https://github.com/fzakaria created 
https://github.com/llvm/llvm-project/pull/199058

We build Clang with PGO at the moment but I want to transition us to CSSPGO.
In order to do so, I need add the pseudo probe instrumentation. Unfortunately, 
I can't seem to generate a profile and apply pseudo problems -- it looked to 
have been explicitly disabled.

The IRInstr branch in BackendUtil.cpp hardcodes PseudoProbeForProfiling to 
false, silently suppressing pseudo probe emission when -fprofile-generate and 
-fpseudo-probe-for-profiling are both passed. Forward the CodeGenOpts value 
instead so pseudo probes can coexist with instrumentation PGO.

I added it also to the `-fprofile-use` case as well, so that the code layout 
for PGO itself should match and there would be no profile statleness.

>From 6aa59826d1c8d0fb6189eebb016fbed4e0eda242 Mon Sep 17 00:00:00 2001
From: Farid Zakaria <[email protected]>
Date: Thu, 21 May 2026 08:23:04 -0700
Subject: [PATCH] [clang][CodeGen] Forward PseudoProbeForProfiling in IRInstr
 PGOOptions

The IRInstr branch in BackendUtil.cpp hardcodes PseudoProbeForProfiling to 
false, silently suppressing pseudo probe emission when -fprofile-generate and 
-fpseudo-probe-for-profiling are both passed. Forward the CodeGenOpts value 
instead so pseudo probes can coexist with instrumentation PGO.
---
 clang/lib/CodeGen/BackendUtil.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index a46a25c4492f2..60635cab9ae98 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -837,7 +837,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
                         CodeGenOpts.MemoryProfileUsePath, PGOOptions::IRInstr,
                         PGOOptions::NoCSAction, ClPGOColdFuncAttr,
                         CodeGenOpts.DebugInfoForProfiling,
-                        /*PseudoProbeForProfiling=*/false,
+                        CodeGenOpts.PseudoProbeForProfiling,
                         CodeGenOpts.AtomicProfileUpdate);
   else if (CodeGenOpts.hasProfileIRUse()) {
     // -fprofile-use.
@@ -847,7 +847,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
                         CodeGenOpts.ProfileRemappingFile,
                         CodeGenOpts.MemoryProfileUsePath, PGOOptions::IRUse,
                         CSAction, ClPGOColdFuncAttr,
-                        CodeGenOpts.DebugInfoForProfiling);
+                        CodeGenOpts.DebugInfoForProfiling,
+                        CodeGenOpts.PseudoProbeForProfiling);
   } else if (!CodeGenOpts.SampleProfileFile.empty())
     // -fprofile-sample-use
     PGOOpt = PGOOptions(

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to