[llvm-commits] CVS: llvm/tools/bugpoint/CrashDebugger.cpp

Bill Wendling isanbard at gmail.com
Fri Oct 27 13:18:20 PDT 2006



Changes in directory llvm/tools/bugpoint:

CrashDebugger.cpp updated: 1.50 -> 1.51
---
Log message:

Re-added the part where it tries to remove all global variables first.


---
Diffs of the changes:  (+38 -13)

 CrashDebugger.cpp |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 13 deletions(-)


Index: llvm/tools/bugpoint/CrashDebugger.cpp
diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.50 llvm/tools/bugpoint/CrashDebugger.cpp:1.51
--- llvm/tools/bugpoint/CrashDebugger.cpp:1.50	Wed Oct 25 13:36:14 2006
+++ llvm/tools/bugpoint/CrashDebugger.cpp	Fri Oct 27 15:18:06 2006
@@ -357,22 +357,47 @@
   if (BD.getProgram()->global_begin() != BD.getProgram()->global_end()) {
     // Now try to reduce the number of global variable initializers in the
     // module to something small.
-    std::vector<GlobalVariable*> GVs;
+    Module *M = CloneModule(BD.getProgram());
+    bool DeletedInit = false;
 
-    for (Module::global_iterator I = BD.getProgram()->global_begin(),
-           E = BD.getProgram()->global_end(); I != E; ++I)
-      if (I->hasInitializer())
-        GVs.push_back(I);
-
-    if (GVs.size() > 1 && !BugpointIsInterrupted) {
-      std::cout << "\n*** Attempting to reduce the number of global variables "
-                << "in the testcase\n";
+    for (Module::global_iterator I = M->global_begin(), E = M->global_end();
+         I != E; ++I)
+      if (I->hasInitializer()) {
+        I->setInitializer(0);
+        I->setLinkage(GlobalValue::ExternalLinkage);
+        DeletedInit = true;
+      }
 
-      unsigned OldSize = GVs.size();
-      ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs);
+    if (!DeletedInit) {
+      delete M;  // No change made...
+    } else {
+      // See if the program still causes a crash...
+      std::cout << "\nChecking to see if we can delete global inits: ";
 
-      if (GVs.size() < OldSize)
-        BD.EmitProgressBytecode("reduced-global-variables");
+      if (TestFn(BD, M)) {      // Still crashes?
+        BD.setNewProgram(M);
+        std::cout << "\n*** Able to remove all global initializers!\n";
+      } else {                  // No longer crashes?
+        std::cout << "  - Removing all global inits hides problem!\n";
+        delete M;
+
+        std::vector<GlobalVariable*> GVs;
+
+        for (Module::global_iterator I = BD.getProgram()->global_begin(),
+               E = BD.getProgram()->global_end(); I != E; ++I)
+          if (I->hasInitializer())
+            GVs.push_back(I);
+
+        if (GVs.size() > 1 && !BugpointIsInterrupted) {
+          std::cout << "\n*** Attempting to reduce the number of global "
+                    << "variables in the testcase\n";
+
+          unsigned OldSize = GVs.size();
+          ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs);
+
+          if (GVs.size() < OldSize)
+            BD.EmitProgressBytecode("reduced-global-variables");
+        }
     }
   }
 






More information about the llvm-commits mailing list