[llvm] [LLVM][MLGO] Fix: Index correctly into features to get default inlining decision (PR #141453)
via llvm-commits
llvm-commits at lists.llvm.org
Sun May 25 21:51:37 PDT 2025
https://github.com/Jellytabby created https://github.com/llvm/llvm-project/pull/141453
Currently, `InlineCostFeatureIndex::NumberOfFeatures` results in an index in the middle of the feature vector, therefore not correctly setting the default inlining decision and overwriting another feature. `FeatureIndex::NumberOfFeatures` is the last index of the feature vector, where the default inlining decision gets appended to when enabled.
>From 259f358f92e32253beb85b68cc3922c5b26ac728 Mon Sep 17 00:00:00 2001
From: Sophia Herrmann <sherrman at ethz.ch>
Date: Mon, 26 May 2025 13:14:18 +0900
Subject: [PATCH] [LLVM][MLGO] Fix: Index correctly into features to get
default inlining decision
---
llvm/lib/Analysis/MLInlineAdvisor.cpp | 2 +-
llvm/test/Transforms/Inline/ML/interactive-mode.ll | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Analysis/MLInlineAdvisor.cpp b/llvm/lib/Analysis/MLInlineAdvisor.cpp
index b6c784b965f79..81a3bc94a6ad8 100644
--- a/llvm/lib/Analysis/MLInlineAdvisor.cpp
+++ b/llvm/lib/Analysis/MLInlineAdvisor.cpp
@@ -441,7 +441,7 @@ std::unique_ptr<InlineAdvice> MLInlineAdvisor::getAdviceImpl(CallBase &CB) {
}
// This one would have been set up to be right at the end.
if (!InteractiveChannelBaseName.empty() && InteractiveIncludeDefault)
- *ModelRunner->getTensor<int64_t>(InlineCostFeatureIndex::NumberOfFeatures) =
+ *ModelRunner->getTensor<int64_t>(FeatureIndex::NumberOfFeatures) =
GetDefaultAdvice(CB);
return getAdviceFromModel(CB, ORE);
}
diff --git a/llvm/test/Transforms/Inline/ML/interactive-mode.ll b/llvm/test/Transforms/Inline/ML/interactive-mode.ll
index 00a64c6c34d07..0866d14c6ece7 100644
--- a/llvm/test/Transforms/Inline/ML/interactive-mode.ll
+++ b/llvm/test/Transforms/Inline/ML/interactive-mode.ll
@@ -23,6 +23,7 @@
; CHECK: unsimplified_common_instructions: 5
; CHECK: callee_users: 3
; CHECK-DEFAULT: inlining_default: 0
+; CHECK-DEFAULT: inlining_default: 1
; CHECK: observation: 5
; CHECK-NOT: observation: 6
More information about the llvm-commits
mailing list