[llvm] 4b4e5d4 - [PSI] Add tests for is(Hot|Cold)FunctionInCallGraphNthPercentile.

Hiroshi Yamauchi via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 08:36:07 PDT 2020


Author: Hiroshi Yamauchi
Date: 2020-03-10T08:21:10-07:00
New Revision: 4b4e5d41ec0073b4f5be1b68681314c605220e03

URL: https://github.com/llvm/llvm-project/commit/4b4e5d41ec0073b4f5be1b68681314c605220e03
DIFF: https://github.com/llvm/llvm-project/commit/4b4e5d41ec0073b4f5be1b68681314c605220e03.diff

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

Summary:
Follow up on D75283.

Also remove the test code that was moved to another test and was to be removed.

Reviewers: davidxl

Subscribers: eraman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D75630

Added: 
    

Modified: 
    llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp b/llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
index 6c4e42aa7e05..ea354a9ede38 100644
--- a/llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
+++ b/llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
@@ -240,6 +240,11 @@ TEST_F(ProfileSummaryInfoTest, InstrProf) {
   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 @@ TEST_F(ProfileSummaryInfoTest, InstrProfNoFuncEntryCount) {
   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 @@ TEST_F(ProfileSummaryInfoTest, SampleProf) {
   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 @@ TEST_F(ProfileSummaryInfoTest, SampleProfNoFuncEntryCount) {
   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


        


More information about the llvm-commits mailing list