-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed as duplicate of#41987
Closed as duplicate of#41987
Copy link
Labels
ABIApplication Binary InterfaceApplication Binary Interfaceclang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.duplicateResolved as duplicateResolved as duplicate
Description
Consider:
#include <cstddef>
#include <type_traits>
struct S {
std::nullptr_t n;
};
static_assert(std::is_trivially_copyable_v<S>);
S foo() {
return {};
}Observed behavior
clang 19.1.0 x86_64 returns on return slot:
foo():
mov rax, rdi
mov qword ptr [rdi], 0
retIn comparison gcc 14.2 returns in register:
foo():
xor eax, eax
rethttps://godbolt.org/z/vaqxYoKTW
Expected behavior
The calling convention on gcc and clang to agree. S is not "non-trivial for the purpose of calls" in the Itanium ABI, therefore it should be returned in registers here.
Note
For std::nullptr_t f() { return {}; } clang correctly returns in a register.
Metadata
Metadata
Assignees
Labels
ABIApplication Binary InterfaceApplication Binary Interfaceclang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.duplicateResolved as duplicateResolved as duplicate