diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h --- a/lld/COFF/Config.h +++ b/lld/COFF/Config.h @@ -223,6 +223,9 @@ // Used for /lto-cs-profile-path llvm::StringRef ltoCSProfileFile; + // Used for /lto-cspgo-warn-mismatch: + bool ltoCSPGOWarnMismatch = true; + // Used for /call-graph-ordering-file: llvm::MapVector, uint64_t> diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -1744,6 +1744,8 @@ config->ltoCSProfileGenerate = args.hasArg(OPT_lto_cs_profile_generate); config->ltoCSProfileFile = args.getLastArgValue(OPT_lto_cs_profile_file); // Handle miscellaneous boolean flags. + config->ltoCSPGOWarnMismatch = args.hasFlag( + OPT_lto_cspgo_warn_mismatch, OPT_lto_cspgo_warn_mismatch_no, true); config->allowBind = args.hasFlag(OPT_allowbind, OPT_allowbind_no, true); config->allowIsolation = args.hasFlag(OPT_allowisolation, OPT_allowisolation_no, true); diff --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp --- a/lld/COFF/LTO.cpp +++ b/lld/COFF/LTO.cpp @@ -87,6 +87,7 @@ c.DebugPassManager = config->ltoDebugPassManager; c.CSIRProfile = std::string(config->ltoCSProfileFile); c.RunCSIRInstr = config->ltoCSProfileGenerate; + c.CSPGOWarnMismatch = config->ltoCSPGOWarnMismatch; if (config->saveTemps) checkError(c.addSaveTemps(std::string(config->outputFile) + ".", diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td --- a/lld/COFF/Options.td +++ b/lld/COFF/Options.td @@ -243,6 +243,10 @@ HelpText<"Perform context sensitive PGO instrumentation">; def lto_cs_profile_file : P<"lto-cs-profile-file", "Context sensitive profile file path">; +defm lto_cspgo_warn_mismatch: B< + "lto-cspgo-warn-mismatch", + "turn on warnings about profile cfg mismatch (default)>", + "turn off warnings about profile cfg mismatch">; def dash_dash_version : Flag<["--"], "version">, HelpText<"Display the version number and exit">; def threads diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h --- a/llvm/include/llvm/LTO/Config.h +++ b/llvm/include/llvm/LTO/Config.h @@ -70,6 +70,10 @@ /// Run PGO context sensitive IR instrumentation. bool RunCSIRInstr = false; + /// Turn on/off the warning about a hash mismatch in the context sensitive + /// PGO profile data. + bool CSPGOWarnMismatch = true; + /// Asserts whether we can assume whole program visibility during the LTO /// link. bool HasWholeProgramVisibility = false; diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -74,6 +74,10 @@ cl::desc("Assume the input has already undergone ThinLTO function " "importing and the other pre-optimization pipeline changes.")); +// Command line option to turn off/on warnings for pgo profile mismatch. +// Defined in Transforms/PGOInstrumentation.cpp: -no-pgo-warn-mismatch +extern cl::opt NoPGOWarnMismatch; + LLVM_ATTRIBUTE_NORETURN static void reportOpenError(StringRef Path, Twine Msg) { errs() << "failed to open " << Path << ": " << Msg << '\n'; errs().flush(); @@ -221,6 +225,7 @@ PGOOpt = PGOOptions(Conf.CSIRProfile, "", Conf.ProfileRemapping, PGOOptions::IRUse, PGOOptions::CSIRUse, Conf.AddFSDiscriminator); + NoPGOWarnMismatch = !Conf.CSPGOWarnMismatch; } else if (Conf.AddFSDiscriminator) { PGOOpt = PGOOptions("", "", "", PGOOptions::NoAction, PGOOptions::NoCSAction, true); diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -200,7 +200,7 @@ // Command line option to enable/disable the warning about a hash mismatch in // the profile data. -static cl::opt +cl::opt NoPGOWarnMismatch("no-pgo-warn-mismatch", cl::init(false), cl::Hidden, cl::desc("Use this option to turn off/on " "warnings about profile cfg mismatch."));