Skip to content

Commit 14a6958

Browse files
committed
[ctxprof] Override type of instrumentation if -profile-context-root is specified
1 parent f6703a4 commit 14a6958

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,10 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
12061206

12071207
// We already asserted this happens in non-FullLTOPostLink earlier.
12081208
const bool IsPreLink = Phase != ThinOrFullLTOPhase::ThinLTOPostLink;
1209-
const bool IsPGOPreLink = PGOOpt && IsPreLink;
1209+
// Enable contextual profiling instrumentation.
1210+
const bool IsCtxProfGen =
1211+
IsPreLink && PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled();
1212+
const bool IsPGOPreLink = !IsCtxProfGen && PGOOpt && IsPreLink;
12101213
const bool IsPGOInstrGen =
12111214
IsPGOPreLink && PGOOpt->Action == PGOOptions::IRInstr;
12121215
const bool IsPGOInstrUse =
@@ -1217,9 +1220,6 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
12171220
assert(!(IsPGOInstrGen && PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled()) &&
12181221
"Enabling both instrumented PGO and contextual instrumentation is not "
12191222
"supported.");
1220-
// Enable contextual profiling instrumentation.
1221-
const bool IsCtxProfGen = !IsPGOInstrGen && IsPreLink &&
1222-
PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled();
12231223
const bool IsCtxProfUse =
12241224
!UseCtxProfile.empty() && Phase == ThinOrFullLTOPhase::ThinLTOPreLink;
12251225

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; REQUIRES: linux
2+
;
3+
; RUN: opt -O2 -debug-pass-manager -S -pgo-kind=pgo-instr-gen-pipeline -profile-file='temp' \
4+
; RUN: < %s 2>&1 | FileCheck %s --check-prefixes=COMMON,PGO
5+
; RUN: opt -O2 -debug-pass-manager -S -pgo-kind=pgo-instr-gen-pipeline -profile-file='temp' \
6+
; RUN: -profile-context-root=something < %s 2>&1 | FileCheck %s --check-prefixes=COMMON,CTXPROF
7+
8+
; COMMON: Running pass: PGOInstrumentationGen
9+
; COMMON: Invalidating analysis: InnerAnalysisManagerProxy<FunctionAnalysisManager, Module>
10+
; COMMON: Invalidating analysis: LazyCallGraphAnalysis
11+
; COMMON: Invalidating analysis: InnerAnalysisManagerProxy<CGSCCAnalysisManager, Module>
12+
; CTXPROF: Running pass: AssignGUIDPass
13+
; CTXPROF: Running pass: NoinlineNonPrevailing
14+
; COMMON: Running analysis: InnerAnalysisManagerProxy<FunctionAnalysisManager, Module>
15+
; PGO: Running pass: InstrProfilingLoweringPass
16+
; CTXPROF: Running pass: PGOCtxProfLoweringPass

0 commit comments

Comments
 (0)