https://bugs.llvm.org/show_bug.cgi?id=38340

            Bug ID: 38340
           Summary: Bogus __llvm_profile_data for
                    __llvm_profile_runtime_user
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

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
http://llvm-cs.pcc.me.uk/lib/Transforms/Instrumentation/InstrProfiling.cpp#899

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`:
http://llvm-cs.pcc.me.uk/include/llvm/Transforms/Instrumentation/InstrProfiling.h/rUsedVars

Maybe `VNodesVar` and `User` should be avoided in that for-loop too?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to