Skip to content

Commit 68811b9

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

File tree

2 files changed

+18
-4
lines changed

2 files changed

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

0 commit comments

Comments
 (0)