<div dir="ltr">So even after applying this patch, IRMover is still emitting an error. I believe the root cause of this is that we do a pointer based comparison of the metadata values. This has worked until now when we have constant values because we unique them in the IR, but doesn't for the ProfileSummary value which references another metadata entry. If you could, please take a look and let me know if I'm seeing things correctly.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 20, 2016 at 6:33 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">eraman created this revision.<br>
eraman added reviewers: davidxl, JakeVanAdrighem.<br>
eraman added a subscriber: llvm-commits.<br>
<br>
This fixes the root cause of PR28219 - profile summar metadata mismatch in LTO mode. This probably needs an LTO test too - what would be the right place to have it?<br>
<br>
<a href="http://reviews.llvm.org/D21546" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21546</a><br>
<br>
Files:<br>
  lib/Transforms/Instrumentation/PGOInstrumentation.cpp<br>
  test/Transforms/PGOProfile/Inputs/PR28219.proftext<br>
  test/Transforms/PGOProfile/PR28219.ll<br>
<br>
Index: test/Transforms/PGOProfile/PR28219.ll<br>
===================================================================<br>
--- /dev/null<br>
+++ test/Transforms/PGOProfile/PR28219.ll<br>
@@ -0,0 +1,12 @@<br>
+; Test that we annotate entire program's summary and not just this module's<br>
+; RUN: llvm-profdata merge %S/Inputs/PR28219.proftext -o %t.profdata<br>
+; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s<br>
+<br>
+define i32 @bar() {<br>
+entry:<br>
+  ret i32 1<br>
+}<br>
+; CHECK-DAG: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}<br>
+; CHECK-DAG: {{![0-9]+}} = !{!"NumFunctions", i64 2}<br>
+; CHECK-DAG: {{![0-9]+}} = !{!"MaxFunctionCount", i64 3}<br>
+<br>
Index: test/Transforms/PGOProfile/Inputs/PR28219.proftext<br>
===================================================================<br>
--- /dev/null<br>
+++ test/Transforms/PGOProfile/Inputs/PR28219.proftext<br>
@@ -0,0 +1,10 @@<br>
+# :ir is the flag to indicate this is IR level profile.<br>
+:ir<br>
+@bar<br>
+256<br>
+1<br>
+2<br>
+@foo<br>
+512<br>
+1<br>
+3<br>
Index: lib/Transforms/Instrumentation/PGOInstrumentation.cpp<br>
===================================================================<br>
--- lib/Transforms/Instrumentation/PGOInstrumentation.cpp<br>
+++ lib/Transforms/Instrumentation/PGOInstrumentation.cpp<br>
@@ -879,7 +879,6 @@<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>
@@ -891,15 +890,13 @@<br>
     Func.populateCounters();<br>
     Func.setBranchWeights();<br>
     Func.annotateIndirectCallSites();<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>
-  M.setProfileSummary(Builder.getSummary()->getMD(M.getContext()));<br>
+  M.setProfileSummary(PGOReader->getSummary().getMD(M.getContext()));<br>
   // Set function hotness attribute from the profile.<br>
   // We have to apply these attributes at the end because their presence<br>
   // can affect the BranchProbabilityInfo of any callers, resulting in an<br>
<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>
<br></blockquote></div><br></div>