[PATCH] D75630: [PSI] Add tests for is(Hot|Cold)FunctionInCallGraphNthPercentile.
Hiroshi Yamauchi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 11:15:43 PST 2020
yamauchi created this revision.
yamauchi added a reviewer: davidxl.
Herald added a subscriber: eraman.
Herald added a project: LLVM.
Follow up on D75283 <https://reviews.llvm.org/D75283>.
Also remove the test code that was moved to another test and was to be removed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75630
Files:
llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
Index: llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
===================================================================
--- llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
+++ llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
@@ -240,6 +240,11 @@
MDBuilder MDB(M->getContext());
CI2->setMetadata(llvm::LLVMContext::MD_prof, MDB.createBranchWeights({400}));
EXPECT_FALSE(PSI.isHotCallSite(CS2, &BFI));
+
+ EXPECT_TRUE(PSI.isFunctionHotInCallGraphNthPercentile(990000, F, BFI));
+ EXPECT_FALSE(PSI.isFunctionColdInCallGraphNthPercentile(990000, F, BFI));
+ EXPECT_FALSE(PSI.isFunctionHotInCallGraphNthPercentile(10000, F, BFI));
+ EXPECT_TRUE(PSI.isFunctionColdInCallGraphNthPercentile(10000, F, BFI));
}
TEST_F(ProfileSummaryInfoTest, InstrProfNoFuncEntryCount) {
@@ -265,6 +270,9 @@
EXPECT_FALSE(PSI.isColdBlockNthPercentile(990000, BB1, &BFI));
EXPECT_FALSE(PSI.isColdBlockNthPercentile(990000, BB2, &BFI));
EXPECT_FALSE(PSI.isColdBlockNthPercentile(990000, BB3, &BFI));
+
+ EXPECT_FALSE(PSI.isFunctionHotInCallGraphNthPercentile(990000, F, BFI));
+ EXPECT_FALSE(PSI.isFunctionColdInCallGraphNthPercentile(990000, F, BFI));
}
TEST_F(ProfileSummaryInfoTest, SampleProf) {
@@ -332,25 +340,10 @@
CI2->setMetadata(llvm::LLVMContext::MD_prof, MDB.createBranchWeights({400}));
EXPECT_TRUE(PSI.isHotCallSite(CS2, &BFI));
- {
- Function *F = M->getFunction("l");
- BlockFrequencyInfo BFI = buildBFI(*F);
- BasicBlock &BB0 = F->getEntryBlock();
- BasicBlock *BB1 = BB0.getTerminator()->getSuccessor(0);
- BasicBlock *BB2 = BB0.getTerminator()->getSuccessor(1);
- BasicBlock *BB3 = BB1->getSingleSuccessor();
-
- // Without the entry count, all should return false.
- EXPECT_FALSE(PSI.isHotBlockNthPercentile(990000, &BB0, &BFI));
- EXPECT_FALSE(PSI.isHotBlockNthPercentile(990000, BB1, &BFI));
- EXPECT_FALSE(PSI.isHotBlockNthPercentile(990000, BB2, &BFI));
- EXPECT_FALSE(PSI.isHotBlockNthPercentile(990000, BB3, &BFI));
-
- EXPECT_FALSE(PSI.isColdBlockNthPercentile(990000, &BB0, &BFI));
- EXPECT_FALSE(PSI.isColdBlockNthPercentile(990000, BB1, &BFI));
- EXPECT_FALSE(PSI.isColdBlockNthPercentile(990000, BB2, &BFI));
- EXPECT_FALSE(PSI.isColdBlockNthPercentile(990000, BB3, &BFI));
- }
+ EXPECT_TRUE(PSI.isFunctionHotInCallGraphNthPercentile(990000, F, BFI));
+ EXPECT_FALSE(PSI.isFunctionColdInCallGraphNthPercentile(990000, F, BFI));
+ EXPECT_FALSE(PSI.isFunctionHotInCallGraphNthPercentile(10000, F, BFI));
+ EXPECT_TRUE(PSI.isFunctionColdInCallGraphNthPercentile(10000, F, BFI));
}
TEST_F(ProfileSummaryInfoTest, SampleProfNoFuncEntryCount) {
@@ -376,6 +369,9 @@
EXPECT_FALSE(PSI.isColdBlockNthPercentile(990000, BB1, &BFI));
EXPECT_FALSE(PSI.isColdBlockNthPercentile(990000, BB2, &BFI));
EXPECT_FALSE(PSI.isColdBlockNthPercentile(990000, BB3, &BFI));
+
+ EXPECT_FALSE(PSI.isFunctionHotInCallGraphNthPercentile(990000, F, BFI));
+ EXPECT_FALSE(PSI.isFunctionColdInCallGraphNthPercentile(990000, F, BFI));
}
} // end anonymous namespace
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75630.248259.patch
Type: text/x-patch
Size: 3055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200304/bb6c0459/attachment.bin>
More information about the llvm-commits
mailing list