diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-07-22 04:54:44 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-07-22 04:54:44 +0000 |
commit | 522a91181af75702f1526640d8fd356e22ea383a (patch) | |
tree | 40ee58b3e30ca6cdbdf69e8bd1881b4ec2a23afc /llvm/lib/Transforms/Scalar/JumpThreading.cpp | |
parent | d382e9d82b086187601cf786d4143816e124eb9f (diff) | |
download | llvm-522a91181af75702f1526640d8fd356e22ea383a.zip llvm-522a91181af75702f1526640d8fd356e22ea383a.tar.gz llvm-522a91181af75702f1526640d8fd356e22ea383a.tar.bz2 |
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.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index b9e717c..d1769fc 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; } } |