http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066

--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
Another problem:

[hjl@gnu-6 gcc]$ cat /tmp/c.i 
static __thread char ccc;

void* __cxa_get_globals()
{
 return &ccc;
}
[hjl@gnu-6 gcc]$ ./xgcc -B./ -S -O2 -fPIC /tmp/c.i 
[hjl@gnu-6 gcc]$ cat /tmp/c.i 
static __thread char ccc;

void* __cxa_get_globals()
{
 return &ccc;
}
[hjl@gnu-6 gcc]$ ./xgcc -B./ -S -O2 -fPIC /tmp/c.i  -m32
[hjl@gnu-6 gcc]$ cat c.s
    .file    "c.i"
    .section    .text.unlikely,"ax",@progbits
.LCOLDB0:
    .text
.LHOTB0:
    .p2align 4,,15
    .globl    __cxa_get_globals
    .type    __cxa_get_globals, @function
__cxa_get_globals:
.LFB0:
    .cfi_startproc
    pushl    %ebx
    .cfi_def_cfa_offset 8
    .cfi_offset 3, -8
    call    __x86.get_pc_thunk.bx
    addl    $_GLOBAL_OFFSET_TABLE_, %ebx
    subl    $8, %esp
    .cfi_def_cfa_offset 16
    addl    $8, %esp
    .cfi_def_cfa_offset 8
    leal    ccc@tlsgd(,%ebx,1), %eax
    call    ___tls_get_addr@PLT
    popl    %ebx
    .cfi_restore 3
    .cfi_def_cfa_offset 4
    ret
    .cfi_endproc
.LFE0:
    .size    __cxa_get_globals, .-__cxa_get_globals

sched2 doesn't know

(insn:TI 15 25 13 2 (parallel [
            (set (reg:SI 0 ax [86])
                (unspec:SI [
                        (reg:SI 3 bx)
                        (symbol_ref:SI ("ccc") [flags 0x1a]  <var_decl
0x7f2b2be
5e980 ccc>)
                        (symbol_ref:SI ("___tls_get_addr"))
                    ] UNSPEC_TLS_GD))
            (clobber (reg:SI 1 dx [88]))
            (clobber (reg:SI 2 cx [89]))
            (clobber (reg:CC 17 flags))
        ]) /tmp/c.i:5 772 {*tls_global_dynamic_32_gnu}
     (expr_list:REG_DEAD (reg:SI 3 bx)
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (expr_list:REG_UNUSED (reg:SI 2 cx [89])
                (expr_list:REG_UNUSED (reg:SI 1 dx [88])
                    (expr_list:REG_EQUIV (unspec:SI [
                                (reg:SI 3 bx)
                                (symbol_ref:SI ("ccc") [flags 0x1a]  <var_decl
0
x7f2b2be5e980 ccc>)
                                (symbol_ref:SI ("___tls_get_addr"))
                            ] UNSPEC_TLS_GD)
                        (nil)))))))

is a function call and move stack adjustment cross it.

Reply via email to