https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80258
--- Comment #9 from Tor Myklebust <tmyklebu at gmail dot com> --- OK, I gather that the gcc developers, as a group, are against changing this behaviour. (I can speculate why; almost all code that uses TLS will see a slowdown.) In order to work around this behaviour, one needs a way to tell gcc that %fs:0 may have been modified. I don't see a way to do this. None of the following hacks, if placed before and after the call to something(), produce a desirable result: - asm volatile("":::"memory"); no change in output. - asm volatile("":::"fs"); unknown register name 'fs' in 'asm'. - asm volatile("":::"%fs"); unknown register name '%fs' in 'asm'. - __seg_fs uintptr_t *hack = 0; asm volatile("" : "+r"(hack) :: "memory"); no change in behaviour, though the TLS region pointer at %fs:0 gets roundtripped through %rax.