summaryrefslogtreecommitdiff
path: root/tools/bugpoint/CrashDebugger.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-04-25 00:53:05 +0000
committerChris Lattner <sabre@nondot.org>2003-04-25 00:53:05 +0000
commit5f73e38548c57636ad0ef8c719d040e166761962 (patch)
treec17a075ab49b4daf6841f03808a9ed775cc6c4e5 /tools/bugpoint/CrashDebugger.cpp
parent16608b4c853ba883ac4bf5c642c4a9b4977a4fba (diff)
downloadllvm-5f73e38548c57636ad0ef8c719d040e166761962.tar.gz
llvm-5f73e38548c57636ad0ef8c719d040e166761962.tar.bz2
llvm-5f73e38548c57636ad0ef8c719d040e166761962.tar.xz
Big programs have tons of global variable initializers, and most passes don't care
about them. Try to delete them if it doesn't affect the passes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint/CrashDebugger.cpp')
-rw-r--r--tools/bugpoint/CrashDebugger.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 2d224f3fba..fd711d99fc 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -244,6 +244,36 @@ bool BugDriver::debugCrash() {
<< getPassesString(PassesToRun) << "\n";
EmitProgressBytecode("passinput");
+
+ // See if we can get away with nuking all of the global variable initializers
+ // in the program...
+ if (Program->gbegin() != Program->gend()) {
+ Module *M = CloneModule(Program);
+ bool DeletedInit = false;
+ for (Module::giterator I = M->gbegin(), E = M->gend(); 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: ";
+ std::swap(Program, M);
+ if (runPasses(PassesToRun)) { // Still crashes?
+ AnyReduction = true;
+ delete M;
+ std::cout << "\n*** Able to remove all global initializers!\n";
+ } else { // No longer crashes?
+ delete Program; // Restore program.
+ Program = M;
+ std::cout << " - Removing all global inits hides problem!\n";
+ }
+ }
+ }
// Now try to reduce the number of functions in the module to something small.
std::vector<Function*> Functions;