diff options
author | Chris Lattner <sabre@nondot.org> | 2004-02-18 23:25:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-02-18 23:25:22 +0000 |
commit | ea9212ca964ff6587227016f86a44160e586a4c8 (patch) | |
tree | 0a54b20946e27c6a7a97b9797c9e9e80d6a35b5c | |
parent | ca005120082385026fd80fe76946fc446d3c9d33 (diff) |
Add a new method for use by the code generator crash debugger.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11613 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/bugpoint/BugDriver.h | 6 | ||||
-rw-r--r-- | tools/bugpoint/ExecutionDriver.cpp | 20 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h index 3ef50f6217..297bab53b4 100644 --- a/tools/bugpoint/BugDriver.h +++ b/tools/bugpoint/BugDriver.h @@ -127,6 +127,12 @@ public: /// the specified one as the current program. void setNewProgram(Module *M); + /// compileProgram - Try to compile the specified module, throwing an + /// exception if an error occurs, or returning normally if not. This is used + /// for code generation crash testing. + /// + void compileProgram(Module *M); + /// executeProgram - This method runs "Program", capturing the output of the /// program to a file, returning the filename of the file. A recommended /// filename may be optionally specified. If there is a problem with the code diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp index 01f7be89e3..3d4e61058f 100644 --- a/tools/bugpoint/ExecutionDriver.cpp +++ b/tools/bugpoint/ExecutionDriver.cpp @@ -137,6 +137,26 @@ bool BugDriver::initializeExecutionEnvironment() { return Interpreter == 0; } +/// compileProgram - Try to compile the specified module, throwing an exception +/// if an error occurs, or returning normally if not. This is used for code +/// generation crash testing. +/// +void BugDriver::compileProgram(Module *M) { + // Emit the program to a bytecode file... + std::string BytecodeFile = getUniqueFilename("bugpoint-test-program.bc"); + if (writeProgramToFile(BytecodeFile, M)) { + std::cerr << ToolName << ": Error emitting bytecode to file '" + << BytecodeFile << "'!\n"; + exit(1); + } + + // Remove the temporary bytecode file when we are done. + FileRemover BytecodeFileRemover(BytecodeFile); + + // Actually compile the program! + Interpreter->compileProgram(BytecodeFile); +} + /// executeProgram - This method runs "Program", capturing the output of the /// program to a file, returning the filename of the file. A recommended |