[llvm-bugs] [Bug 41722] New: Poor optimization of thread local globals on OSX
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu May 2 20:59:08 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41722
Bug ID: 41722
Summary: Poor optimization of thread local globals on OSX
Product: new-bugs
Version: 8.0
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: tyler.m.kopf at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org
Multiple calls to tlv_get_addr are (often) generated per usage of a thread
local variable on OSX. This issue was discovered by looking at the assembly
generated by rustc, and is discussed in more detail here:
https://github.com/rust-lang/rust/pull/60341#issuecomment-487982828
I know very little about llvm - so hopefully this all makes sense. The linked
IR [1] demonstrates the issue. Often, the optimizer spits out IR which
references thread_local globals multiple times when the unoptimized IR only
references them once. Often associated with getelementptr.
In the final assembly the asm does the tlv_get_addr dance twice.
movq _foo at TLVP(%rip), %rdi
callq *(%rdi)
For larger structures with multiple members, the problem gets worse, resulting
in many redundant calls to tlv_get_addr. In contrast, when targeting linux,
__tls_get_addr at PLT, is only invoked once.
Maybe there's a good reason the address isn't cached on OSX, but I'm hoping
there isn't :).
[1]: https://gist.github.com/alexcrichton/a9a90412152d04caa7011042aa89b6bf
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190503/4b03017f/attachment.html>
More information about the llvm-bugs
mailing list