This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82803] New: Wildly excessive calls to __tls_get_addr with optimizations enabled.
- From: "amohr at amohr dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 02 Nov 2017 06:09:32 +0000
- Subject: [Bug c++/82803] New: Wildly excessive calls to __tls_get_addr with optimizations enabled.
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82803
Bug ID: 82803
Summary: Wildly excessive calls to __tls_get_addr with
optimizations enabled.
Product: gcc
Version: 7.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: amohr at amohr dot org
Target Milestone: ---
gcc emits a call to __tls_get_addr for every iteration of the while loop below
at -O1 or above. It does not happen at -O0.
static thread_local int x;
int g();
int f(int c) {
int *px = &x;
while (c--)
*px =+ g();
return *px;
}
Compile with: -O2 -std=c++11 -fPIC -Wall -Wextra
I tried it with several versions back to 4.8.2 with the same results. At -O0
exactly one call is emitted. Seems like the optimizer is doing something silly
with thread_locals.
https://godbolt.org/g/S9hvHQ