aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/LTOBackend.cpp
diff options
context:
space:
mode:
authorYolanda Chen <yolanda.chen@intel.com>2021-08-11 09:45:55 -0700
committerFangrui Song <i@maskray.me>2021-08-11 09:45:55 -0700
commit8fa16cc628cb642798b3c218594cafa7426064e2 (patch)
tree7131f743cf76887a47e66f42514efe4a1275f8c3 /llvm/lib/LTO/LTOBackend.cpp
parent32adf108c8edd989caf9392131a5ebaf9de762f2 (diff)
downloadllvm-8fa16cc628cb642798b3c218594cafa7426064e2.zip
llvm-8fa16cc628cb642798b3c218594cafa7426064e2.tar.gz
llvm-8fa16cc628cb642798b3c218594cafa7426064e2.tar.bz2
[LTO][lld] Add lto-pgo-warn-mismatch option
When enable CSPGO for ThinLTO, there are profile cfg mismatch warnings that will cause lld-link errors (with /WX) due to source changes (e.g. `#if` code runs for profile generation but not for profile use) To disable it we have to use an internal "/mllvm:-no-pgo-warn-mismatch" option. In contrast clang uses option ”-Wno-backend-plugin“ to avoid such warnings and gcc has an explicit "-Wno-coverage-mismatch" option. Add "lto-pgo-warn-mismatch" option to lld COFF/ELF to help turn on/off the profile mismatch warnings explicitly when build with ThinLTO and CSPGO. Differential Revision: https://reviews.llvm.org/D104431
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 5863ec6..6563af0 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -74,6 +74,10 @@ static cl::opt<bool> ThinLTOAssumeMerged(
cl::desc("Assume the input has already undergone ThinLTO function "
"importing and the other pre-optimization pipeline changes."));
+namespace llvm {
+extern cl::opt<bool> NoPGOWarnMismatch;
+}
+
[[noreturn]] static void reportOpenError(StringRef Path, Twine Msg) {
errs() << "failed to open " << Path << ": " << Msg << '\n';
errs().flush();
@@ -221,6 +225,7 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
PGOOpt = PGOOptions(Conf.CSIRProfile, "", Conf.ProfileRemapping,
PGOOptions::IRUse, PGOOptions::CSIRUse,
Conf.AddFSDiscriminator);
+ NoPGOWarnMismatch = !Conf.PGOWarnMismatch;
} else if (Conf.AddFSDiscriminator) {
PGOOpt = PGOOptions("", "", "", PGOOptions::NoAction,
PGOOptions::NoCSAction, true);