Skip to content

Clang: 64-bit SPARC doesn't align struct arguments as required by ABI #144709

Open
@beetrees

Description

@beetrees

The 64-bit SPARC calling convention states:

Structure or union types larger than eight bytes, and up to sixteen bytes in size are assigned to two consecutive
parameter array words, and align according to the alignment requirements of the structure or at least to an eight-byte
boundary.

However, Clang fails to correctly align structs when passed by value. For instance, in this example:

struct Struct { _Alignas(16) int x; };

void bar(int pad, struct Struct value);

void foo(struct Struct input) {
    bar(0, input);
}

Clang incorrectly passes value 8-aligned in o1 and o2, whereas GCC correctly 16-aligns it and therefore passes it in o2 and o3 (compiler explorer).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions