summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorKyle Butt <kyle+llvm@iteratee.net>2017-06-28 01:41:25 +0000
committerKyle Butt <kyle+llvm@iteratee.net>2017-06-28 01:41:25 +0000
commitf73c8a06a97748030b36d394db3cee2560968348 (patch)
tree0a1159be1e16319fd0e4ffe53f147e738c2f5ff0 /llvm/lib
parent46dd7dbc8cbd87ce09acf118f7ea14b8986e5e6a (diff)
downloadbcm5719-llvm-f73c8a06a97748030b36d394db3cee2560968348.tar.gz
bcm5719-llvm-f73c8a06a97748030b36d394db3cee2560968348.zip
Inlining: Don't re-map simplified cloned instructions.
When simplifying an instruction that has been re-mapped, it should never simplify to an instruction in the original function. In the edge case where we are inlining a function into itself, the existing code led to incorrect behavior. Replace the incorrect code with an assert verifying that we never expect simplification to produce an instruction in the old function, unless the functions are the same. Differential Revision: https://reviews.llvm.org/D33850 llvm-svn: 306495
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 314c990293c..b61017f37ca 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -325,10 +325,11 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
// the basic block.
if (Value *V =
SimplifyInstruction(NewInst, BB->getModule()->getDataLayout())) {
- // On the off-chance that this simplifies to an instruction in the old
- // function, map it back into the new function.
- if (Value *MappedV = VMap.lookup(V))
- V = MappedV;
+ assert((!isa<Instruction>(V) ||
+ cast<Instruction>(V)->getParent() == nullptr ||
+ cast<Instruction>(V)->getFunction() != OldFunc ||
+ OldFunc == NewFunc) &&
+ "Simplified Instruction should not be in the old function.");
if (!NewInst->mayHaveSideEffects()) {
VMap[&*II] = V;
OpenPOWER on IntegriCloud