[llvm-commits] [llvm] r103523 - /llvm/trunk/tools/bugpoint/Miscompilation.cpp

Jeffrey Yasskin jyasskin at google.com
Tue May 11 16:25:16 PDT 2010


Author: jyasskin
Date: Tue May 11 18:25:16 2010
New Revision: 103523

URL: http://llvm.org/viewvc/llvm-project?rev=103523&view=rev
Log:
Fix PR6951 by fixing Module leaks in bugpoint.

Modified:
    llvm/trunk/tools/bugpoint/Miscompilation.cpp

Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=103523&r1=103522&r2=103523&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original)
+++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Tue May 11 18:25:16 2010
@@ -126,7 +126,8 @@
   // Ok, so now we know that the prefix passes work, try running the suffix
   // passes on the result of the prefix passes.
   //
-  Module *PrefixOutput = ParseInputFile(BitcodeResult, BD.getContext());
+  OwningPtr<Module> PrefixOutput(ParseInputFile(BitcodeResult,
+                                                BD.getContext()));
   if (PrefixOutput == 0) {
     errs() << BD.getToolName() << ": Error reading bitcode file '"
            << BitcodeResult << "'!\n";
@@ -142,7 +143,7 @@
             << "' passes compile correctly after the '"
             << getPassesString(Prefix) << "' passes: ";
 
-  Module *OriginalInput = BD.swapProgramIn(PrefixOutput);
+  OwningPtr<Module> OriginalInput(BD.swapProgramIn(PrefixOutput.take()));
   if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
     errs() << " Error running this sequence of passes"
            << " on the input program!\n";
@@ -157,13 +158,13 @@
     return InternalError;
   if (Diff) {
     outs() << " nope.\n";
-    delete OriginalInput;     // We pruned down the original input...
     return KeepSuffix;
   }
 
   // Otherwise, we must not be running the bad pass anymore.
   outs() << " yup.\n";      // No miscompilation!
-  delete BD.swapProgramIn(OriginalInput); // Restore orig program & free test
+  // Restore orig program & free test.
+  delete BD.swapProgramIn(OriginalInput.take());
   return NoFailure;
 }
 
@@ -222,15 +223,14 @@
   }
   delete M2;   // We are done with this module.
 
-  Module *OldProgram = BD.swapProgramIn(M1);
+  OwningPtr<Module> OldProgram(BD.swapProgramIn(M1));
 
   // Execute the program.  If it does not match the expected output, we must
   // return true.
   bool Broken = BD.diffProgram("", "", false, &Error);
   if (!Error.empty()) {
     // Delete the linked module & restore the original
-    BD.swapProgramIn(OldProgram);
-    delete M1;
+    delete BD.swapProgramIn(OldProgram.take());
   }
   return Broken;
 }





More information about the llvm-commits mailing list