summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-07-22 04:54:44 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-07-22 04:54:44 +0000
commit522a91181af75702f1526640d8fd356e22ea383a (patch)
tree40ee58b3e30ca6cdbdf69e8bd1881b4ec2a23afc /llvm/lib/Transforms/Scalar/JumpThreading.cpp
parentd382e9d82b086187601cf786d4143816e124eb9f (diff)
downloadbcm5719-llvm-522a91181af75702f1526640d8fd356e22ea383a.tar.gz
bcm5719-llvm-522a91181af75702f1526640d8fd356e22ea383a.zip
Don't remove side effecting instructions due to ConstantFoldInstruction
Just because we can constant fold the result of an instruction does not imply that we can delete the instruction. It may have side effects. This fixes PR28655. llvm-svn: 276389
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index b9e717cf763..d1769fc3ebb 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -758,7 +758,8 @@ bool JumpThreadingPass::ProcessBlock(BasicBlock *BB) {
ConstantFoldInstruction(I, BB->getModule()->getDataLayout(), TLI);
if (SimpleVal) {
I->replaceAllUsesWith(SimpleVal);
- I->eraseFromParent();
+ if (isInstructionTriviallyDead(I, TLI))
+ I->eraseFromParent();
Condition = SimpleVal;
}
}
OpenPOWER on IntegriCloud