[llvm] 18fced4 - [LLVM][MLGO] Fix: Index correctly into features to get default inlining decision (#141453)
via llvm-commits
llvm-commits at lists.llvm.org
Sun May 25 22:57:06 PDT 2025
Author: Jellytabby
Date: 2025-05-26T14:57:04+09:00
New Revision: 18fced40d5c68afdd2bf64552015ad257fe679ef
URL: https://github.com/llvm/llvm-project/commit/18fced40d5c68afdd2bf64552015ad257fe679ef
DIFF: https://github.com/llvm/llvm-project/commit/18fced40d5c68afdd2bf64552015ad257fe679ef.diff
LOG: [LLVM][MLGO] Fix: Index correctly into features to get default inlining decision (#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.
Added:
Modified:
llvm/lib/Analysis/MLInlineAdvisor.cpp
llvm/test/Transforms/Inline/ML/interactive-mode.ll
Removed:
################################################################################
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