From: Chris Lattner Date: Fri, 2 Apr 2004 06:32:17 +0000 (+0000) Subject: Fix two pretty serious bugs: X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=5313f23b8c3d22a2028beb731c60fc1a25beb149;p=oota-llvm.git 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. :) :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12605 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 6524f7a8aea..043d0df4139 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -165,7 +165,7 @@ static bool TestMergedProgram(BugDriver &BD, Module *M1, Module *M2, // Delete the linked module & restore the original BD.swapProgramIn(OldProgram); - if (DeleteInputs) delete M1; + delete M1; return Broken; } @@ -267,17 +267,22 @@ static bool ExtractLoops(BugDriver &BD, << 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;