Skip to content

[ARM32] Empty structs are ignored when passing in C++ #98159

Closed
@tomeksowi

Description

@tomeksowi

Problem similar to #97285, opening new issue since the RISC-V one is closed. I'm less familiar with ARM32 so I can't point to the ABI wording that specifies empty struct handling.

struct Empty {};

int after_empty(int i0, Empty e, int i1)
{
	return i1;
}

int after_empty_on_stack(
    int i0, int i1, int i2, int i3, int i4, int i5, int i6, int i7, Empty e, int i8)
{
	return i8;
}
after_empty(int, Empty, int):
        mov     r0, r1
        bx      lr
after_empty_on_stack(int, int, int, int, int, int, int, int, Empty, int):
        ldr     r0, [sp, #16]
        bx      lr

GCC passes i1 and i8 in r2 and [sp, #20] respectively. Comparison on Godbolt
ARM64 on Clang looks ok, it matches GCC and passes i1 in w2

Clang version: 18.1.0 and Godbolt "trunk" at the time of filing this issue (2024-07-09).

cc @svs-quic @efriedma-quic
Part of dotnet/runtime#84834

Metadata

Metadata

Assignees

Labels

ABIApplication Binary Interfacebackend:ARM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions