/// 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...
+ /// before handing it to the user... if the module parameter is specified, it
+ /// operates directly on the specified Module, modifying it in place.
///
- Module *performFinalCleanups() const;
+ Module *performFinalCleanups(Module *M = 0) const;
/// initializeExecutionEnvironment - This method is used to set up the
/// environment for executing LLVM programs.
/// a series of cleanups intended to get rid of extra cruft on the module
/// before handing it to the user...
///
-Module *BugDriver::performFinalCleanups() const {
- Module *M = CloneModule(Program);
+Module *BugDriver::performFinalCleanups(Module *InM) const {
+ Module *M = InM ? InM : CloneModule(Program);
// Allow disabling these passes if they crash bugpoint.
//
CleanupPasses.add(createFunctionResolvingPass());
CleanupPasses.add(createGlobalDCEPass());
CleanupPasses.add(createDeadTypeEliminationPass());
- CleanupPasses.add(createDeadArgEliminationPass(true));
+ CleanupPasses.add(createDeadArgEliminationPass(InM == 0));
CleanupPasses.add(createVerifierPass());
CleanupPasses.run(*M);
return M;