[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

Lei Wang via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 1 15:11:06 PDT 2024


================
@@ -1784,6 +1784,12 @@ defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling",
   PosFlag<SetTrue, [], [ClangOption, CC1Option],
           "Emit extra debug info to make sample profile more accurate">,
   NegFlag<SetFalse>>;
+def fprofile_generate_cold_function_coverage : Flag<["-"], "fprofile-generate-cold-function-coverage">, 
----------------
wlei-llvm wrote:

Sorry if my PR description is not clear. Note that there is no use for  `-fprofile-generate` and  `-fprofile-instr-generate` here, so a driver flag here is to configure the instr file path and make linker to link the compiler.profile object files (just similar to `-fprofile-[instr]-generate=`).

The reason for not using `-fprofile-[instr]-generate` is because those flags conflict with `-fprofile-sample-use`, see [PGOOptions](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/PGOOptions.h#L27-L43), `ProfileFile` is a shared file path which means the two flags are actually mutually exclusive. 

Another option is to make `-fprofile-generate` compatible with `-fprofile-samle-use`(like refactoring PGOOptions or adding another flag to configure the file path things), this seems to me they are more complicated than the current one. But I’m open to any suggestions on this. 

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


More information about the cfe-commits mailing list