diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -1829,6 +1829,7 @@ // Replace the function in the call graph (if any). CGUpdater.replaceFunctionWith(*OldFn, *NewFn); + CGUpdater.removeFunction(*OldFn); // If the old function was modified and needed to be reanalyzed, the new one // does now. diff --git a/llvm/lib/Transforms/Utils/CallGraphUpdater.cpp b/llvm/lib/Transforms/Utils/CallGraphUpdater.cpp --- a/llvm/lib/Transforms/Utils/CallGraphUpdater.cpp +++ b/llvm/lib/Transforms/Utils/CallGraphUpdater.cpp @@ -134,7 +134,6 @@ LazyCallGraph::Node &OldLCGN = LCG->get(OldFn); SCC->getOuterRefSCC().replaceNodeFunction(OldLCGN, NewFn); } - removeFunction(OldFn); } bool CallGraphUpdater::replaceCallSite(CallBase &OldCS, CallBase &NewCS) { diff --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp --- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp +++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp @@ -1640,7 +1640,7 @@ CallGraphUpdater CGU; CGU.initialize(CG, C, AM, UR); ASSERT_NO_FATAL_FAILURE(CGU.replaceFunctionWith(*FnF, *FnewF)); - ASSERT_TRUE(FnF->isDeclaration()); + ASSERT_FALSE(FnF->isDeclaration()); ASSERT_EQ(FnF->getNumUses(), 0U); }));