Index: lib/Transforms/Instrumentation/PGOInstrumentation.cpp =================================================================== --- lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -111,6 +111,16 @@ cl::desc("Max number of annotations for a single indirect " "call callsite")); +// Command line option to enable/disable the warning about missing profile +// information. +static cl::opt PGOWarnMissing("pgo-warn-missing", cl::init(true), + cl::Hidden); + +// Command line option to enable/disable the warning about a hash mismatch in +// the profile data. +static cl::opt PGOWarnMismatch("pgo-warn-mismatch", cl::init(true), + cl::Hidden); + namespace { class PGOInstrumentationGenLegacyPass : public ModulePass { public: @@ -575,11 +585,17 @@ ErrorOr Result = PGOReader->getInstrProfRecord(FuncInfo.FuncName, FuncInfo.FunctionHash); if (std::error_code EC = Result.getError()) { - if (EC == instrprof_error::unknown_function) + bool Warn = false; + if (PGOWarnMissing && EC == instrprof_error::unknown_function) { NumOfPGOMissing++; - else if (EC == instrprof_error::hash_mismatch || - EC == llvm::instrprof_error::malformed) + Warn = true; + } else if (PGOWarnMismatch && (EC == instrprof_error::hash_mismatch || + EC == llvm::instrprof_error::malformed)) { NumOfPGOMismatch++; + Warn = true; + } + if (!Warn) + return false; std::string Msg = EC.message() + std::string(" ") + F.getName().str(); Ctx.diagnose(