[llvm] [nfc] Clarify when the various PGO instrumentation passes run (PR #92330)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 10:23:49 PDT 2024


================
@@ -1145,29 +1145,41 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(GlobalCleanupPM),
                                                 PTO.EagerlyInvalidateAnalyses));
 
-  // Invoke the pre-inliner passes for instrumentation PGO or MemProf.
-  if (PGOOpt && Phase != ThinOrFullLTOPhase::ThinLTOPostLink &&
-      (PGOOpt->Action == PGOOptions::IRInstr ||
-       PGOOpt->Action == PGOOptions::IRUse || !PGOOpt->MemoryProfile.empty()))
+  const bool IsPreLink = Phase != ThinOrFullLTOPhase::ThinLTOPostLink;
+  const bool IsPGOPreLink = PGOOpt && IsPreLink;
+  const bool IsPGOInstrGen =
+      IsPGOPreLink && PGOOpt->Action == PGOOptions::IRInstr;
+  const bool IsPGOInstrUse =
+      IsPGOPreLink && PGOOpt->Action == PGOOptions::IRUse;
+  const bool IsMemprof = 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 &&
----------------
teresajohnson wrote:

Can you split out the Ctx profiling stuff into a different PR as that makes this one non-NFC and is separate from the PR description?

https://github.com/llvm/llvm-project/pull/92330


More information about the llvm-commits mailing list