Skip to content

[ctxprof] Override type of instrumentation if -profile-context-root is specified #128940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions llvm/lib/Passes/PassBuilderPipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,10 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,

// We already asserted this happens in non-FullLTOPostLink earlier.
const bool IsPreLink = Phase != ThinOrFullLTOPhase::ThinLTOPostLink;
const bool IsPGOPreLink = PGOOpt && IsPreLink;
// Enable contextual profiling instrumentation.
const bool IsCtxProfGen =
IsPreLink && PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled();
const bool IsPGOPreLink = !IsCtxProfGen && PGOOpt && IsPreLink;
const bool IsPGOInstrGen =
IsPGOPreLink && PGOOpt->Action == PGOOptions::IRInstr;
const bool IsPGOInstrUse =
Expand All @@ -1217,9 +1220,6 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
assert(!(IsPGOInstrGen && PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled()) &&
"Enabling both instrumented PGO and contextual instrumentation is not "
"supported.");
// Enable contextual profiling instrumentation.
const bool IsCtxProfGen = !IsPGOInstrGen && IsPreLink &&
PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled();
const bool IsCtxProfUse =
!UseCtxProfile.empty() && Phase == ThinOrFullLTOPhase::ThinLTOPreLink;

Expand Down
16 changes: 16 additions & 0 deletions llvm/test/Transforms/PGOProfile/ctx-instrumentation-optin.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; REQUIRES: linux
;
; RUN: opt -O2 -debug-pass-manager -S -pgo-kind=pgo-instr-gen-pipeline -profile-file='temp' \
; RUN: < %s 2>&1 | FileCheck %s --check-prefixes=COMMON,PGO
; RUN: opt -O2 -debug-pass-manager -S -pgo-kind=pgo-instr-gen-pipeline -profile-file='temp' \
; RUN: -profile-context-root=something < %s 2>&1 | FileCheck %s --check-prefixes=COMMON,CTXPROF

; COMMON: Running pass: PGOInstrumentationGen
; COMMON: Invalidating analysis: InnerAnalysisManagerProxy<FunctionAnalysisManager, Module>
; COMMON: Invalidating analysis: LazyCallGraphAnalysis
; COMMON: Invalidating analysis: InnerAnalysisManagerProxy<CGSCCAnalysisManager, Module>
; CTXPROF: Running pass: AssignGUIDPass
; CTXPROF: Running pass: NoinlineNonPrevailing
; COMMON: Running analysis: InnerAnalysisManagerProxy<FunctionAnalysisManager, Module>
; PGO: Running pass: InstrProfilingLoweringPass
; CTXPROF: Running pass: PGOCtxProfLoweringPass