Skip to content

Commit fb14f1d

Browse files
authored
[PGO][Pipeline] Enable PGOForceFunctionAttrs in PGO optimization pipelines (#106790)
Remove flag that turns on the PGOForceFunctionAttrs pass and always add it to default pipelines when using PGO. This is NFC by default since PGOOpt->ColdOptType is by default ColdFuncOpt::Default. Remove -O2 RUN line in basic.ll since we now have the pipeline tests.
1 parent b91b1f0 commit fb14f1d

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

clang/test/CodeGen/pgo-force-function-attrs.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
; RUN: %clang_cc1 -O2 -mllvm -pgo-cold-func-opt=optsize -mllvm -enable-pgo-force-function-attrs -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -emit-llvm -o - | FileCheck %s --check-prefix=OPTSIZE
1+
; RUN: %clang_cc1 -O2 -mllvm -pgo-cold-func-opt=optsize -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -emit-llvm -o - | FileCheck %s --check-prefix=OPTSIZE
22
; Check that no profile means no optsize
3-
; RUN: %clang_cc1 -O2 -mllvm -pgo-cold-func-opt=optsize -mllvm -enable-pgo-force-function-attrs %s -emit-llvm -o - | FileCheck %s --check-prefix=NONE
3+
; RUN: %clang_cc1 -O2 -mllvm -pgo-cold-func-opt=optsize %s -emit-llvm -o - | FileCheck %s --check-prefix=NONE
44
; Check that no -pgo-cold-func-opt=optsize means no optsize
5-
; RUN: %clang_cc1 -O2 -mllvm -enable-pgo-force-function-attrs -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -emit-llvm -o - | FileCheck %s --check-prefix=NONE
5+
; RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -emit-llvm -o - | FileCheck %s --check-prefix=NONE
66

77
; NONE-NOT: optsize
88
; OPTSIZE: optsize

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,6 @@ static cl::opt<bool>
227227
cl::desc("Enable DFA jump threading"),
228228
cl::init(false), cl::Hidden);
229229

230-
// TODO: turn on and remove flag
231-
static cl::opt<bool> EnablePGOForceFunctionAttrs(
232-
"enable-pgo-force-function-attrs",
233-
cl::desc("Enable pass to set function attributes based on PGO profiles"),
234-
cl::init(false));
235-
236230
static cl::opt<bool>
237231
EnableHotColdSplit("hot-cold-split",
238232
cl::desc("Enable hot-cold splitting pass"));
@@ -1222,7 +1216,8 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
12221216
if (EnableSyntheticCounts && !PGOOpt)
12231217
MPM.addPass(SyntheticCountsPropagation());
12241218

1225-
if (EnablePGOForceFunctionAttrs && PGOOpt)
1219+
if (PGOOpt && (PGOOpt->Action == PGOOptions::IRUse ||
1220+
PGOOpt->Action == PGOOptions::SampleUse))
12261221
MPM.addPass(PGOForceFunctionAttrsPass(PGOOpt->ColdOptType));
12271222

12281223
MPM.addPass(AlwaysInlinerPass(/*InsertLifetimeIntrinsics=*/true));

llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
; Should be no changes without profile data
77
; RUN: opt < %s -passes=pgo-force-function-attrs -S -pgo-cold-func-opt=minsize | FileCheck %s --check-prefixes=NONE,CHECK
8-
; RUN: opt < %s -passes='default<O2>' -enable-pgo-force-function-attrs -S -pgo-cold-func-opt=minsize | FileCheck %s --check-prefixes=O2
98

109
; NONE-NOT: Function Attrs:
1110
; OPTSIZE: Function Attrs: optsize{{$}}

llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
; CHECK-O-NEXT: Running analysis: PostDominatorTreeAnalysis on foo
6060
; CHECK-O-NEXT: Running pass: SimplifyCFGPass on foo
6161

62+
; CHECK-O-NEXT: Running pass: PGOForceFunctionAttrsPass
6263
; CHECK-O-NEXT: Running pass: AlwaysInlinerPass
6364
; CHECK-O-NEXT: Running pass: ModuleInlinerWrapperPass
6465
; CHECK-O-NEXT: Running analysis: InlineAdvisorAnalysis

llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
; CHECK-O-NEXT: Running pass: PGOIndirectCallPromotion on
8585
; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
8686
; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis on foo
87+
; CHECK-O-NEXT: Running pass: PGOForceFunctionAttrsPass
8788
; CHECK-O-NEXT: Running pass: AlwaysInlinerPass
8889
; CHECK-O-NEXT: Running pass: ModuleInlinerWrapperPass
8990
; CHECK-O-NEXT: Running analysis: InlineAdvisorAnalysis

llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
; CHECK-O-NEXT: Running analysis: LoopAnalysis on foo
6565
; CHECK-O-NEXT: Running analysis: PostDominatorTreeAnalysis on foo
6666
; CHECK-O-NEXT: Running pass: SimplifyCFGPass on foo
67+
; CHECK-O-NEXT: Running pass: PGOForceFunctionAttrsPass
6768
; CHECK-O-NEXT: Running pass: AlwaysInlinerPass
6869
; CHECK-O-NEXT: Running pass: ModuleInlinerWrapperPass
6970
; CHECK-O-NEXT: Running analysis: InlineAdvisorAnalysis

0 commit comments

Comments
 (0)