https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80881

--- Comment #10 from Liu Hao <lh_mouse at 126 dot com> ---
Compiling this rather simple program using your gcc:

```
__thread int a = 1;

int get_a(void){
   return a;
}
```

resulted in wrong assembly:

```
E:\Desktop\gcc-7.1.0-debug-broken-tls\bin>gcc E:\Desktop\test.c -S -masm=intel
-O2 -o -
        .file   "test.c"
        .intel_syntax noprefix
        .text
        .p2align 4,,15
        .globl  get_a
        .def    get_a;  .scl    2;      .type   32;     .endef
        .seh_proc       get_a
get_a:
        .seh_endprologue
        mov     rax, QWORD PTR fs:0
        mov     eax, DWORD PTR a@tpoff[rax]
        ret
        .seh_endproc
        .globl  a
        .data
        .align 4
a:
        .long   1
        .ident  "GCC: (GNU) 7.1.0"
```

With my working GCC it resulted in:

```
E:\Desktop>gcc E:\Desktop\test.c -S -masm=intel -O2 -o -
        .file   "test.c"
        .intel_syntax noprefix
        .text
        .globl  get_a
        .def    get_a;  .scl    2;      .type   32;     .endef
        .seh_proc       get_a
get_a:
        sub     rsp, 40
        .seh_stackalloc 40
        .seh_endprologue
        lea     rcx, __emutls_v.a[rip]
        call    __emutls_get_address
        mov     eax, DWORD PTR [rax]
        add     rsp, 40
        ret
        .seh_endproc
        .section .rdata,"dr"
        .align 4
__emutls_t.a:
        .long   1
        .globl  __emutls_v.a
        .data
        .align 32
__emutls_v.a:
        .quad   4
        .quad   4
        .quad   0
        .quad   __emutls_t.a
        .ident  "GCC: (gcc-7-branch HEAD with MCF thread model, built by
LH_Mouse.) 7.2.1 20171119"
        .def    __emutls_get_address;   .scl    2;      .type   32;     .endef
```

Reply via email to