<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Bogus __llvm_profile_data for __llvm_profile_runtime_user"
   href="https://bugs.llvm.org/show_bug.cgi?id=38340">38340</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bogus __llvm_profile_data for __llvm_profile_runtime_user
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dmajor@mozilla.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>davidxl@google.com, llvm-bugs@lists.llvm.org, rnk@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>A PGO-instrumented DLL on Windows has static initializers that go like:

00007ffa`4eb1e234 488d0de5ffffff  lea     rcx,[nss3!_llvm_profile_runtime_user
(00007ffa`4eb1e220)]
00007ffa`4eb1e23b e820ab0e00      call    nss3!__llvm_profile_register_function
(00007ffa`4ec08d60)
00007ffa`4eb1e240 488d0db9ec1800  lea     rcx,[nss3!_profd_sprintf
(00007ffa`4ecacf00)]
00007ffa`4eb1e247 e814ab0e00      call    nss3!__llvm_profile_register_function
(00007ffa`4ec08d60)
00007ffa`4eb1e24c 488d0dddec1800  lea     rcx,[nss3!_profd_vsprintf
(00007ffa`4ecacf30)]
00007ffa`4eb1e253 e808ab0e00      call    nss3!__llvm_profile_register_function
(00007ffa`4ec08d60)
[...many more...]

The ones for sprintf and friends look fine, but the registration for
__llvm_profile_runtime_user contains garbage:

0:000> dt nss3!__llvm_profile_data 00007ffa`4eb1e220
   +0x000 NameRef          : 0xccc30013`514a058b
   +0x008 FuncHash         : 0xcccccccc`cccccccc
   +0x010 CounterPtr       : 0xe50d8d48`28ec8348 Void
   +0x018 FunctionPointer  : 0x000eab20`e8ffffff Void
   +0x020 Values           : 0xe80018ec`b90d8d48 Void
   +0x028 NumCounters      : 0xeab14
   +0x02c NumValueSites    : [2] 0x8d48

I'm not even sure if __llvm_profile_runtime_user is supposed to be registered
here at all. It's not a __profd_... thing.

The list of registrations seems to come from `for (Value *Data : UsedVars)` in
<a href="http://llvm-cs.pcc.me.uk/lib/Transforms/Instrumentation/InstrProfiling.cpp#899">http://llvm-cs.pcc.me.uk/lib/Transforms/Instrumentation/InstrProfiling.cpp#899</a>

But there's a special case for `if (Data != NamesVar)` which suggests that
maybe not everything in `UsedVars` should be registered as a function.

Looking at the callers of `UsedVars.push_back`:
<a href="http://llvm-cs.pcc.me.uk/include/llvm/Transforms/Instrumentation/InstrProfiling.h/rUsedVars">http://llvm-cs.pcc.me.uk/include/llvm/Transforms/Instrumentation/InstrProfiling.h/rUsedVars</a>

Maybe `VNodesVar` and `User` should be avoided in that for-loop too?</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>