Fix PR1752 and LoopSimplify/2007-10-28-InvokeCrash.ll: terminators

can have uses too.  Wouldn't it be nice if invoke didn't exist? :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43426 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2007-10-29 02:30:37 +00:00
parent adc9b9c317
commit 3cb63ddd51
2 changed files with 898 additions and 4 deletions

View File

@@ -34,7 +34,7 @@
#define DEBUG_TYPE "loopsimplify"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Constant.h"
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/Function.h"
#include "llvm/Type.h"
@@ -158,12 +158,14 @@ bool LoopSimplify::runOnFunction(Function &F) {
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
TI->getSuccessor(i)->removePredecessor(BB);
// Add a new unreachable instruction.
// Add a new unreachable instruction before the old terminator.
new UnreachableInst(TI);
// Delete the dead terminator.
if (AA) AA->deleteValue(&BB->back());
BB->getInstList().pop_back();
if (AA) AA->deleteValue(TI);
if (!TI->use_empty())
TI->replaceAllUsesWith(UndefValue::get(TI->getType()));
TI->eraseFromParent();
Changed |= true;
}