[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)
Lei Wang via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 2 14:30:31 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:
>Would -Wl,-lclang_rt.profile work?
Got it, I think it should work, except it requires another linker flag: the `--u__llvm_runtime_variable`, we can configure it to linker too, but basically [those instr PGO flags](https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChain.cpp#L885-L893) control [addProfileRTLibs](https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Linux.cpp#L841-L849) (which seems not equivalent to `-Wl,-lclang_rt.profile`), I just wanted to mirror those flags so that we don't need to maintain if anything changes to `addProfileRTLibs` in the future. (Though I feel this code should be very stable, should not be a big problem, so mainly for the convenience for compiler user to use one flag instead of using/maintaining multiple flags )
Overall, I agree that it's feasible to do it without clang flag. I'm not very familiar with the convention for adding driver flags, so if you think this doesn't justify it, I will drop it from this patch. Thanks for the discussion!
https://github.com/llvm/llvm-project/pull/109837
More information about the cfe-commits
mailing list