From 0698de9218db7613e9e9af9dce5746c8808e4be5 Mon Sep 17 00:00:00 2001 From: Rong Xu Date: Fri, 13 May 2016 17:26:06 +0000 Subject: [PATCH] [PGO] Add flags to control IRPGO warnings. Currently there is no reasonable way to control the warnings in the 'use' phase of the IRPGO pass. This is problematic because the output can be somewhat spammy. This patch adds some flags which allow us to optionally disable these warnings. The current upstream behavior will remain the default. Patch by Jake VanAdrighem (jvanadrighem@gmail.com) Differential Revision: http://reviews.llvm.org/D20195 llvm-svn: 269437 --- .../Instrumentation/PGOInstrumentation.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 6ec36319e3e3..379f7c5ebed9 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -111,6 +111,16 @@ static cl::opt MaxNumAnnotations( 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 NoPGOWarnMissing("no-pgo-warn-missing", cl::init(false), + cl::Hidden); + +// Command line option to enable/disable the warning about a hash mismatch in +// the profile data. +static cl::opt NoPGOWarnMismatch("no-pgo-warn-mismatch", cl::init(false), + cl::Hidden); + namespace { class PGOInstrumentationGenLegacyPass : public ModulePass { public: @@ -575,11 +585,16 @@ bool PGOUseFunc::readCounters(IndexedInstrProfReader *PGOReader) { ErrorOr Result = PGOReader->getInstrProfRecord(FuncInfo.FuncName, FuncInfo.FunctionHash); if (std::error_code EC = Result.getError()) { - if (EC == instrprof_error::unknown_function) + if (EC == instrprof_error::unknown_function) { NumOfPGOMissing++; - else if (EC == instrprof_error::hash_mismatch || - EC == llvm::instrprof_error::malformed) + if (NoPGOWarnMissing) + return false; + } else if (EC == instrprof_error::hash_mismatch || + EC == llvm::instrprof_error::malformed) { NumOfPGOMismatch++; + if (NoPGOWarnMismatch) + return false; + } std::string Msg = EC.message() + std::string(" ") + F.getName().str(); Ctx.diagnose(