[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)
Ellis Hoag via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 1 16:13:01 PDT 2024
================
@@ -649,6 +649,24 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
}
}
+ if (auto *ColdFuncCoverageArg = Args.getLastArg(
+ options::OPT_fprofile_generate_cold_function_coverage,
+ options::OPT_fprofile_generate_cold_function_coverage_EQ)) {
+ SmallString<128> Path(
+ ColdFuncCoverageArg->getOption().matches(
+ options::OPT_fprofile_generate_cold_function_coverage_EQ)
+ ? ColdFuncCoverageArg->getValue()
+ : "");
+ llvm::sys::path::append(Path, "default_%m.profraw");
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back(Args.MakeArgString(
+ Twine("--instrument-sample-cold-function-path=") + Path));
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("--instrument-cold-function-coverage");
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("--pgo-function-entry-coverage");
----------------
ellishg wrote:
You probably want to add a driver test case for this change like
https://github.com/llvm/llvm-project/blob/2f4327294dccc27fc9d5febe71196f6f854d66ff/clang/test/Driver/fcs-profile-generate.c#L1-L4
https://github.com/llvm/llvm-project/pull/109837
More information about the cfe-commits
mailing list