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/InstCombine/InstructionCombining.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/InstCombine/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 51c3262..377ccb9 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2830,7 +2830,8 @@ bool InstCombiner::run() { // Add operands to the worklist. replaceInstUsesWith(*I, C); ++NumConstProp; - eraseInstFromFunction(*I); + if (isInstructionTriviallyDead(I, TLI)) + eraseInstFromFunction(*I); MadeIRChange = true; continue; } @@ -2851,7 +2852,8 @@ bool InstCombiner::run() { // Add operands to the worklist. replaceInstUsesWith(*I, C); ++NumConstProp; - eraseInstFromFunction(*I); + if (isInstructionTriviallyDead(I, TLI)) + eraseInstFromFunction(*I); MadeIRChange = true; continue; } @@ -3007,7 +3009,8 @@ static bool AddReachableCodeToWorklist(BasicBlock *BB, const DataLayout &DL, << *Inst << '\n'); Inst->replaceAllUsesWith(C); ++NumConstProp; - Inst->eraseFromParent(); + if (isInstructionTriviallyDead(Inst, TLI)) + Inst->eraseFromParent(); continue; } |