Index: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp =================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp @@ -325,10 +325,11 @@ // 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(V) || + cast(V)->getParent() == nullptr || + cast(V)->getFunction() != OldFunc || + OldFunc == NewFunc) && + "Simplified Instruction should not be in the old function."); if (!NewInst->mayHaveSideEffects()) { VMap[&*II] = V;