[llvm-commits] CVS: llvm/tools/bugpoint/ExtractFunction.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Mar 14 15:18:12 PST 2004
Changes in directory llvm/tools/bugpoint:
ExtractFunction.cpp updated: 1.28 -> 1.29
---
Log message:
Refactor to use a new method
---
Diffs of the changes: (+14 -38)
Index: llvm/tools/bugpoint/ExtractFunction.cpp
diff -u llvm/tools/bugpoint/ExtractFunction.cpp:1.28 llvm/tools/bugpoint/ExtractFunction.cpp:1.29
--- llvm/tools/bugpoint/ExtractFunction.cpp:1.28 Sun Mar 14 14:50:42 2004
+++ llvm/tools/bugpoint/ExtractFunction.cpp Sun Mar 14 15:17:22 2004
@@ -112,25 +112,13 @@
CleanupPasses.push_back(getPI(createDeadArgHackingPass()));
else
CleanupPasses.push_back(getPI(createDeadArgEliminationPass()));
-
- std::swap(Program, M);
- std::string Filename;
- bool Failed = runPasses(CleanupPasses, Filename);
- std::swap(Program, M);
- if (Failed) {
+ Module *New = runPassesOn(M, CleanupPasses);
+ if (New == 0) {
std::cerr << "Final cleanups failed. Sorry. :( Please report a bug!\n";
- } else {
- delete M;
- M = ParseInputFile(Filename);
- if (M == 0) {
- std::cerr << getToolName() << ": Error reading bytecode file '"
- << Filename << "'!\n";
- exit(1);
- }
- removeFile(Filename);
}
- return M;
+ delete M;
+ return New;
}
@@ -141,32 +129,20 @@
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) {
+ Module *NewM = runPassesOn(M, LoopExtractPasses);
+ if (NewM == 0) {
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;
+ // 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;
}
More information about the llvm-commits
mailing list