///
Module *deleteInstructionFromProgram(Instruction *I, unsigned Simp) const;
+ /// performFinalCleanups - This method clones the current Program and performs
+ /// a series of cleanups intended to get rid of extra cruft on the module
+ /// before handing it to the user...
+ ///
+ Module *performFinalCleanups() const;
+
/// initializeExecutionEnvironment - This method is used to set up the
/// environment for executing LLVM programs.
///
///
bool BugDriver::debugPassCrash(const PassInfo *Pass) {
EmitProgressBytecode(Pass, "passinput");
+ bool Reduced = false, AnyReduction = false;
if (CountFunctions(Program) > 1) {
// Attempt to reduce the input program down to a single function that still
// reduce the testcase...
delete M;
- EmitProgressBytecode(Pass, "reduced-"+I->getName());
+ Reduced = AnyReduction = true;
break;
}
}
}
+ if (Reduced) {
+ EmitProgressBytecode(Pass, "reduced-function");
+ Reduced = false;
+ }
+
// FIXME: This should attempt to delete entire basic blocks at a time to speed
// up convergence...
if (runPass(Pass)) {
// Yup, it does, we delete the old module, and continue trying to
// reduce the testcase...
- EmitProgressBytecode(Pass, "reduced-" + I->getName());
delete M;
+ Reduced = AnyReduction = true;
goto TryAgain; // I wish I had a multi-level break here!
}
}
}
} while (Simplification);
-
+
+ // Try to clean up the testcase by running funcresolve and globaldce...
+ if (AnyReduction) {
+ std::cout << "\n*** Attempting to perform final cleanups: ";
+ Module *M = performFinalCleanups();
+ std::swap(Program, M);
+
+ // Find out if the pass still crashes on the cleaned up program...
+ if (runPass(Pass)) {
+ // Yup, it does, keep the reduced version...
+ delete M;
+ Reduced = AnyReduction = true;
+ } else {
+ delete Program; // Otherwise, restore the original module...
+ Program = M;
+ }
+ }
+
+ if (Reduced) {
+ EmitProgressBytecode(Pass, "reduced-simplified");
+ Reduced = false;
+ }
+
return false;
}
Passes.run(*Result);
return Result;
}
+
+/// performFinalCleanups - This method clones the current Program and performs
+/// a series of cleanups intended to get rid of extra cruft on the module
+/// before handing it to the user...
+///
+Module *BugDriver::performFinalCleanups() const {
+ PassManager CleanupPasses;
+ CleanupPasses.add(createFunctionResolvingPass());
+ CleanupPasses.add(createGlobalDCEPass());
+ Module *M = CloneModule(Program);
+ CleanupPasses.run(*M);
+ return M;
+}