forked from OSchip/llvm-project
[CallGraphUpdater] Remove dead constants before replacing a function
Dead constants might be left when a function is replaced, we can gracefully handle this case and avoid complexity for the users who would see an assertion otherwise.
This commit is contained in:
parent
5877d6f5f4
commit
cb0ecc5c33
|
@ -106,6 +106,7 @@ void CallGraphUpdater::removeFunction(Function &DeadFn) {
|
|||
}
|
||||
|
||||
void CallGraphUpdater::replaceFunctionWith(Function &OldFn, Function &NewFn) {
|
||||
OldFn.removeDeadConstantUsers();
|
||||
ReplacedFunctions.insert(&OldFn);
|
||||
if (CG) {
|
||||
// Update the call graph for the newly promoted function.
|
||||
|
|
|
@ -1608,6 +1608,10 @@ TEST_F(CGSCCPassManagerTest, TestUpdateCGAndAnalysisManagerForPasses8) {
|
|||
FnF->getEntryBlock().front().moveBefore(RI);
|
||||
ASSERT_NE(FnF, nullptr);
|
||||
|
||||
// Create an unsused constant that is referencing the old (=replaced)
|
||||
// function.
|
||||
ConstantExpr::getBitCast(FnF, Type::getInt8PtrTy(FnF->getContext()));
|
||||
|
||||
// Use the CallGraphUpdater to update the call graph.
|
||||
CallGraphUpdater CGU;
|
||||
CGU.initialize(CG, C, AM, UR);
|
||||
|
|
Loading…
Reference in New Issue