<div dir="ltr">Looks like none of the "prof" metadata is documented, and it is only partially verified. I'll go ahead and add these. Probably the LangRef first, today, then the verifier as a follow-up with tests in the next day or so.<div>Teresa</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 14, 2017 at 9:59 AM, Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I guess the author is no longer active in LLVM. +davidxl, we can have someone here add it.<span class="HOEnZb"><font color="#888888"><div>Teresa</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 14, 2017 at 9:46 AM, Philip Reames <span dir="ltr"><<a href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div class="m_3995847052723939642m_2022698915543435463moz-cite-prefix">Teresa, Dehao,<br>
      <br>
      It's been a couple of weeks and this new metadata extension still
      has not been added to the LangRef or the verifier.  This needs
      immediate attention.<br>
      <br>
      I would like to build off this work but am unclear on the
      semantics of the new metadata.  The lack of
      documentation/verification is actively blocking me from forward
      progress.<span class="m_3995847052723939642HOEnZb"><font color="#888888"><br>
      <br>
      Philip</font></span><div><div class="m_3995847052723939642h5"><br>
      <br>
      On 05/19/2017 09:27 PM, Teresa Johnson wrote:<br>
    </div></div></div><div><div class="m_3995847052723939642h5">
    <blockquote type="cite">
      <div dir="ltr">Hi Philip,
        <div><br>
        </div>
        <div>I was just looking back at this commit and saw your
          question. It is Value Profile metadata (e.g. for indirect call
          profiling) and was introduced in <a href="https://reviews.llvm.org/D8940" target="_blank">https://reviews.llvm.org/D8<wbr>940</a>.</div>
        <div><br>
        </div>
        <div>Teresa</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, May 5, 2017 at 6:05 PM, Philip
          Reames 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">Sorry, I
            think I'm coming into something late here.  What exactly is
            VP metadata?  I have not seen this before and it does not
            appear to be documented in the LangRef.  The latter is a
            major problem which needs fixed ASAP.<br>
            <br>
            Can you give a pointer where the review thread this was
            introduced in?<br>
            <br>
            Philip
            <div class="m_3995847052723939642m_2022698915543435463HOEnZb">
              <div class="m_3995847052723939642m_2022698915543435463h5"><br>
                <br>
                On 05/04/2017 05:47 PM, Dehao Chen via llvm-commits
                wrote:<br>
                <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  Author: dehao<br>
                  Date: Thu May  4 19:47:34 2017<br>
                  New Revision: 302209<br>
                  <br>
                  URL: <a href="http://llvm.org/viewvc/llvm-project?rev=302209&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=302209&view=rev</a><br>
                  Log:<br>
                  Update VP prof metadata during inlining.<br>
                  <br>
                  Summary: r298270 added profile update logic for
                  branch_weights. This patch implements profile update
                  logic for VP prof metadata too.<br>
                  <br>
                  Reviewers: eraman, tejohnson, davidxl<br>
                  <br>
                  Reviewed By: eraman<br>
                  <br>
                  Subscribers: llvm-commits<br>
                  <br>
                  Differential Revision: <a href="https://reviews.llvm.org/D32773" rel="noreferrer" target="_blank">https://reviews.llvm.org/D3277<wbr>3</a><br>
                  <br>
                  Modified:<br>
                       llvm/trunk/lib/IR/Instruction<wbr>.cpp<br>
                       llvm/trunk/test/Transforms/In<wbr>line/prof-update.ll<br>
                  <br>
                  Modified: llvm/trunk/lib/IR/Instruction.<wbr>cpp<br>
                  URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instruction.cpp?rev=302209&r1=302208&r2=302209&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/IR/Instru<wbr>ction.cpp?rev=302209&r1=302208<wbr>&r2=302209&view=diff</a><br>
                  ==============================<wbr>==============================<wbr>==================<br>
                  --- llvm/trunk/lib/IR/Instruction.<wbr>cpp (original)<br>
                  +++ llvm/trunk/lib/IR/Instruction.<wbr>cpp Thu May  4
                  19:47:34 2017<br>
                  @@ -625,20 +625,41 @@ void
                  Instruction::updateProfWeight(<wbr>uint6<br>
                        return;<br>
                        auto *ProfDataName =
                  dyn_cast<MDString>(ProfileData<wbr>->getOperand(0));<br>
                  -  if (!ProfDataName ||
                  !ProfDataName->getString().equ<wbr>als("branch_weights"))<br>
                  +  if (!ProfDataName ||
                  (!ProfDataName->getString().eq<wbr>uals("branch_weights")
                  &&<br>
                  +                       
                  !ProfDataName->getString().equ<wbr>als("VP")))<br>
                        return;<br>
                    -  SmallVector<uint32_t, 4> Weights;<br>
                  -  for (unsigned i = 1; i <
                  ProfileData->getNumOperands(); i++) {<br>
                  -    // Using APInt::div may be expensive, but most
                  cases should fit in 64 bits.<br>
                  -    APInt Val(128, mdconst::dyn_extract<ConstantI<wbr>nt>(ProfileData->getOperand(i)<wbr>)<br>
                  -                       ->getValue()<br>
                  -                       .getZExtValue());<br>
                  -    Val *= APInt(128, S);<br>
                  -    Weights.push_back(Val.udiv(API<wbr>nt(128,
                  T)).getLimitedValue());<br>
                  -  }<br>
                      MDBuilder MDB(getContext());<br>
                  -  setMetadata(LLVMContext::MD_pr<wbr>of,
                  MDB.createBranchWeights(Weight<wbr>s));<br>
                  +  SmallVector<Metadata *, 3> Vals;<br>
                  +  Vals.push_back(ProfileData->ge<wbr>tOperand(0));<br>
                  +  APInt APS(128, S), APT(128, T);<br>
                  +  if (ProfDataName->getString().equ<wbr>als("branch_weights"))<br>
                  +    for (unsigned i = 1; i <
                  ProfileData->getNumOperands(); i++) {<br>
                  +      // Using APInt::div may be expensive, but most
                  cases should fit 64 bits.<br>
                  +      APInt Val(128,<br>
                  +                mdconst::dyn_extract<ConstantI<wbr>nt>(ProfileData->getOperand(i)<wbr>)<br>
                  +                    ->getValue()<br>
                  +                    .getZExtValue());<br>
                  +      Val *= APS;<br>
                  +      Vals.push_back(MDB.createConst<wbr>ant(<br>
                  +          ConstantInt::get(Type::getInt6<wbr>4Ty(getContext()),<br>
                  +                           Val.udiv(APT).getLimitedValue<wbr>())));<br>
                  +    }<br>
                  +  else if (ProfDataName->getString().equ<wbr>als("VP"))<br>
                  +    for (unsigned i = 1; i <
                  ProfileData->getNumOperands(); i += 2) {<br>
                  +      // The first value is the key of the value
                  profile, which will not change.<br>
                  +      Vals.push_back(ProfileData->ge<wbr>tOperand(i));<br>
                  +      // Using APInt::div may be expensive, but most
                  cases should fit 64 bits.<br>
                  +      APInt Val(128,<br>
                  +                mdconst::dyn_extract<ConstantI<wbr>nt>(ProfileData->getOperand(i
                  + 1))<br>
                  +                    ->getValue()<br>
                  +                    .getZExtValue());<br>
                  +      Val *= APS;<br>
                  +      Vals.push_back(MDB.createConst<wbr>ant(<br>
                  +          ConstantInt::get(Type::getInt6<wbr>4Ty(getContext()),<br>
                  +                           Val.udiv(APT).getLimitedValue<wbr>())));<br>
                  +    }<br>
                  +  setMetadata(LLVMContext::MD_pr<wbr>of,
                  MDNode::get(getContext(), Vals));<br>
                    }<br>
                      void Instruction::setProfWeight(uin<wbr>t64_t W) {<br>
                  <br>
                  Modified: llvm/trunk/test/Transforms/Inl<wbr>ine/prof-update.ll<br>
                  URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/prof-update.ll?rev=302209&r1=302208&r2=302209&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/test/Transfor<wbr>ms/Inline/prof-update.ll?rev=3<wbr>02209&r1=302208&r2=302209&view<wbr>=diff</a><br>
                  ==============================<wbr>==============================<wbr>==================<br>
                  --- llvm/trunk/test/Transforms/Inl<wbr>ine/prof-update.ll
                  (original)<br>
                  +++ llvm/trunk/test/Transforms/Inl<wbr>ine/prof-update.ll
                  Thu May  4 19:47:34 2017<br>
                  @@ -3,6 +3,7 @@<br>
                      declare void @ext();<br>
                    declare void @ext1();<br>
                  +@func = global void ()* null<br>
                      ; CHECK: define void @callee(i32 %n) !prof
                  ![[ENTRY_COUNT:[0-9]*]]<br>
                    define void  @callee(i32 %n) !prof !1 {<br>
                  @@ -17,12 +18,16 @@ cond_false:<br>
                    ; ext is cloned and updated.<br>
                    ; CHECK: call void @ext(), !prof
                  ![[COUNT_CALLEE:[0-9]*]]<br>
                      call void @ext(), !prof !2<br>
                  +  %f = load void ()*, void ()** @func<br>
                  +; CHECK: call void %f(), !prof
                  ![[COUNT_IND_CALLEE:[0-9]*]]<br>
                  +  call void %f(), !prof !4<br>
                      ret void<br>
                    }<br>
                      ; CHECK: define void @caller()<br>
                    define void @caller() {<br>
                    ; CHECK: call void @ext(), !prof
                  ![[COUNT_CALLER:[0-9]*]]<br>
                  +; CHECK: call void %f.i(), !prof
                  ![[COUNT_IND_CALLER:[0-9]*]]<br>
                      call void @callee(i32 15), !prof !3<br>
                      ret void<br>
                    }<br>
                  @@ -32,8 +37,11 @@ define void @caller() {<br>
                    !1 = !{!"function_entry_count", i64 1000}<br>
                    !2 = !{!"branch_weights", i64 2000}<br>
                    !3 = !{!"branch_weights", i64 400}<br>
                  +!4 = !{!"VP", i32 0, i64 140, i64 111, i64 80, i64
                  222, i64 40, i64 333, i64 20}<br>
                    attributes #0 = { alwaysinline }<br>
                    ; CHECK: ![[ENTRY_COUNT]] =
                  !{!"function_entry_count", i64 600}<br>
                    ; CHECK: ![[COUNT_CALLEE1]] = !{!"branch_weights",
                  i64 2000}<br>
                  -; CHECK: ![[COUNT_CALLEE]] = !{!"branch_weights", i32
                  1200}<br>
                  -; CHECK: ![[COUNT_CALLER]] = !{!"branch_weights", i32
                  800}<br>
                  +; CHECK: ![[COUNT_CALLEE]] = !{!"branch_weights", i64
                  1200}<br>
                  +; CHECK: ![[COUNT_IND_CALLEE]] = !{!"VP", i32 0, i64
                  84, i64 111, i64 48, i64 222, i64 24, i64 333, i64 12}<br>
                  +; CHECK: ![[COUNT_CALLER]] = !{!"branch_weights", i64
                  800}<br>
                  +; CHECK: ![[COUNT_IND_CALLER]] = !{!"VP", i32 0, i64
                  56, i64 111, i64 32, i64 222, i64 16, i64 333, i64 8}<br>
                  <br>
                  <br>
                  ______________________________<wbr>_________________<br>
                  llvm-commits mailing list<br>
                  <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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/<wbr>mailman/listinfo/llvm-commits</a><br>
                </blockquote>
                <br>
                <br>
                ______________________________<wbr>_________________<br>
                llvm-commits mailing list<br>
                <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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/<wbr>mailman/listinfo/llvm-commits</a><br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <div class="m_3995847052723939642m_2022698915543435463gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium">
            <table cellspacing="0" cellpadding="0">
              <tbody>
                <tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small">
                  <td style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px" nowrap>Teresa Johnson |</td>
                  <td style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px" nowrap> Software Engineer |</td>
                  <td style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px" nowrap> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td>
                  <td style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px" nowrap> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td>
                </tr>
              </tbody>
            </table>
          </span></div>
      </div>
    </blockquote>
    <p><br>
    </p>
  </div></div></div>

</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_3995847052723939642gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 408-460-2413</td></tr></tbody></table></span></div>
</div>