diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -672,15 +672,22 @@ } bool isCostBenefitAnalysisEnabled() { - if (!InlineEnableCostBenefitAnalysis) - return false; - if (!PSI || !PSI->hasProfileSummary()) return false; if (!GetBFI) return false; + if (InlineEnableCostBenefitAnalysis.getNumOccurrences()) { + // Honor the explicit request from the user. + if (!InlineEnableCostBenefitAnalysis) + return false; + } else { + // Otherwise, require instrumentation profile. + if (!PSI->hasInstrumentationProfile()) + return false; + } + auto *Caller = CandidateCall.getParent()->getParent(); if (!Caller->getEntryCount()) return false;