[llvm] [ctx_profile] Decouple ctx instrumentation from PGOOpt (PR #92445)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Thu May 16 12:25:16 PDT 2024
https://github.com/mtrofin created https://github.com/llvm/llvm-project/pull/92445
We currently don't support passing files and don't need frontend involvment either.
>From 1dbe45a50e7010e4907b05fac225063167c7912b Mon Sep 17 00:00:00 2001
From: Mircea Trofin <mtrofin at google.com>
Date: Wed, 15 May 2024 17:11:56 -0700
Subject: [PATCH] [ctx_profile] Decouple ctx instrumentation from PGOOpt
We currently don't support passing files and don't need frontend involvment either.
---
llvm/lib/Passes/PassBuilderPipelines.cpp | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 682bdefbd5243..dd1752d59e65a 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -839,10 +839,6 @@ void PassBuilder::addPGOInstrPasses(ModulePassManager &MPM,
MPM.addPass(PGOInstrumentationGen(IsCS));
addPostPGOLoopRotation(MPM, Level);
- if (PGOCtxProfLoweringPass::isContextualIRPGOEnabled()) {
- MPM.addPass(PGOCtxProfLoweringPass());
- return;
- }
// Add the profile lowering pass.
InstrProfOptions Options;
if (!ProfileFile.empty())
@@ -1157,8 +1153,12 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
const bool IsPGOInstrUse =
IsPGOPreLink && PGOOpt->Action == PGOOptions::IRUse;
const bool IsMemprofUse = IsPGOPreLink && !PGOOpt->MemoryProfile.empty();
+ // We don't want to mix pgo ctx gen and pgo gen; we also don't currently
+ // enable ctx profiling from the frontend.
+ const bool IsCtxProfGen = !IsPGOInstrGen && IsPreLink &&
+ PGOCtxProfLoweringPass::isContextualIRPGOEnabled();
- if (IsPGOInstrGen || IsPGOInstrUse || IsMemprofUse)
+ if (IsPGOInstrGen || IsPGOInstrUse || IsMemprofUse || IsCtxProfGen)
addPreInlinerPasses(MPM, Level, Phase);
// Add all the requested passes for instrumentation PGO, if requested.
@@ -1168,9 +1168,13 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
/*IsCS=*/false, PGOOpt->AtomicCounterUpdate,
PGOOpt->ProfileFile, PGOOpt->ProfileRemappingFile,
PGOOpt->FS);
+ } else if (IsCtxProfGen) {
+ MPM.addPass(PGOInstrumentationGen(false));
+ addPostPGOLoopRotation(MPM, Level);
+ MPM.addPass(PGOCtxProfLoweringPass());
}
- if (IsPGOInstrGen || IsPGOInstrUse)
+ if (IsPGOInstrGen || IsPGOInstrUse || IsCtxProfGen)
MPM.addPass(PGOIndirectCallPromotion(false, false));
if (IsPGOPreLink && PGOOpt->CSAction == PGOOptions::CSIRInstr)
More information about the llvm-commits
mailing list