[llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Apr 2 00:33:03 PST 2004


Changes in directory llvm/tools/bugpoint:

Miscompilation.cpp updated: 1.33 -> 1.34

---
Log message:

Fix two pretty serious bugs:
  1. Each time the loop extractor extracted a loop, we would leak a module.
  2. When we extracted a loop, we didn't add the new function to the list of
     miscompiled functions.  Thus if the bug was in a loop nest and we 
     extracted it, we could actually *LOSE THE BUG*, which is very bad.

With these patches, bugpoint has successfully found a bug for me in a function
with several nested loops, and cut it down to just one of them. :) :)



---
Diffs of the changes:  (+14 -9)

Index: llvm/tools/bugpoint/Miscompilation.cpp
diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.33 llvm/tools/bugpoint/Miscompilation.cpp:1.34
--- llvm/tools/bugpoint/Miscompilation.cpp:1.33	Wed Mar 17 11:42:09 2004
+++ llvm/tools/bugpoint/Miscompilation.cpp	Fri Apr  2 00:32:17 2004
@@ -165,7 +165,7 @@
 
   // Delete the linked module & restore the original
   BD.swapProgramIn(OldProgram);
-  if (DeleteInputs) delete M1;
+  delete M1;
   return Broken;
 }
 
@@ -267,17 +267,22 @@
                 << ErrorMsg << "\n";
       exit(1);
     }
-    delete ToOptimizeLoopExtracted;
 
     // All of the Function*'s in the MiscompiledFunctions list are in the old
-    // module.  Make sure to update them to point to the corresponding functions
-    // in the new module.
-    for (unsigned i = 0, e = MiscompiledFunctions.size(); i != e; ++i) {
-      Function *OldF = MiscompiledFunctions[i];
-      Function *NewF = 
-        ToNotOptimize->getFunction(OldF->getName(), OldF->getFunctionType());
-      MiscompiledFunctions[i] = NewF;
+    // module.  Update this list to include all of the functions in the
+    // optimized and loop extracted module.
+    MiscompiledFunctions.clear();
+    for (Module::iterator I = ToOptimizeLoopExtracted->begin(),
+           E = ToOptimizeLoopExtracted->end(); I != E; ++I) {
+      if (!I->isExternal()) {
+        Function *OldF = I;
+        Function *NewF = 
+          ToNotOptimize->getFunction(OldF->getName(), OldF->getFunctionType());
+        assert(NewF && "Function not found??");
+        MiscompiledFunctions.push_back(NewF);
+      }
     }
+    delete ToOptimizeLoopExtracted;
 
     BD.setNewProgram(ToNotOptimize);
     MadeChange = true;





More information about the llvm-commits mailing list