Simplify the performFinalCleanups interface
authorChris Lattner <sabre@nondot.org>
Wed, 5 Nov 2003 21:15:19 +0000 (21:15 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 5 Nov 2003 21:15:19 +0000 (21:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9740 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/BugDriver.h
tools/bugpoint/CodeGeneratorBug.cpp
tools/bugpoint/CrashDebugger.cpp
tools/bugpoint/ExtractFunction.cpp

index acd579914d4e0da913bd1ed905fdd3e0d49aaf52..6c48c04fa55926cca32eb26ae0fbf2c9042e90f6 100644 (file)
@@ -158,11 +158,11 @@ private:
   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... if the module parameter is specified, it
-  /// operates directly on the specified Module, modifying it in place.
+  /// a series of cleanups intended to get rid of extra cruft on the module.  If
+  /// the MayModifySemantics argument is true, then the cleanups is allowed to
+  /// modify how the code behaves.
   ///
-  Module *performFinalCleanups(Module *M = 0) const;
+  void performFinalCleanups(Module *M, bool MayModifySemantics = false) const;
 
   /// initializeExecutionEnvironment - This method is used to set up the
   /// environment for executing LLVM programs.
index 41df79a110a96f16eb964ecb13d695442ddba681..29a9f6823ab85ea968e98a78dc240449bf41e1fc 100644 (file)
@@ -224,8 +224,8 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
   }
 
   // Clean up the modules, removing extra cruft that we don't need anymore...
-  SafeModule = BD.performFinalCleanups(SafeModule);
-  TestModule = BD.performFinalCleanups(TestModule);
+  BD.performFinalCleanups(SafeModule);
+  BD.performFinalCleanups(TestModule);
 
   if (BD.writeProgramToFile(TestModuleBC, TestModule)) {
     std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting.";
index fe13e6726dace1f93b2a1a81adfeb68f3b936349..27e99b994ba090888c2f066bb826f3eb79f2797d 100644 (file)
@@ -378,7 +378,8 @@ bool BugDriver::debugCrash() {
 
   // Try to clean up the testcase by running funcresolve and globaldce...
   std::cout << "\n*** Attempting to perform final cleanups: ";
-  Module *M = performFinalCleanups();
+  Module *M = CloneModule(Program);
+  performFinalCleanups(M, true);
   std::swap(Program, M);
             
   // Find out if the pass still crashes on the cleaned up program...
index c65b482b01ef4c63155968ea6b122b114c9848cb..2d7747af77527a27fd060cd17cbea08a4bd8a8cc 100644 (file)
@@ -93,15 +93,13 @@ Module *BugDriver::deleteInstructionFromProgram(Instruction *I,
 /// a series of cleanups intended to get rid of extra cruft on the module
 /// before handing it to the user...
 ///
-Module *BugDriver::performFinalCleanups(Module *InM) const {
-  Module *M = InM ? InM : CloneModule(Program);
-
+void BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) const {
   // Allow disabling these passes if they crash bugpoint.
   //
   // FIXME: This should eventually run these passes in a pass list to prevent
   // them from being able to crash bugpoint at all!
   //
-  if (NoFinalCleanup) return M;
+  if (NoFinalCleanup) return;
 
   // Make all functions external, so GlobalDCE doesn't delete them...
   for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
@@ -113,8 +111,7 @@ Module *BugDriver::performFinalCleanups(Module *InM) const {
   CleanupPasses.add(createFunctionResolvingPass());
   CleanupPasses.add(createGlobalDCEPass());
   CleanupPasses.add(createDeadTypeEliminationPass());
-  CleanupPasses.add(createDeadArgEliminationPass(InM == 0));
+  CleanupPasses.add(createDeadArgEliminationPass(MayModifySemantics));
   CleanupPasses.add(createVerifierPass());
   CleanupPasses.run(*M);
-  return M;
 }