http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52268
Iain Sandoe <iains at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2012-02-16 Ever Confirmed|0 |1 --- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> 2012-02-16 18:53:33 UTC --- somewhat different from the output generated, for example for x86-64-unk-linux (-fPIC). .... this is what clang version 3.1 (trunk 150612) : gives. $ cat ../tests/thr-0.c int foo (int f) { static __thread int ff ; ff += f; return ff; } $ ./install/bin/clang ../tests/thr-0.c -target x86_64-apple-darwin11 -S $ more thr-0.s .section __TEXT,__text,regular,pure_instructions .globl _foo .align 4, 0x90 _foo: ## @foo .cfi_startproc ## BB#0: ## %entry pushq %rbp Ltmp2: .cfi_def_cfa_offset 16 Ltmp3: .cfi_offset %rbp, -16 movq %rsp, %rbp Ltmp4: .cfi_def_cfa_register %rbp subq $16, %rsp movl %edi, -4(%rbp) movl %edi, -8(%rbp) ## 4-byte Spill movq _foo.ff@TLVP(%rip), %rdi callq *(%rdi) movl (%rax), %ecx movl -8(%rbp), %edx ## 4-byte Reload addl %edx, %ecx movl %ecx, (%rax) movl %ecx, %eax addq $16, %rsp popq %rbp ret .cfi_endproc .tbss _foo.ff$tlv$init, 4, 2 ## @foo.ff .section __DATA,__thread_vars,thread_local_variables _foo.ff: .quad __tlv_bootstrap .quad 0 .quad _foo.ff$tlv$init .subsections_via_symbols ===== $ ./install/bin/clang ../tests/thr-0.c -target i686-apple-darwin11 -S $ more thr-0.s .section __TEXT,__text,regular,pure_instructions .globl _foo .align 4, 0x90 _foo: ## @foo ## BB#0: ## %entry pushl %ebp movl %esp, %ebp subl $8, %esp calll L0$pb L0$pb: popl %eax movl 8(%ebp), %ecx movl %ecx, -4(%ebp) movl _foo.ff@TLVP-L0$pb(%eax), %eax movl %ecx, -8(%ebp) ## 4-byte Spill calll *(%eax) movl (%eax), %ecx movl -8(%ebp), %edx ## 4-byte Reload addl %edx, %ecx movl %ecx, (%eax) movl %ecx, %eax addl $8, %esp popl %ebp ret .tbss _foo.ff$tlv$init, 4, 2 ## @foo.ff .section __DATA,__thread_vars,thread_local_variables _foo.ff: .long __tlv_bootstrap .long 0 .long _foo.ff$tlv$init .subsections_via_symbols === $ cat ../tests/thr-1.c int foo (int f) { static __thread int ff = 1234; ff += f; return ff; } ... much the same except popq %rbp ret .cfi_endproc .section __DATA,__thread_data,thread_local_regular .align 2 ## @foo.ff _foo.ff$tlv$init: .long 1234 ## 0x4d2 .section __DATA,__thread_vars,thread_local_variables _foo.ff: .quad __tlv_bootstrap .quad 0 .quad _foo.ff$tlv$init --- and popl %ebp ret .section __DATA,__thread_data,thread_local_regular .align 2 ## @foo.ff _foo.ff$tlv$init: .long 1234 ## 0x4d2 .section __DATA,__thread_vars,thread_local_variables _foo.ff: .long __tlv_bootstrap .long 0 .long _foo.ff$tlv$init