[PATCH] D30800: Do not use branch metadata to check if a basic block is hot.
Dehao Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 9 17:30:22 PST 2017
danielcdh created this revision.
We should not use that to check basic block hotness as optimization may mess it up.
https://reviews.llvm.org/D30800
Files:
lib/Analysis/ProfileSummaryInfo.cpp
unittests/Analysis/ProfileSummaryInfoTest.cpp
Index: unittests/Analysis/ProfileSummaryInfoTest.cpp
===================================================================
--- unittests/Analysis/ProfileSummaryInfoTest.cpp
+++ unittests/Analysis/ProfileSummaryInfoTest.cpp
@@ -162,12 +162,6 @@
EXPECT_TRUE(PSI.isHotCallSite(CS1, &BFI));
EXPECT_FALSE(PSI.isHotCallSite(CS2, &BFI));
-
- // Test that adding an MD_prof metadata with a hot count on CS2 does not
- // change itas hotness as it has no effect in instrumented profiling.
- MDBuilder MDB(M->getContext());
- CI2->setMetadata(llvm::LLVMContext::MD_prof, MDB.createBranchWeights({400}));
- EXPECT_FALSE(PSI.isHotCallSite(CS2, &BFI));
}
TEST_F(ProfileSummaryInfoTest, SampleProf) {
Index: lib/Analysis/ProfileSummaryInfo.cpp
===================================================================
--- lib/Analysis/ProfileSummaryInfo.cpp
+++ lib/Analysis/ProfileSummaryInfo.cpp
@@ -124,18 +124,7 @@
bool ProfileSummaryInfo::isHotBB(const BasicBlock *B, BlockFrequencyInfo *BFI) {
auto Count = BFI->getBlockProfileCount(B);
- if (Count && isHotCount(*Count))
- return true;
- // Use extractProfTotalWeight to get BB count.
- // For Sample PGO, BFI may not provide accurate BB count due to errors
- // magnified during sample count propagation. This serves as a backup plan
- // to ensure all hot BB will not be missed.
- // The query currently has false positives as branch instruction cloning does
- // not update/scale branch weights. Unlike false negatives, this will not cause
- // performance problem.
- uint64_t TotalCount;
- auto *TI = B->getTerminator();
- return extractProfTotalWeight(TI, TotalCount) && isHotCount(TotalCount);
+ return Count && isHotCount(*Count);
}
bool ProfileSummaryInfo::isColdBB(const BasicBlock *B,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30800.91242.patch
Type: text/x-patch
Size: 1772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170310/5f91cc09/attachment.bin>
More information about the llvm-commits
mailing list