[llvm] 7a316c0 - [CSSPGO] Turn on profi and ext-tsp when using probe-based profile.

Hongtao Yu via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 25 09:09:31 PDT 2022


Author: Hongtao Yu
Date: 2022-03-25T09:09:21-07:00
New Revision: 7a316c0a1f116b50fc88c26fc776c8861c92c885

URL: https://github.com/llvm/llvm-project/commit/7a316c0a1f116b50fc88c26fc776c8861c92c885
DIFF: https://github.com/llvm/llvm-project/commit/7a316c0a1f116b50fc88c26fc776c8861c92c885.diff

LOG: [CSSPGO] Turn on profi and ext-tsp when using probe-based profile.

Probe-based profile leads to a better performance when combined with profi and ext-tsp block layout. I'm turning them on by default.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D122442

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/SampleProfile.cpp
    llvm/test/Transforms/SampleProfile/function_metadata.ll
    llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll
    llvm/test/Transforms/SampleProfile/pseudo-probe-profile-metadata.ll
    llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 709f5f81a7385..82324069933e8 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -2001,7 +2001,17 @@ bool SampleProfileLoader::doInitialization(Module &M,
         /*EmitRemarks=*/false);
   }
 
-  // Apply tweaks if context-sensitive profile is available.
+  // Apply tweaks if context-sensitive or probe-based profile is available.
+  if (Reader->profileIsCSFlat() || Reader->profileIsCSNested() ||
+      Reader->profileIsProbeBased()) {
+    if (!UseIterativeBFIInference.getNumOccurrences())
+      UseIterativeBFIInference = true;
+    if (!SampleProfileUseProfi.getNumOccurrences())
+      SampleProfileUseProfi = true;
+    if (!EnableExtTspBlockPlacement.getNumOccurrences())
+      EnableExtTspBlockPlacement = true;
+  }
+
   if (Reader->profileIsCSFlat() || Reader->profileIsCSNested()) {
     ProfileIsCSFlat = Reader->profileIsCSFlat();
     // Enable priority-base inliner and size inline by default for CSSPGO.
@@ -2018,17 +2028,6 @@ bool SampleProfileLoader::doInitialization(Module &M,
     if (!AllowRecursiveInline.getNumOccurrences())
       AllowRecursiveInline = true;
 
-    // Enable iterative-BFI by default for CSSPGO.
-    if (!UseIterativeBFIInference.getNumOccurrences())
-      UseIterativeBFIInference = true;
-    // Enable Profi by default for CSSPGO.
-    if (!SampleProfileUseProfi.getNumOccurrences())
-      SampleProfileUseProfi = true;
-
-    // Enable EXT-TSP block layout for CSSPGO.
-    if (!EnableExtTspBlockPlacement.getNumOccurrences())
-      EnableExtTspBlockPlacement = true;
-
     if (FunctionSamples::ProfileIsCSFlat) {
       // Tracker for profiles under 
diff erent context
       ContextTracker = std::make_unique<SampleContextTracker>(

diff  --git a/llvm/test/Transforms/SampleProfile/function_metadata.ll b/llvm/test/Transforms/SampleProfile/function_metadata.ll
index 9ff1e5a9bc884..12274d90c3d35 100644
--- a/llvm/test/Transforms/SampleProfile/function_metadata.ll
+++ b/llvm/test/Transforms/SampleProfile/function_metadata.ll
@@ -1,6 +1,6 @@
 ; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/function_metadata.prof -S | FileCheck %s
 ; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/function_metadata.compact.afdo -S | FileCheck %s
-; RUN: opt < %s -passes='pseudo-probe,thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/pseudo-probe-func-metadata.prof -S | FileCheck %s
+; RUN: opt < %s -passes='pseudo-probe,thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/pseudo-probe-func-metadata.prof -sample-profile-use-profi=0 -S | FileCheck %s
 
 ;; Validate that with replay in effect, we import call sites even if they are below the threshold
 ;; Baseline import decisions

diff  --git a/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll b/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll
index 6f40a2b69170f..700017ae8981a 100644
--- a/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll
+++ b/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profile-correlation-irreducible-loops.prof | opt -passes='print<block-freq>' -disable-output  -use-iterative-bfi-inference 2>&1 | FileCheck %s
-; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profile-correlation-irreducible-loops.prof -S | FileCheck %s --check-prefix=CHECK2
+; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profile-correlation-irreducible-loops.prof -sample-profile-use-profi=0 | opt -passes='print<block-freq>' -disable-output  -use-iterative-bfi-inference 2>&1 | FileCheck %s
+; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profile-correlation-irreducible-loops.prof -sample-profile-use-profi=0 -S | FileCheck %s --check-prefix=CHECK2
 ; RUN: opt < %s -passes='print<block-freq>' -use-iterative-bfi-inference -disable-output 2>&1 | FileCheck %s --check-prefix=CHECK3
 
 ; The C++ code for this test case is from c-parse.c in 403.gcc (SPEC2006)

diff  --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-metadata.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-metadata.ll
index 47c874d610bbe..b8c9c2c65d5cd 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-metadata.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile-metadata.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-metadata.prof -S | FileCheck %s
+; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-metadata.prof -sample-profile-use-profi=0 -S | FileCheck %s
 
 ; The test verifies the presence of prof metadata for BranchInst, SwitchInst,
 ; and IndirectBrInst

diff  --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
index 34629a3743ebd..d9de3716e3907 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile.prof -pass-remarks=sample-profile -pass-remarks-output=%t.opt.yaml -S | FileCheck %s
+; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile.prof -pass-remarks=sample-profile -pass-remarks-output=%t.opt.yaml -sample-profile-use-profi=0 -S | FileCheck %s
 ; RUN: FileCheck %s -check-prefix=YAML < %t.opt.yaml
 
 define dso_local i32 @foo(i32 %x, void (i32)* %f) #0 !dbg !4 {


        


More information about the llvm-commits mailing list