[llvm] [ML Inliner] Fix inconsistancy between CallGraph and FunctionLevels (PR #122830)
Peter Rong via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 16:46:07 PST 2025
https://github.com/DataCorrupted updated https://github.com/llvm/llvm-project/pull/122830
>From 7355c600342f04cb33e7a2730edcbcebfc8447e8 Mon Sep 17 00:00:00 2001
From: Peter Rong <PeterRong at meta.com>
Date: Mon, 13 Jan 2025 16:26:43 -0800
Subject: [PATCH 1/2] [ML Inliner] Fix inconsistancy between CallGraph and
FunctionLevels
When building our internal code, one of the function annotated with `co_await` (c++20) will cause inconsistancy:
The function exists in CG but not FunctionLevels.
This patch fixes it by using FunctionLevels only.
Signed-off-by: Peter Rong <PeterRong at meta.com>
---
llvm/lib/Analysis/MLInlineAdvisor.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Analysis/MLInlineAdvisor.cpp b/llvm/lib/Analysis/MLInlineAdvisor.cpp
index 2db58d1c2578bf..68d8f794d23897 100644
--- a/llvm/lib/Analysis/MLInlineAdvisor.cpp
+++ b/llvm/lib/Analysis/MLInlineAdvisor.cpp
@@ -189,7 +189,9 @@ MLInlineAdvisor::MLInlineAdvisor(
}
unsigned MLInlineAdvisor::getInitialFunctionLevel(const Function &F) const {
- return CG.lookup(F) ? FunctionLevels.at(CG.lookup(F)) : 0;
+ return FunctionLevels.find(CG.lookup(F)) != FunctionLevels.end()
+ ? FunctionLevels.at(CG.lookup(F))
+ : 0;
}
void MLInlineAdvisor::onPassEntry(LazyCallGraph::SCC *CurSCC) {
>From c668980be21052992aa3936c60d4c025f7f54c42 Mon Sep 17 00:00:00 2001
From: Peter Rong <peterrong96 at gmail.com>
Date: Mon, 13 Jan 2025 16:45:59 -0800
Subject: [PATCH 2/2] Update llvm/lib/Analysis/MLInlineAdvisor.cpp
Co-authored-by: Ellis Hoag <ellis.sparky.hoag at gmail.com>
---
llvm/lib/Analysis/MLInlineAdvisor.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Analysis/MLInlineAdvisor.cpp b/llvm/lib/Analysis/MLInlineAdvisor.cpp
index 68d8f794d23897..d41631c2782f0d 100644
--- a/llvm/lib/Analysis/MLInlineAdvisor.cpp
+++ b/llvm/lib/Analysis/MLInlineAdvisor.cpp
@@ -189,9 +189,10 @@ MLInlineAdvisor::MLInlineAdvisor(
}
unsigned MLInlineAdvisor::getInitialFunctionLevel(const Function &F) const {
- return FunctionLevels.find(CG.lookup(F)) != FunctionLevels.end()
- ? FunctionLevels.at(CG.lookup(F))
- : 0;
+ auto It = FunctionLevels.find(CG.lookup(F));
+ if (It == FunctionLevels.end())
+ return 0;
+ return *It;
}
void MLInlineAdvisor::onPassEntry(LazyCallGraph::SCC *CurSCC) {
More information about the llvm-commits
mailing list