Skip to content

aarch64: Failure to handle PSTATE.SM & ZA for tlsdesc calls #152165

@pinskia

Description

@pinskia

Turns out LLVM has the same issue as GCC here (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121415).
For:

extern __thread int x;
int f() __arm_streaming_compatible { return x; }

compiled with -O2 -fPIC, we get:

f():                                  // @f()
        .cfi_startproc
// %bb.0:
        stp     x29, x30, [sp, #-16]!           // 16-byte Folded Spill
        .cfi_def_cfa_offset 16
        mov     x29, sp
        .cfi_def_cfa w29, 16
        .cfi_offset w30, -8
        .cfi_offset w29, -16
        adrp    x0, :tlsdesc:x
        ldr     x1, [x0, :tlsdesc_lo12:x]
        add     x0, x0, :tlsdesc_lo12:x
        .tlsdesccall x
        blr     x1
        mrs     x8, TPIDR_EL0
        ldr     w0, [x8, x0]
        .cfi_def_cfa wsp, 16
        ldp     x29, x30, [sp], #16             // 16-byte Folded Reload
        .cfi_def_cfa_offset 0
        .cfi_restore w30
        .cfi_restore w29
        ret

which fails to force non-streaming mode around the call. A function with ZA or ZT0 state would also need to handle that.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions