summaryrefslogtreecommitdiffstats
path: root/llvm/tools/bugpoint/CrashDebugger.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2006-10-27 20:18:06 +0000
committerBill Wendling <isanbard@gmail.com>2006-10-27 20:18:06 +0000
commit74a4a2a80be2440b85299fd945bff9a320b20ff6 (patch)
tree24d2e273e5e40ba65c3155bc896dae81e619aa51 /llvm/tools/bugpoint/CrashDebugger.cpp
parentcef515fcc0fc45a51d4768e99fe7c3893c1a8ad8 (diff)
downloadbcm5719-llvm-74a4a2a80be2440b85299fd945bff9a320b20ff6.tar.gz
bcm5719-llvm-74a4a2a80be2440b85299fd945bff9a320b20ff6.zip
Re-added the part where it tries to remove all global variables first.
llvm-svn: 31225
Diffstat (limited to 'llvm/tools/bugpoint/CrashDebugger.cpp')
-rw-r--r--llvm/tools/bugpoint/CrashDebugger.cpp49
1 files changed, 37 insertions, 12 deletions
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index b86bb8fa042..a67d9922fce 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -357,22 +357,47 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
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 = M->global_begin(), E = M->global_end();
+ I != E; ++I)
+ if (I->hasInitializer()) {
+ I->setInitializer(0);
+ I->setLinkage(GlobalValue::ExternalLinkage);
+ DeletedInit = true;
+ }
+
+ 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 (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);
+ 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";
+ 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);
+ unsigned OldSize = GVs.size();
+ ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs);
- if (GVs.size() < OldSize)
- BD.EmitProgressBytecode("reduced-global-variables");
+ if (GVs.size() < OldSize)
+ BD.EmitProgressBytecode("reduced-global-variables");
+ }
}
}
OpenPOWER on IntegriCloud