[llvm] 954979d - Reland [InlineCost] Enable the cost benefit analysis for Sample PGO (#66457)

Haohai Wen via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 21:45:06 PDT 2023


Author: HaohaiWen
Date: 2023-09-21T12:44:24+08:00
New Revision: 954979d681339c2f44e38e669d67b9183a5cf92d

URL: https://github.com/llvm/llvm-project/commit/954979d681339c2f44e38e669d67b9183a5cf92d
DIFF: https://github.com/llvm/llvm-project/commit/954979d681339c2f44e38e669d67b9183a5cf92d.diff

LOG: Reland [InlineCost] Enable the cost benefit analysis for Sample PGO (#66457)

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

No extra fix is required.

Added: 
    

Modified: 
    llvm/lib/Analysis/InlineCost.cpp
    llvm/test/Transforms/SampleProfile/remarks-hotness.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 71d35ad6cf3cacb..f5a31628f16502b 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -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;
     }
 

diff  --git a/llvm/test/Transforms/SampleProfile/remarks-hotness.ll b/llvm/test/Transforms/SampleProfile/remarks-hotness.ll
index 36fb3c58181703d..b90b21e9e3c5826 100644
--- a/llvm/test/Transforms/SampleProfile/remarks-hotness.ll
+++ b/llvm/test/Transforms/SampleProfile/remarks-hotness.ll
@@ -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
@@ -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'


        


More information about the llvm-commits mailing list