Skip to content

[AArch64] atomic operations with syncscope::SingleThread conservatively lower to proper atomics #114580

@gbaraldi

Description

@gbaraldi

I.e

define void @foo(ptr nonnull %myptr) {
top:
  store atomic i64 320, ptr %myptr syncscope("singlethread") release, align 8
  ret void
}

lowers to

_foo:                          ; @foo
        mov     w8, #320                        ; =0x140
        stlr    x8, [x0]
        ret

This seems pessimistic given that

define void @bar(ptr nonnull %myptr) {
top:
  store i64 320, ptr %myptr, align 8
  fence syncscope("singlethread") release
  ret void
}

Lowers to

_bar:                                   ; @bar
        mov     w8, #320                        ; =0x140
        str     x8, [x0]
        ret

I believe this requires a change in

if (SI->isAtomic()) {
AtomicOrdering Ord = SI->getOrdering();
// The non-atomic instructions are sufficient for relaxed stores.
if (isReleaseOrStronger(Ord)) {
// The STLR addressing mode only supports a base reg; pass that directly.
Register AddrReg = getRegForValue(PtrV);
return emitStoreRelease(VT, SrcReg, AddrReg,
createMachineMemOperandFor(I));
}
}
but I'm not familiar enough with llvm backend specifics

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions