[PATCH] D33156: Add hasProfileSummary method.

Easwaran Raman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 15:40:09 PDT 2017


eraman created this revision.

This will be useful in inliner if we want to differentiate globally hot  vs locally hot callsites.


https://reviews.llvm.org/D33156

Files:
  include/llvm/Analysis/ProfileSummaryInfo.h
  lib/Analysis/ProfileSummaryInfo.cpp
  unittests/Analysis/ProfileSummaryInfoTest.cpp


Index: unittests/Analysis/ProfileSummaryInfoTest.cpp
===================================================================
--- unittests/Analysis/ProfileSummaryInfoTest.cpp
+++ unittests/Analysis/ProfileSummaryInfoTest.cpp
@@ -102,6 +102,7 @@
   Function *F = M->getFunction("f");
 
   ProfileSummaryInfo PSI = buildPSI(M.get());
+  EXPECT_FALSE(PSI.hasProfileSummary());
   // In the absence of profiles, is{Hot|Cold}X methods should always return
   // false.
   EXPECT_FALSE(PSI.isHotCount(1000));
@@ -130,6 +131,7 @@
   Function *H = M->getFunction("h");
 
   ProfileSummaryInfo PSI = buildPSI(M.get());
+  EXPECT_TRUE(PSI.hasProfileSummary());
   EXPECT_TRUE(PSI.isHotCount(400));
   EXPECT_TRUE(PSI.isColdCount(2));
   EXPECT_FALSE(PSI.isColdCount(100));
@@ -144,6 +146,7 @@
   auto M = makeLLVMModule("InstrProf");
   Function *F = M->getFunction("f");
   ProfileSummaryInfo PSI = buildPSI(M.get());
+  EXPECT_TRUE(PSI.hasProfileSummary());
 
   BasicBlock &BB0 = F->getEntryBlock();
   BasicBlock *BB1 = BB0.getTerminator()->getSuccessor(0);
@@ -174,6 +177,7 @@
   auto M = makeLLVMModule("SampleProfile");
   Function *F = M->getFunction("f");
   ProfileSummaryInfo PSI = buildPSI(M.get());
+  EXPECT_TRUE(PSI.hasProfileSummary());
 
   BasicBlock &BB0 = F->getEntryBlock();
   BasicBlock *BB1 = BB0.getTerminator()->getSuccessor(0);
Index: lib/Analysis/ProfileSummaryInfo.cpp
===================================================================
--- lib/Analysis/ProfileSummaryInfo.cpp
+++ lib/Analysis/ProfileSummaryInfo.cpp
@@ -68,6 +68,10 @@
   return true;
 }
 
+bool ProfileSummaryInfo::hasProfileSummary() {
+  return computeSummary();
+}
+
 Optional<uint64_t>
 ProfileSummaryInfo::getProfileCount(const Instruction *Inst,
                                     BlockFrequencyInfo *BFI) {
Index: include/llvm/Analysis/ProfileSummaryInfo.h
===================================================================
--- include/llvm/Analysis/ProfileSummaryInfo.h
+++ include/llvm/Analysis/ProfileSummaryInfo.h
@@ -55,6 +55,9 @@
   ProfileSummaryInfo(ProfileSummaryInfo &&Arg)
       : M(Arg.M), Summary(std::move(Arg.Summary)) {}
 
+  /// \brief Returns true if profile summary is available.
+  bool hasProfileSummary();
+
   /// Handle the invalidation of this information.
   ///
   /// When used as a result of \c ProfileSummaryAnalysis this method will be


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33156.98857.patch
Type: text/x-patch
Size: 2361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170512/daba6424/attachment.bin>


More information about the llvm-commits mailing list