[llvm] [ctx_prof] Relax the "profile use" case around `PGOOpt` (PR #108265)

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 11 11:15:58 PDT 2024


https://github.com/mtrofin created https://github.com/llvm/llvm-project/pull/108265

`PGOOpt` could have a value if, for instance, debug info for profiling is requested. Relaxing the requirement, for now, following that eventually we would factor `PGOOpt` to better capture the supported interplay between the various profiling options.

>From 9e3eead2aaec563a370cf4a34ffa24df28a1735d Mon Sep 17 00:00:00 2001
From: Mircea Trofin <mtrofin at google.com>
Date: Wed, 11 Sep 2024 11:13:22 -0700
Subject: [PATCH] [ctx_prof] Relax the "profile use" case around `PGOOpt`

`PGOOpt` could have a value if, for instance, debug info for profiling is
requested. Relaxing the requirement, for now, following that eventually
we would factor `PGOOpt` to better capture the supported interplay
between the various profiling options.
---
 llvm/lib/Passes/PassBuilderPipelines.cpp                | 6 +++---
 llvm/test/Transforms/PGOProfile/ctx-prof-use-prelink.ll | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 6ebf262379c2fb..8f151a99b11709 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1181,8 +1181,8 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
   // Enable contextual profiling instrumentation.
   const bool IsCtxProfGen = !IsPGOInstrGen && IsPreLink &&
                             PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled();
-  const bool IsCtxProfUse = !UseCtxProfile.empty() && !PGOOpt &&
-                            Phase == ThinOrFullLTOPhase::ThinLTOPreLink;
+  const bool IsCtxProfUse =
+      !UseCtxProfile.empty() && Phase == ThinOrFullLTOPhase::ThinLTOPreLink;
 
   if (IsPGOInstrGen || IsPGOInstrUse || IsMemprofUse || IsCtxProfGen ||
       IsCtxProfUse)
@@ -1673,7 +1673,7 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
   // In pre-link, for ctx prof use, we stop here with an instrumented IR. We let
   // thinlto use the contextual info to perform imports; then use the contextual
   // profile in the post-thinlink phase.
-  if (!UseCtxProfile.empty() && !PGOOpt) {
+  if (!UseCtxProfile.empty()) {
     addRequiredLTOPreLinkPasses(MPM);
     return MPM;
   }
diff --git a/llvm/test/Transforms/PGOProfile/ctx-prof-use-prelink.ll b/llvm/test/Transforms/PGOProfile/ctx-prof-use-prelink.ll
index 7959e4d0760edb..56ed92ea1b7ffb 100644
--- a/llvm/test/Transforms/PGOProfile/ctx-prof-use-prelink.ll
+++ b/llvm/test/Transforms/PGOProfile/ctx-prof-use-prelink.ll
@@ -4,6 +4,7 @@
 ; There is no scenario currently of doing ctx profile use without thinlto.
 ;
 ; RUN: opt -passes='thinlto-pre-link<O2>' -use-ctx-profile=something_that_does_not_exist %s -S | FileCheck %s
+; RUN: opt -debug-info-for-profiling -passes='thinlto-pre-link<O2>' -use-ctx-profile=something_that_does_not_exist %s -S | FileCheck %s
 
 declare void @bar()
 



More information about the llvm-commits mailing list