Index: include/llvm/Analysis/ProfileSummaryInfo.h =================================================================== --- include/llvm/Analysis/ProfileSummaryInfo.h +++ include/llvm/Analysis/ProfileSummaryInfo.h @@ -51,11 +51,11 @@ ProfileSummaryInfo(Module &M) : M(M) {} ProfileSummaryInfo(ProfileSummaryInfo &&Arg) : M(Arg.M), Summary(std::move(Arg.Summary)) {} + /// \brief Returns true if \p F has hot function entry. + bool isFunctionEntryHot(const Function *F); + /// \brief Returns true if \p F has cold function entry. + bool isFunctionEntryCold(const Function *F); /// \brief Returns true if \p F is a hot function. - bool isHotFunction(const Function *F); - /// \brief Returns true if \p F is a cold function. - bool isColdFunction(const Function *F); - /// \brief Returns true if count \p C is considered hot. bool isHotCount(uint64_t C); /// \brief Returns true if count \p C is considered cold. bool isColdCount(uint64_t C); Index: lib/Analysis/InlineCost.cpp =================================================================== --- lib/Analysis/InlineCost.cpp +++ lib/Analysis/InlineCost.cpp @@ -647,14 +647,14 @@ // when it would increase the threshold and the caller does not need to // minimize its size. bool InlineHint = Callee.hasFnAttribute(Attribute::InlineHint) || - PSI->isHotFunction(&Callee); + PSI->isFunctionEntryHot(&Callee); if (InlineHint && !Caller->optForMinSize()) Threshold = MaxIfValid(Threshold, Params.HintThreshold); if (HotCallsite && !Caller->optForMinSize()) Threshold = MaxIfValid(Threshold, Params.HotCallSiteThreshold); - bool ColdCallee = PSI->isColdFunction(&Callee); + bool ColdCallee = PSI->isFunctionEntryCold(&Callee); // For cold callees, use the ColdThreshold knob if it is available and reduces // the threshold. if (ColdCallee) Index: lib/Analysis/ProfileSummaryInfo.cpp =================================================================== --- lib/Analysis/ProfileSummaryInfo.cpp +++ lib/Analysis/ProfileSummaryInfo.cpp @@ -66,7 +66,7 @@ /// Returns true if the function is a hot function. If it returns false, it /// either means it is not hot or it is unknown whether F is hot or not (for /// example, no profile data is available). -bool ProfileSummaryInfo::isHotFunction(const Function *F) { +bool ProfileSummaryInfo::isFunctionEntryHot(const Function *F) { computeSummary(); if (!F || !Summary) return false; @@ -74,15 +74,13 @@ // FIXME: The heuristic used below for determining hotness is based on // preliminary SPEC tuning for inliner. This will eventually be a // convenience method that calls isHotCount. - return (FunctionCount && - FunctionCount.getValue() >= - (uint64_t)(0.3 * (double)Summary->getMaxFunctionCount())); + return FunctionCount && isHotCount(FunctionCount.getValue()); } /// Returns true if the function is a cold function. If it returns false, it /// either means it is not cold or it is unknown whether F is cold or not (for /// example, no profile data is available). -bool ProfileSummaryInfo::isColdFunction(const Function *F) { +bool ProfileSummaryInfo::isFunctionEntryCold(const Function *F) { computeSummary(); if (!F) return false; @@ -95,9 +93,7 @@ // FIXME: The heuristic used below for determining coldness is based on // preliminary SPEC tuning for inliner. This will eventually be a // convenience method that calls isHotCount. - return (FunctionCount && - FunctionCount.getValue() <= - (uint64_t)(0.01 * (double)Summary->getMaxFunctionCount())); + return FunctionCount && isColdCount(FunctionCount.getValue()); } /// Compute the hot and cold thresholds. @@ -149,7 +145,7 @@ return ProfileSummaryInfo(M); } -// FIXME: This only tests isHotFunction and isColdFunction and not the +// FIXME: This only tests isFunctionEntryHot and isFunctionEntryCold and not the // isHotCount and isColdCount calls. PreservedAnalyses ProfileSummaryPrinterPass::run(Module &M, ModuleAnalysisManager &AM) { @@ -158,9 +154,9 @@ OS << "Functions in " << M.getName() << " with hot/cold annotations: \n"; for (auto &F : M) { OS << F.getName(); - if (PSI.isHotFunction(&F)) + if (PSI.isFunctionEntryHot(&F)) OS << " :hot "; - else if (PSI.isColdFunction(&F)) + else if (PSI.isFunctionEntryCold(&F)) OS << " :cold "; OS << "\n"; }