* Stefan Hajnoczi: > I'm basically asking whether the &tls_var input operand is treated as > volatile and part of the inline assembly or whether it's just regular > C code that the compiler may optimize with the surrounding function?
&tls_var is evaluated outside of the inline assembly, any compiler barrier will come after that. It's subject to CSE (or whatever it's called. Three asm statements in a row asm volatile("" : "=r"(dst_ptr) : "0"(&tls_var)); asm volatile("" : "=r"(dst_ptr) : "0"(&tls_var)); asm volatile("" : "=r"(dst_ptr) : "0"(&tls_var)); result in movq tls_var@gottpoff(%rip), %rax addq %fs:0, %rax movq %rax, %rdx movq %rax, %rdx which is probably not what you want. Thanks, Florian