public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/99619] New: fails to infer local-dynamic TLS model from hidden visibility
@ 2021-03-16 15:29 amonakov at gcc dot gnu.org
2021-03-16 15:36 ` [Bug middle-end/99619] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: amonakov at gcc dot gnu.org @ 2021-03-16 15:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99619
Bug ID: 99619
Summary: fails to infer local-dynamic TLS model from hidden
visibility
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: amonakov at gcc dot gnu.org
Target Milestone: ---
Thread-local variables with hidden visibility don't need to use the
"general-dynamic" TLS model: they can use "local-dynamic" model, which is more
efficient when more than one variable is accessed. This is documented in "ELF
handling for thread-local storage".
Testcase:
__attribute__((visibility("hidden")))
extern __thread int a, b;
int f()
{
return a + b;
}
clang -O2 -fpic emits:
f:
.cfi_startproc
push rax
.cfi_def_cfa_offset 16
lea rdi, [rip + a@TLSLD]
call __tls_get_addr@PLT
mov rcx, rax
mov eax, dword ptr [rax + b@DTPOFF]
add eax, dword ptr [rcx + a@DTPOFF]
pop rcx
.cfi_def_cfa_offset 8
ret
gcc -O2 -fpic emits:
f:
.cfi_startproc
push rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
data16 lea rdi, a@tlsgd[rip]
.value 0x6666
rex64
call __tls_get_addr@PLT
mov rbx, rax
data16 lea rdi, b@tlsgd[rip]
.value 0x6666
rex64
call __tls_get_addr@PLT
mov eax, DWORD PTR [rax]
add eax, DWORD PTR [rbx]
pop rbx
.cfi_def_cfa_offset 8
ret
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/99619] fails to infer local-dynamic TLS model from hidden visibility
2021-03-16 15:29 [Bug middle-end/99619] New: fails to infer local-dynamic TLS model from hidden visibility amonakov at gcc dot gnu.org
@ 2021-03-16 15:36 ` pinskia at gcc dot gnu.org
2022-10-20 17:52 ` cvs-commit at gcc dot gnu.org
2022-10-20 17:53 ` amonakov at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-03-16 15:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99619
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/99619] fails to infer local-dynamic TLS model from hidden visibility
2021-03-16 15:29 [Bug middle-end/99619] New: fails to infer local-dynamic TLS model from hidden visibility amonakov at gcc dot gnu.org
2021-03-16 15:36 ` [Bug middle-end/99619] " pinskia at gcc dot gnu.org
@ 2022-10-20 17:52 ` cvs-commit at gcc dot gnu.org
2022-10-20 17:53 ` amonakov at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-20 17:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99619
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Alexander Monakov <amonakov@gcc.gnu.org>:
https://gcc.gnu.org/g:1d561e1851c466a4952081caef17747781609b00
commit r13-3416-g1d561e1851c466a4952081caef17747781609b00
Author: Artem Klimov <jakmobius@gmail.com>
Date: Wed Jul 6 17:02:01 2022 +0300
ipa-visibility: Optimize TLS access [PR99619]
Fix PR99619, which asks to optimize TLS model based on visibility.
The fix is implemented as an IPA optimization: this allows to take
optimized visibility status into account (as well as avoid modifying
all language frontends).
2022-04-17 Artem Klimov <jakmobius@gmail.com>
gcc/ChangeLog:
PR middle-end/99619
* ipa-visibility.cc (function_and_variable_visibility): Promote
TLS access model afer visibility optimizations.
* varasm.cc (have_optimized_refs): New helper.
(optimize_dyn_tls_for_decl_p): New helper. Use it ...
(decl_default_tls_model): ... here in place of 'optimize' check.
gcc/testsuite/ChangeLog:
PR middle-end/99619
* gcc.dg/tls/vis-attr-gd.c: New test.
* gcc.dg/tls/vis-attr-hidden-gd.c: New test.
* gcc.dg/tls/vis-attr-hidden.c: New test.
* gcc.dg/tls/vis-flag-hidden-gd.c: New test.
* gcc.dg/tls/vis-flag-hidden.c: New test.
* gcc.dg/tls/vis-pragma-hidden-gd.c: New test.
* gcc.dg/tls/vis-pragma-hidden.c: New test.
Co-Authored-By: Alexander Monakov <amonakov@gcc.gnu.org>
Signed-off-by: Artem Klimov <jakmobius@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/99619] fails to infer local-dynamic TLS model from hidden visibility
2021-03-16 15:29 [Bug middle-end/99619] New: fails to infer local-dynamic TLS model from hidden visibility amonakov at gcc dot gnu.org
2021-03-16 15:36 ` [Bug middle-end/99619] " pinskia at gcc dot gnu.org
2022-10-20 17:52 ` cvs-commit at gcc dot gnu.org
@ 2022-10-20 17:53 ` amonakov at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: amonakov at gcc dot gnu.org @ 2022-10-20 17:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99619
Alexander Monakov <amonakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #2 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Fixed for gcc-13.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-20 17:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 15:29 [Bug middle-end/99619] New: fails to infer local-dynamic TLS model from hidden visibility amonakov at gcc dot gnu.org
2021-03-16 15:36 ` [Bug middle-end/99619] " pinskia at gcc dot gnu.org
2022-10-20 17:52 ` cvs-commit at gcc dot gnu.org
2022-10-20 17:53 ` amonakov at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).