diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -143,6 +143,12 @@ "callsite and function as having 0 samples. Otherwise, treat " "un-sampled callsites and functions conservatively as unknown. ")); +static cl::opt ProfileSampleBlockAccurate( + "profile-sample-block-accurate", cl::Hidden, cl::init(false), + cl::desc("If the sample profile is accurate, we will mark all un-sampled " + "branches and calls as having 0 samples. Otherwise, treat " + "them conservatively as unknown. ")); + static cl::opt ProfileAccurateForSymsInList( "profile-accurate-for-symsinlist", cl::Hidden, cl::ZeroOrMore, cl::init(true), @@ -1529,7 +1535,7 @@ {static_cast(BlockWeights[BB])})); } } - } else if (OverwriteExistingWeights) { + } else if (OverwriteExistingWeights || ProfileSampleBlockAccurate) { // Set profile metadata (possibly annotated by LTO prelink) to zero or // clear it for cold code. for (auto &I : BB->getInstList()) {