aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/CloneFunction.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-06-24 19:34:46 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-06-24 19:34:46 +0000
commit3b3e954ea2a48d0d466dec383f6bfa40a90dd0e1 (patch)
tree1aa8c2d5969c527ac4bafc5c71fe4dfd39fa9ae2 /llvm/lib/Transforms/Utils/CloneFunction.cpp
parentf15064871ad933370532f068eca70fb5134ba69f (diff)
downloadllvm-3b3e954ea2a48d0d466dec383f6bfa40a90dd0e1.zip
llvm-3b3e954ea2a48d0d466dec383f6bfa40a90dd0e1.tar.gz
llvm-3b3e954ea2a48d0d466dec383f6bfa40a90dd0e1.tar.bz2
SimplifyInstruction does not imply DCE
We cannot remove an instruction with no uses just because SimplifyInstruction succeeds. It may have side effects. llvm-svn: 273711
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 6ff05fe..59b109e 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -279,6 +279,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
II != IE; ++II) {
Instruction *NewInst = II->clone();
+ VMap[&*II] = NewInst; // Add instruction map to value.
// Eagerly remap operands to the newly cloned instruction, except for PHI
// nodes for which we defer processing until we update the CFG.
@@ -297,14 +298,15 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
V = MappedV;
VMap[&*II] = V;
- delete NewInst;
- continue;
+ if (!NewInst->mayHaveSideEffects()) {
+ delete NewInst;
+ continue;
+ }
}
}
if (II->hasName())
NewInst->setName(II->getName()+NameSuffix);
- VMap[&*II] = NewInst; // Add instruction map to value.
NewBB->getInstList().push_back(NewInst);
hasCalls |= (isa<CallInst>(II) && !isa<DbgInfoIntrinsic>(II));