From 7da5a08e1a50ca5da1a35a4fa83673bf96f37d3c Mon Sep 17 00:00:00 2001 From: Wei Mi Date: Wed, 12 Dec 2018 17:09:27 +0000 Subject: [SampleFDO] Extend profile-sample-accurate option to cover isFunctionColdInCallGraph For SampleFDO, when a callsite doesn't appear in the profile, it will not be marked as cold callsite unless the option -profile-sample-accurate is specified. But profile-sample-accurate doesn't cover function isFunctionColdInCallGraph which is used to decide whether a function should be put into text.unlikely section, so even if the user knows the profile is accurate and specifies profile-sample-accurate, those functions not appearing in the sample profile are still not be put into text.unlikely section right now. The patch fixes that. Differential Revision: https://reviews.llvm.org/D55567 llvm-svn: 348940 --- llvm/lib/Analysis/ProfileSummaryInfo.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Analysis/ProfileSummaryInfo.cpp') diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp index bd8459ddb82..4326e53b43b 100644 --- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp +++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp @@ -261,7 +261,14 @@ bool ProfileSummaryInfo::isHotBlock(const BasicBlock *BB, BlockFrequencyInfo *BF bool ProfileSummaryInfo::isColdBlock(const BasicBlock *BB, BlockFrequencyInfo *BFI) { auto Count = BFI->getBlockProfileCount(BB); - return Count && isColdCount(*Count); + if (Count) + return isColdCount(*Count); + if (!hasSampleProfile()) + return false; + + const Function *F = BB->getParent(); + return ProfileSampleAccurate || + (F && F->hasFnAttribute("profile-sample-accurate")); } bool ProfileSummaryInfo::isHotCallSite(const CallSite &CS, -- cgit v1.2.3