diff options
author | Chris Lattner <sabre@nondot.org> | 2007-10-29 02:30:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-10-29 02:30:37 +0000 |
commit | 3cb63ddd5183a1469e4557b3e22735ed3ace05b2 (patch) | |
tree | d3dd15bf29082203620573bce0dda146618390ca /lib/Transforms/Utils/LoopSimplify.cpp | |
parent | adc9b9c317ad0cf6b8a5c2cf4e8da351aec3f6b7 (diff) |
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
Diffstat (limited to 'lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r-- | lib/Transforms/Utils/LoopSimplify.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index 20eecd6f33..21a4e23825 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -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; } |