[llvm] r306495 - Inlining: Don't re-map simplified cloned instructions.
Kyle Butt via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 27 18:41:25 PDT 2017
Author: iteratee
Date: Tue Jun 27 18:41:25 2017
New Revision: 306495
URL: http://llvm.org/viewvc/llvm-project?rev=306495&view=rev
Log:
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
Modified:
llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=306495&r1=306494&r2=306495&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Tue Jun 27 18:41:25 2017
@@ -325,10 +325,11 @@ void PruningFunctionCloner::CloneBlock(c
// 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;
More information about the llvm-commits
mailing list