Skip to content

Commit 18fced4

Browse files
authored
[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.
1 parent 9c59946 commit 18fced4

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

llvm/lib/Analysis/MLInlineAdvisor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ std::unique_ptr<InlineAdvice> MLInlineAdvisor::getAdviceImpl(CallBase &CB) {
441441
}
442442
// This one would have been set up to be right at the end.
443443
if (!InteractiveChannelBaseName.empty() && InteractiveIncludeDefault)
444-
*ModelRunner->getTensor<int64_t>(InlineCostFeatureIndex::NumberOfFeatures) =
444+
*ModelRunner->getTensor<int64_t>(FeatureIndex::NumberOfFeatures) =
445445
GetDefaultAdvice(CB);
446446
return getAdviceFromModel(CB, ORE);
447447
}

llvm/test/Transforms/Inline/ML/interactive-mode.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
; CHECK: unsimplified_common_instructions: 5
2424
; CHECK: callee_users: 3
2525
; CHECK-DEFAULT: inlining_default: 0
26+
; CHECK-DEFAULT: inlining_default: 1
2627
; CHECK: observation: 5
2728
; CHECK-NOT: observation: 6
2829

0 commit comments

Comments
 (0)