https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26461
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |torvald at gcc dot gnu.org --- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Even if we have an option that avoids CSE of TLS addresses across function calls (or attribute for specific function), what would you expect to happen when user takes address of TLS variables himself: __thread int a; void foo () { int *p = &a; *p = 10; bar (); // Changes threads *p += 10; } ? The address can be stored anywhere, so the compiler can't do anything with it. And of course such an option would cause major slowdown of anything using TLS, not only it would need to stop CSEing TLS addresses late, but stop treating TLS addresses as constant in all early optimizations as well.