[llvm-commits] CVS: llvm/tools/bugpoint/ExtractFunction.cpp BugDriver.h
Chris Lattner
lattner at cs.uiuc.edu
Sun Mar 14 14:03:01 PST 2004
Changes in directory llvm/tools/bugpoint:
ExtractFunction.cpp updated: 1.26 -> 1.27
BugDriver.h updated: 1.31 -> 1.32
---
Log message:
Add a method to extract a loop
---
Diffs of the changes: (+42 -1)
Index: llvm/tools/bugpoint/ExtractFunction.cpp
diff -u llvm/tools/bugpoint/ExtractFunction.cpp:1.26 llvm/tools/bugpoint/ExtractFunction.cpp:1.27
--- llvm/tools/bugpoint/ExtractFunction.cpp:1.26 Sun Mar 14 13:31:00 2004
+++ llvm/tools/bugpoint/ExtractFunction.cpp Sun Mar 14 14:02:07 2004
@@ -117,7 +117,7 @@
std::swap(Program, M);
if (Failed) {
- std::cerr << "Final cleanups failed. Sorry. :(\n";
+ std::cerr << "Final cleanups failed. Sorry. :( Please report a bug!\n";
} else {
delete M;
M = ParseInputFile(Filename);
@@ -129,6 +129,42 @@
removeFile(Filename);
}
return M;
+}
+
+
+/// ExtractLoop - Given a module, extract up to one loop from it into a new
+/// function. This returns null if there are no extractable loops in the
+/// program or if the loop extractor crashes.
+Module *BugDriver::ExtractLoop(Module *M) {
+ std::vector<const PassInfo*> LoopExtractPasses;
+ LoopExtractPasses.push_back(getPI(createSingleLoopExtractorPass()));
+
+ std::swap(Program, M);
+ std::string Filename;
+ bool Failed = runPasses(LoopExtractPasses, Filename);
+ std::swap(Program, M);
+
+ if (Failed) {
+ std::cerr << "Loop extraction failed. Sorry. :( Please report a bug!\n";
+ return 0;
+ } else {
+ Module *NewM = ParseInputFile(Filename);
+ if (NewM == 0) {
+ std::cerr << getToolName() << ": Error reading bytecode file '"
+ << Filename << "'!\n";
+ exit(1);
+ }
+ removeFile(Filename);
+
+ // Check to see if we created any new functions. If not, no loops were
+ // extracted and we should return null.
+ if (M->size() != NewM->size()) {
+ delete NewM;
+ return 0;
+ }
+
+ return NewM;
+ }
}
Index: llvm/tools/bugpoint/BugDriver.h
diff -u llvm/tools/bugpoint/BugDriver.h:1.31 llvm/tools/bugpoint/BugDriver.h:1.32
--- llvm/tools/bugpoint/BugDriver.h:1.31 Sun Mar 14 13:27:19 2004
+++ llvm/tools/bugpoint/BugDriver.h Sun Mar 14 14:02:07 2004
@@ -178,6 +178,11 @@
///
Module *performFinalCleanups(Module *M, bool MayModifySemantics = false);
+ /// ExtractLoop - Given a module, extract up to one loop from it into a new
+ /// function. This returns null if there are no extractable loops in the
+ /// program or if the loop extractor crashes.
+ Module *ExtractLoop(Module *M);
+
private:
/// ParseInputFile - Given a bytecode or assembly input filename, parse and
/// return it, or return null if not possible.
More information about the llvm-commits
mailing list