Add a new method for use by the code generator crash debugger.
authorChris Lattner <sabre@nondot.org>
Wed, 18 Feb 2004 23:25:22 +0000 (23:25 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 18 Feb 2004 23:25:22 +0000 (23:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11613 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/BugDriver.h
tools/bugpoint/ExecutionDriver.cpp

index 3ef50f6217fec7d65ab41b22e6f84387665955a0..297bab53b4eef64cf96f31ff162eeb62b9f793c1 100644 (file)
@@ -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
index 01f7be89e35a8465e9bd4413f53a1a58f6c7be71..3d4e61058ff37bead6831cdef56059ec6337c99d 100644 (file)
@@ -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