<div dir="ltr">The plan is to deprecate the function_entry_count metadata, right? I noticed in passing that the IR instrumentation was not setting that.<div><br></div><div>I noticed in <a href="http://reviews.llvm.org/D20648">http://reviews.llvm.org/D20648</a> that you are doing `auto FunctionCount = F->getEntryCount();`. Will that eventually be deprecated? You may want to add a note there.<br><div><br></div><div>-- Sean Silva</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 26, 2016 at 3:57 PM, Easwaran Raman via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: eraman<br>
Date: Thu May 26 17:57:11 2016<br>
New Revision: 270933<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=270933&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=270933&view=rev</a><br>
Log:<br>
Attach profile summary in IR based instrumentation pass.<br>
<br>
Differential revision: <a href="http://reviews.llvm.org/D20655" rel="noreferrer" target="_blank">http://reviews.llvm.org/D20655</a><br>
<br>
Modified:<br>
    llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp<br>
    llvm/trunk/test/Transforms/PGOProfile/branch1.ll<br>
<br>
Modified: llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp?rev=270933&r1=270932&r2=270933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp?rev=270933&r1=270932&r2=270933&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp Thu May 26 17:57:11 2016<br>
@@ -67,6 +67,7 @@<br>
 #include "llvm/IR/Module.h"<br>
 #include "llvm/Pass.h"<br>
 #include "llvm/ProfileData/InstrProfReader.h"<br>
+#include "llvm/ProfileData/ProfileCommon.h"<br>
 #include "llvm/Support/BranchProbability.h"<br>
 #include "llvm/Support/Debug.h"<br>
 #include "llvm/Support/JamCRC.h"<br>
@@ -478,6 +479,9 @@ public:<br>
   // Return the function hotness from the profile.<br>
   FuncFreqAttr getFuncFreqAttr() const { return FreqAttr; }<br>
<br>
+  // Return the profile record for this function;<br>
+  InstrProfRecord &getProfileRecord() { return ProfileRecord; }<br>
+<br>
 private:<br>
   Function &F;<br>
   Module *M;<br>
@@ -883,6 +887,7 @@ static bool annotateAllFunctions(<br>
<br>
   std::vector<Function *> HotFunctions;<br>
   std::vector<Function *> ColdFunctions;<br>
+  InstrProfSummaryBuilder Builder(ProfileSummaryBuilder::DefaultCutoffs);<br>
   for (auto &F : M) {<br>
     if (F.isDeclaration())<br>
       continue;<br>
@@ -890,13 +895,15 @@ static bool annotateAllFunctions(<br>
     auto *BFI = LookupBFI(F);<br>
     PGOUseFunc Func(F, &M, BPI, BFI);<br>
     setPGOCountOnFunc(Func, PGOReader.get());<br>
+    if (!Func.getProfileRecord().Counts.empty())<br>
+      Builder.addRecord(Func.getProfileRecord());<br>
     PGOUseFunc::FuncFreqAttr FreqAttr = Func.getFuncFreqAttr();<br>
     if (FreqAttr == PGOUseFunc::FFA_Cold)<br>
       ColdFunctions.push_back(&F);<br>
     else if (FreqAttr == PGOUseFunc::FFA_Hot)<br>
       HotFunctions.push_back(&F);<br>
   }<br>
-<br>
+  M.setProfileSummary(Builder.getSummary()->getMD(M.getContext()));<br>
   // Set function hotness attribute from the profile.<br>
   for (auto &F : HotFunctions) {<br>
     F->addFnAttr(llvm::Attribute::InlineHint);<br>
<br>
Modified: llvm/trunk/test/Transforms/PGOProfile/branch1.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/branch1.ll?rev=270933&r1=270932&r2=270933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/branch1.ll?rev=270933&r1=270932&r2=270933&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/PGOProfile/branch1.ll (original)<br>
+++ llvm/trunk/test/Transforms/PGOProfile/branch1.ll Thu May 26 17:57:11 2016<br>
@@ -28,7 +28,7 @@ entry:<br>
   br i1 %cmp, label %if.then, label %if.end<br>
 ; USE: br i1 %cmp, label %if.then, label %if.end<br>
 ; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]<br>
-; USE: ![[BW_ENTRY]] = !{!"branch_weights", i32 2, i32 1}<br>
+; USE-DAG: ![[BW_ENTRY]] = !{!"branch_weights", i32 2, i32 1}<br>
<br>
 if.then:<br>
 ; GEN: if.then:<br>
@@ -42,3 +42,5 @@ if.end:<br>
   %retv = phi i32 [ %add, %if.then ], [ %i, %entry ]<br>
   ret i32 %retv<br>
 }<br>
+; USE-DAG: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}<br>
+; USE-DAG: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>