Skip to content

[InlineCost] Enable the cost benefit analysis for Sample PGO #66457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/InlineCost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
return false;
} else {
// Otherwise, require instrumentation profile.
if (!PSI->hasInstrumentationProfile())
if (!(PSI->hasInstrumentationProfile() || PSI->hasSampleProfile()))
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/SampleProfile/remarks-hotness.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

; YAML-PASS: --- !Passed
; YAML-PASS-NEXT: Pass: inline
; YAML-PASS-NEXT: Name: Inlined
; YAML-PASS-NEXT: Name: AlwaysInline
; YAML-PASS-NEXT: DebugLoc: { File: remarks-hotness.cpp, Line: 10, Column: 10 }
; YAML-PASS-NEXT: Function: _Z7caller1v
; YAML-PASS-NEXT: Hotness: 401
Expand All @@ -36,7 +36,7 @@
; YAML-MISS-NEXT: Function: _Z7caller2v
; YAML-MISS-NEXT: Hotness: 2

; CHECK-RPASS: '_Z7callee1v' inlined into '_Z7caller1v' with (cost=-30, threshold=4500) at callsite _Z7caller1v:1:10; (hotness: 401)
; CHECK-RPASS: '_Z7callee1v' inlined into '_Z7caller1v' with (cost=always): benefit over cost at callsite _Z7caller1v:1:10; (hotness: 401)
; CHECK-RPASS-NOT: '_Z7callee2v' not inlined into '_Z7caller2v' because it should never be inlined (cost=never): noinline function attribute (hotness: 2)

; ModuleID = 'remarks-hotness.cpp'
Expand Down