15#include "mlir/Bytecode/BytecodeWriter.h"
16#include "mlir/IR/Verifier.h"
17#include "llvm/Support/ToolOutputFile.h"
28 bool testMustFail,
bool emitBytecode)
29 : emitBytecode(emitBytecode), testScript(testScript),
30 testScriptArgs(testScriptArgs), testMustFail(testMustFail) {}
33 auto test =
get(module);
34 return std::make_pair(test.isInteresting(), test.getSize());
43 SmallVector<StringRef> testerArgs;
46 testerArgs.push_back(testCase);
50 int result = llvm::sys::ExecuteAndWait(
51 testScript, testerArgs, std::nullopt, std::nullopt,
54 llvm::report_fatal_error(
55 Twine(
"Error running interestingness test: ") + errMsg,
false);
84 valid = succeeded(verify(module));
128 std::error_code ec = llvm::sys::fs::createTemporaryFile(
129 "circt-reduce",
"mlir", fd,
filepath);
131 llvm::report_fatal_error(
132 Twine(
"Error making unique filename: ") + ec.message(),
false);
135 file = std::make_unique<llvm::ToolOutputFile>(
filepath, fd);
137 if (failed(writeBytecodeToFile(
141 llvm::report_fatal_error(
142 llvm::Twine(
"Error emitting the IR to file `") +
filepath +
"`",
146 module.print(file->os());
150 if (
file->os().has_error())
151 llvm::report_fatal_error(llvm::Twine(
"Error emitting the IR to file `") +
163 std::error_code ec = llvm::sys::fs::file_size(
filepath, fileSize);
165 llvm::report_fatal_error(Twine(
"Error determining size of file `") +
assert(baseType &&"element must be base type")
A single test case to be run by a tester.
std::optional< bool > interesting
Whether the tester has run on this test case, and its result.
mlir::ModuleOp llvm::SmallString< 32 > filepath
The module to be tested.
size_t getSize()
Determine the size of the MLIR module on disk.
bool isValid()
Check whether the MLIR module is valid.
std::optional< size_t > size
Whether the size of the test case on disk has already been determined, and if yes,...
void ensureFileOnDisk()
Ensure filepath and size are populated, and that the test case is in a file on disk.
std::optional< bool > valid
Whether the MLIR module validation has run, and its result.
bool isInteresting()
Run the tester on the MLIR module and return whether it is deemed interesting.
const Tester & tester
The tester that is used to run this test case.
llvm::StringRef getFilepath()
Determine the path to the MLIR module on disk.
std::unique_ptr< llvm::ToolOutputFile > file
In case this test case has created a temporary file on disk, this is the ToolOutputFile that did the ...
llvm::StringRef testScript
The binary to execute in order to check a reduction attempt for interestingness.
const bool emitBytecode
If true, use MLIR bytecode on-disk. Otherwise, use MLIR text.
Tester(llvm::StringRef testScript, llvm::ArrayRef< std::string > testScriptArgs, bool testMustFail, bool emitBytecode)
std::pair< bool, size_t > isInteresting(mlir::ModuleOp module) const
Runs the interestingness testing script on a MLIR test case file.
bool testMustFail
Consider the testcase to be interesting if it fails rather than on exit code 0.
TestCase get(mlir::ModuleOp module) const
Create a new test case for the given module.
llvm::ArrayRef< std::string > testScriptArgs
Additional arguments to pass to testScript.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
const char * getCirctVersion()