[llc/opt] Add an option to run all passes twice
[oota-llvm.git] / tools / bugpoint / CrashDebugger.cpp
index 91bf033ac9c159e2600bda41006e994ef4393815..631a58455c5b93968d32e4187fd3e9feee71e2e1 100644 (file)
@@ -162,7 +162,7 @@ ReduceCrashingGlobalVariables::TestGlobalVariables(
   // playing with...
   for (GlobalVariable &I : M->globals())
     if (I.hasInitializer() && !GVSet.count(&I)) {
-      I.setInitializer(nullptr);
+      DeleteGlobalInitializer(&I);
       I.setLinkage(GlobalValue::ExternalLinkage);
     }
 
@@ -373,8 +373,9 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
           (*SI)->removePredecessor(&*BB);
 
         TerminatorInst *BBTerm = BB->getTerminator();
-
-        if (!BB->getTerminator()->getType()->isVoidTy())
+        if (BBTerm->isEHPad())
+          continue;
+        if (!BBTerm->getType()->isVoidTy() && !BBTerm->getType()->isTokenTy())
           BBTerm->replaceAllUsesWith(Constant::getNullValue(BBTerm->getType()));
 
         // Replace the old terminator instruction.
@@ -476,7 +477,7 @@ bool ReduceCrashingInstructions::TestInsts(std::vector<const Instruction*>
         Instruction *Inst = &*I++;
         if (!Instructions.count(Inst) && !isa<TerminatorInst>(Inst) &&
             !Inst->isEHPad()) {
-          if (!Inst->getType()->isVoidTy())
+          if (!Inst->getType()->isVoidTy() && !Inst->getType()->isTokenTy())
             Inst->replaceAllUsesWith(UndefValue::get(Inst->getType()));
           Inst->eraseFromParent();
         }
@@ -663,7 +664,7 @@ static bool DebugACrash(BugDriver &BD,
     for (Module::global_iterator I = M->global_begin(), E = M->global_end();
          I != E; ++I)
       if (I->hasInitializer()) {
-        I->setInitializer(nullptr);
+        DeleteGlobalInitializer(&*I);
         I->setLinkage(GlobalValue::ExternalLinkage);
         DeletedInit = true;
       }
@@ -785,7 +786,7 @@ static bool DebugACrash(BugDriver &BD,
             } else {
               if (BugpointIsInterrupted) goto ExitLoops;
 
-              if (isa<LandingPadInst>(I))
+              if (I->isEHPad() || I->getType()->isTokenTy())
                 continue;
 
               outs() << "Checking instruction: " << *I;