[llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.h OptimizerDriver.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Mar 14 15:18:01 PST 2004
Changes in directory llvm/tools/bugpoint:
BugDriver.h updated: 1.33 -> 1.34
OptimizerDriver.cpp updated: 1.18 -> 1.19
---
Log message:
Add new method
---
Diffs of the changes: (+28 -0)
Index: llvm/tools/bugpoint/BugDriver.h
diff -u llvm/tools/bugpoint/BugDriver.h:1.33 llvm/tools/bugpoint/BugDriver.h:1.34
--- llvm/tools/bugpoint/BugDriver.h:1.33 Sun Mar 14 14:50:42 2004
+++ llvm/tools/bugpoint/BugDriver.h Sun Mar 14 15:17:03 2004
@@ -190,6 +190,11 @@
/// program or if the loop extractor crashes.
Module *ExtractLoop(Module *M);
+ /// runPassesOn - Carefully run the specified set of pass on the specified
+ /// module, returning the transformed module on success, or a null pointer on
+ /// failure.
+ Module *runPassesOn(Module *M, const std::vector<const PassInfo*> &Passes);
+
/// runPasses - Run the specified passes on Program, outputting a bytecode
/// file and writting the filename into OutputFile if successful. If the
/// optimizations fail for some reason (optimizer crashes), return true,
Index: llvm/tools/bugpoint/OptimizerDriver.cpp
diff -u llvm/tools/bugpoint/OptimizerDriver.cpp:1.18 llvm/tools/bugpoint/OptimizerDriver.cpp:1.19
--- llvm/tools/bugpoint/OptimizerDriver.cpp:1.18 Wed Feb 18 17:24:56 2004
+++ llvm/tools/bugpoint/OptimizerDriver.cpp Sun Mar 14 15:17:03 2004
@@ -161,3 +161,26 @@
return !ExitedOK;
}
+
+/// runPassesOn - Carefully run the specified set of pass on the specified
+/// module, returning the transformed module on success, or a null pointer on
+/// failure.
+Module *BugDriver::runPassesOn(Module *M,
+ const std::vector<const PassInfo*> &Passes) {
+ Module *OldProgram = swapProgramIn(M);
+ std::string BytecodeResult;
+ if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/))
+ return 0;
+
+ // Restore the current program.
+ swapProgramIn(OldProgram);
+
+ Module *Ret = ParseInputFile(BytecodeResult);
+ if (Ret == 0) {
+ std::cerr << getToolName() << ": Error reading bytecode file '"
+ << BytecodeResult << "'!\n";
+ exit(1);
+ }
+ removeFile(BytecodeResult); // No longer need the file on disk
+ return Ret;
+}
More information about the llvm-commits
mailing list