Skip to content

Commit

Permalink
Reland [InlineCost] Enable the cost benefit analysis for Sample PGO (#…
Browse files Browse the repository at this point in the history
…66457)

Enables the cost-benefit-analysis-based inliner by default if we have
sample profile.

No extra fix is required.
  • Loading branch information
HaohaiWen committed Sep 21, 2023
1 parent 7641c22 commit 954979d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit 954979d

Please sign in to comment.