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 | 4a15e04aee7436b080b76717193c8dd6ef8d66c1 (patch) | |
tree | a4350aeac80b03ec5123dbf3c43cfab759533b28 /llvm/lib/Transforms/Utils/LoopSimplify.cpp | |
parent | 8be9bc64ce349838acf73a6e604411506bae1a15 (diff) | |
download | llvm-4a15e04aee7436b080b76717193c8dd6ef8d66c1.zip llvm-4a15e04aee7436b080b76717193c8dd6ef8d66c1.tar.gz llvm-4a15e04aee7436b080b76717193c8dd6ef8d66c1.tar.bz2 |
Fix PR1752 and LoopSimplify/2007-10-28-InvokeCrash.ll: terminators
can have uses too. Wouldn't it be nice if invoke didn't exist? :)
llvm-svn: 43426
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopSimplify.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 20eecd6..21a4e23 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/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; } |