diff options
author | Chris Lattner <sabre@nondot.org> | 2002-03-11 22:11:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-03-11 22:11:07 +0000 |
commit | 0fce76a009bccfa427575643a2b793fd53e8aff1 (patch) | |
tree | a69d8e71f8eca22bbf44c91344c438cf449b5afa /lib/Transforms/Scalar/ConstantProp.cpp | |
parent | 81ba70445fce530384a8e7e36be56b5cb804fc30 (diff) |
Fix bug: test/Regression/Other/2002-03-11-ConstPropCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1858 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/ConstantProp.cpp')
-rw-r--r-- | lib/Transforms/Scalar/ConstantProp.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index fc4e3bf0e3..624e6da39d 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -102,7 +102,8 @@ ConstantFoldBinaryInst(BasicBlock *BB, BasicBlock::iterator &II, // constant value, convert it into an unconditional branch to the constant // destination. // -bool ConstantFoldTerminator(TerminatorInst *T) { +bool ConstantFoldTerminator(BasicBlock *BB, BasicBlock::iterator &II, + TerminatorInst *T) { // Branch - See if we are conditional jumping on constant if (BranchInst *BI = dyn_cast<BranchInst>(T)) { if (BI->isUnconditional()) return false; // Can't optimize uncond branch @@ -127,6 +128,7 @@ bool ConstantFoldTerminator(TerminatorInst *T) { // Set the unconditional destination, and change the insn to be an // unconditional branch. BI->setUnconditionalDest(Destination); + II = BB->end()-1; // Update instruction iterator! return true; } #if 0 @@ -171,7 +173,7 @@ bool doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &II) { Constant *D = dyn_cast<Constant>(UInst->getOperand(0)); if (D) return ConstantFoldUnaryInst(BB, II, UInst, D); } else if (TerminatorInst *TInst = dyn_cast<TerminatorInst>(Inst)) { - return ConstantFoldTerminator(TInst); + return ConstantFoldTerminator(BB, II, TInst); } else if (PHINode *PN = dyn_cast<PHINode>(Inst)) { // If it's a PHI node and only has one operand |