[llvm] [MLInliner] Keep track of deleted functions (PR #97348)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 14:07:02 PDT 2024
https://github.com/aeubanks created https://github.com/llvm/llvm-project/pull/97348
As opposed to using Node::isDead(), which is no longer accurate after #94815.
This is only used in diagnostics.
>From c6741aa04182043e2ba10222b9eb04fa48edbbc3 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Mon, 1 Jul 2024 21:01:52 +0000
Subject: [PATCH] [MLInliner] Keep track of deleted functions
As opposed to using Node::isDead(), which is no longer accurate after #94815.
This is only used in diagnostics.
---
llvm/include/llvm/Analysis/MLInlineAdvisor.h | 1 +
llvm/lib/Analysis/MLInlineAdvisor.cpp | 10 +++++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm/Analysis/MLInlineAdvisor.h b/llvm/include/llvm/Analysis/MLInlineAdvisor.h
index 2aa077fe0e035..0333f457c1a2d 100644
--- a/llvm/include/llvm/Analysis/MLInlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/MLInlineAdvisor.h
@@ -89,6 +89,7 @@ class MLInlineAdvisor : public InlineAdvisor {
int32_t CurrentIRSize = 0;
llvm::SmallPtrSet<const LazyCallGraph::Node *, 1> NodesInLastSCC;
DenseSet<const LazyCallGraph::Node *> AllNodes;
+ DenseSet<Function *> DeadFunctions;
bool ForceStop = false;
ProfileSummaryInfo &PSI;
};
diff --git a/llvm/lib/Analysis/MLInlineAdvisor.cpp b/llvm/lib/Analysis/MLInlineAdvisor.cpp
index 652f0d994b29c..8131acb3f0df3 100644
--- a/llvm/lib/Analysis/MLInlineAdvisor.cpp
+++ b/llvm/lib/Analysis/MLInlineAdvisor.cpp
@@ -311,11 +311,13 @@ void MLInlineAdvisor::onSuccessfulInlining(const MLInlineAdvice &Advice,
int64_t NewCallerAndCalleeEdges =
getCachedFPI(*Caller).DirectCallsToDefinedFunctions;
- if (CalleeWasDeleted)
+ if (CalleeWasDeleted) {
--NodeCount;
- else
+ DeadFunctions.insert(Callee);
+ } else {
NewCallerAndCalleeEdges +=
getCachedFPI(*Callee).DirectCallsToDefinedFunctions;
+ }
EdgeCount += (NewCallerAndCalleeEdges - Advice.CallerAndCalleeEdges);
assert(CurrentIRSize >= 0 && EdgeCount >= 0 && NodeCount >= 0);
}
@@ -493,7 +495,9 @@ void MLInlineAdvisor::print(raw_ostream &OS) const {
OS << "\n";
OS << "[MLInlineAdvisor] FuncLevels:\n";
for (auto I : FunctionLevels)
- OS << (I.first->isDead() ? "<deleted>" : I.first->getFunction().getName())
+ OS << (DeadFunctions.contains(&I.first->getFunction())
+ ? "<deleted>"
+ : I.first->getFunction().getName())
<< " : " << I.second << "\n";
OS << "\n";
More information about the llvm-commits
mailing list