[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:52:32 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Jellytabby (Jellytabby)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/141453.diff
2 Files Affected:
- (modified) llvm/lib/Analysis/MLInlineAdvisor.cpp (+1-1)
- (modified) llvm/test/Transforms/Inline/ML/interactive-mode.ll (+1)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/141453
More information about the llvm-commits
mailing list