diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -2001,7 +2001,17 @@ /*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 @@ 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 different context ContextTracker = std::make_unique( diff --git a/llvm/test/Transforms/SampleProfile/function_metadata.ll b/llvm/test/Transforms/SampleProfile/function_metadata.ll --- 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' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/function_metadata.prof -S | FileCheck %s ; RUN: opt < %s -passes='thinlto-pre-link' -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' -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' -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 --- 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' -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' -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' -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 --- 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 --- 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 {