Skip to content

Commit ebdb6f4

Browse files
authored
[MLInliner] Keep track of deleted functions (#97348)
As opposed to using Node::isDead(), which is no longer accurate after #94815. This is only used in diagnostics.
1 parent 5e564d9 commit ebdb6f4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

llvm/include/llvm/Analysis/MLInlineAdvisor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class MLInlineAdvisor : public InlineAdvisor {
8989
int32_t CurrentIRSize = 0;
9090
llvm::SmallPtrSet<const LazyCallGraph::Node *, 1> NodesInLastSCC;
9191
DenseSet<const LazyCallGraph::Node *> AllNodes;
92+
DenseSet<Function *> DeadFunctions;
9293
bool ForceStop = false;
9394
ProfileSummaryInfo &PSI;
9495
};

llvm/lib/Analysis/MLInlineAdvisor.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,13 @@ void MLInlineAdvisor::onSuccessfulInlining(const MLInlineAdvice &Advice,
311311
int64_t NewCallerAndCalleeEdges =
312312
getCachedFPI(*Caller).DirectCallsToDefinedFunctions;
313313

314-
if (CalleeWasDeleted)
314+
if (CalleeWasDeleted) {
315315
--NodeCount;
316-
else
316+
DeadFunctions.insert(Callee);
317+
} else {
317318
NewCallerAndCalleeEdges +=
318319
getCachedFPI(*Callee).DirectCallsToDefinedFunctions;
320+
}
319321
EdgeCount += (NewCallerAndCalleeEdges - Advice.CallerAndCalleeEdges);
320322
assert(CurrentIRSize >= 0 && EdgeCount >= 0 && NodeCount >= 0);
321323
}
@@ -493,7 +495,9 @@ void MLInlineAdvisor::print(raw_ostream &OS) const {
493495
OS << "\n";
494496
OS << "[MLInlineAdvisor] FuncLevels:\n";
495497
for (auto I : FunctionLevels)
496-
OS << (I.first->isDead() ? "<deleted>" : I.first->getFunction().getName())
498+
OS << (DeadFunctions.contains(&I.first->getFunction())
499+
? "<deleted>"
500+
: I.first->getFunction().getName())
497501
<< " : " << I.second << "\n";
498502

499503
OS << "\n";

0 commit comments

Comments
 (0)