diff --git a/llvm/lib/Transforms/Scalar/GCSE.cpp b/llvm/lib/Transforms/Scalar/GCSE.cpp index 8ed8238806d5..bbefe8157f4a 100644 --- a/llvm/lib/Transforms/Scalar/GCSE.cpp +++ b/llvm/lib/Transforms/Scalar/GCSE.cpp @@ -160,11 +160,14 @@ void GCSE::ReplaceInstructionWith(Instruction *I, Value *V) { ++NumCallRemoved; // Keep track of calls eliminated ++NumInstRemoved; // Keep track of number of insts eliminated + // Update value numbering + getAnalysis().deleteInstruction(I); + // If we are not replacing the instruction with a constant, we cannot do // anything special. if (!isa(V)) { I->replaceAllUsesWith(V); - + // Erase the instruction from the program. I->getParent()->getInstList().erase(I); return;