[flang-commits] [clang] [flang] [Flang][Driver]Add support for option '-fpseudo-probe-for-profiling' in flang (PR #205046)

Kaviya Rajendiran via flang-commits flang-commits at lists.llvm.org
Wed Jun 24 02:42:22 PDT 2026


================
@@ -995,7 +995,13 @@ void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) {
         opts.SampleProfileFile, "", opts.ProfileRemappingFile,
         opts.MemoryProfileUsePath, llvm::PGOOptions::SampleUse,
         llvm::PGOOptions::NoCSAction, llvm::PGOOptions::ColdFuncOpt::Default,
-        opts.DebugInfoForProfiling, /*PseudoProbeForProfiling=*/false);
+        opts.DebugInfoForProfiling, opts.PseudoProbeForProfiling);
+  } else if (opts.PseudoProbeForProfiling) {
----------------
kaviya2510 wrote:

My implementation order deviated from clang's implementation. In Clang, the order is:

1. hasProfileIRInstr() → -fprofile-generate
2. hasProfileIRUse() → -fprofile-use
3. !SampleProfileFile.empty() → -fprofile-sample-use
4. !MemoryProfileUsePath.empty() → -fmemory-profile-use
5. PseudoProbeForProfiling → -fpseudo-probe-for-profiling
6. DebugInfoForProfiling → -fdebug-info-for-profiling 

In clang, `DebugInfoForProfiling` is checked last as it coexist with other options. So when both the flags are specified `-fdebug-info-for-profiling -fpseudo-probe-for-profiling` , PseudoProbeForProfiling branch is taken and DebugInfoForProfiling also honoured via `opts.DebugInfoForProfiling`.

I modified the implementation similar to the ordering in Clang.

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


More information about the flang-commits mailing list