Closed nikic closed 5 months ago
Rust: https://rust.godbolt.org/z/z4fsMK7sf Clang (and GCC): https://clang.godbolt.org/z/c3j4h4faP
The struct in question is:
#[repr(C)]
#[repr(align(16))]
pub struct TwoU64s {
pub a: u64,
pub b: u64,
}
Rust passes it as [2 x i64]
, while clang passes it as [1 x i128]
. The GCC behavior appears to agree with Clang.
cc @erikdesjardins because I know how much you love ABI bugs related to overaligned structs :P
I think the problem is that Rust hardcodes the use of i64 here: https://github.com/rust-lang/rust/blob/b7dcabe55e3b915ba9488dc374f752404c2c8945/compiler/rustc_target/src/abi/call/powerpc64.rs#L116-L119
While Clang makes it dependent on the ABI alignment: https://github.com/llvm/llvm-project/blob/fe2119a7b08b6e468b2a67768904ea85b1bf0a45/clang/lib/CodeGen/Targets/PPC.cpp#L878-L884
Wow, apparently passing i128
and [1 x i128]
has different ABI: https://llvm.godbolt.org/z/beM6j8Yhs
The Rust cast ABI currently assumes that these are the same thing and will always pass a single-element Uniform as a scalar rather than array...
The test fails with assertion:
This is the case at least on 1.76 and 1.77, haven't checked other versions. cc @cuviper
Full error: