Add support for partial redefs to the fast register allocator.
[oota-llvm.git] / tools / bugpoint / Miscompilation.cpp
index 96aab95a5baad06f60922c26f72997afbc16f52c..71484a250745f37bc3e6ef40297d60c84b9abad4 100644 (file)
@@ -126,7 +126,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
   // 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 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
             << "' 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 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
     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 @@ static bool TestMergedProgram(BugDriver &BD, Module *M1, Module *M2,
   }
   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;
 }
@@ -909,7 +909,7 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe,
   }
   std::string SharedObject = BD.compileSharedObject(SafeModuleBC.str(), Error);
   if (!Error.empty())
-    return -1;
+    return false;
   delete Safe;
 
   // Run the code generator on the `Test' code, loading the shared library.
@@ -1000,7 +1000,7 @@ bool BugDriver::debugCodeGenerator(std::string *Error) {
   if (isExecutingJIT()) {
     outs() << "  lli -load " << SharedObject << " " << TestModuleBC.str();
   } else {
-    outs() << "  llc -f " << TestModuleBC.str() << " -o " << TestModuleBC.str()
+    outs() << "  llc " << TestModuleBC.str() << " -o " << TestModuleBC.str()
            << ".s\n";
     outs() << "  gcc " << SharedObject << " " << TestModuleBC.str()
               << ".s -o " << TestModuleBC.str() << ".exe";