[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 29 21:14:48 PST 2025
================
@@ -785,6 +786,34 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
D.Diag(diag::err_drv_unsupported_option_argument)
<< A->getSpelling() << Val;
}
+ if (const auto *A = Args.getLastArg(options::OPT_fprofile_continuous)) {
+ if (!PGOGenerateArg && !CSPGOGenerateArg && !ProfileGenerateArg)
+ D.Diag(clang::diag::err_drv_argument_only_allowed_with)
+ << A->getSpelling()
+ << "-fprofile-generate, -fprofile-instr-generate, or "
+ "-fcs-profile-generate";
+ else {
+ CmdArgs.push_back("-fprofile-continuous");
+ // Platforms that require a bias variable:
+ if (T.isOSFuchsia() || T.isOSBinFormatELF() || T.isOSAIX()) {
+ CmdArgs.push_back("-mllvm");
----------------
MaskRay wrote:
I vaguely remember that continuous mode could be used without -runtime-counter-relocation on ELF. I just checked again and we disallow that mode. OK, I think it's fine to use
```
if (T.isOSBinFormatELF() || T.isOSAIX())
```
to match `runtime_reloc = bool(config.host_os in ["AIX", "Linux"])` in compiler-rt/test/profile/lit.cfg.py
https://github.com/llvm/llvm-project/pull/124353
More information about the cfe-commits
mailing list