[PATCH] D75630: [PSI] Add tests for is(Hot|Cold)FunctionInCallGraphNthPercentile.

Hiroshi Yamauchi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 08:40:19 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b4e5d41ec00: [PSI] Add tests for is(Hot|Cold)FunctionInCallGraphNthPercentile. (authored by yamauchi).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75630/new/

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.249398.patch
Type: text/x-patch
Size: 3055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200310/201486a8/attachment.bin>


More information about the llvm-commits mailing list