Codegen backends should validate their assumed encodings of e.g. rustc layouts. #105282
Labels
A-codegen
Area: Code generation
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Specifically the thing that came to mind is that
rustc_codegen_llvm
could assertLLVMSizeOf
matches therustc
Layout
every time it builds a LLVM type from a layout.(and this should hopefully be cheap enough that we could always have it enabled)
(I generally dislike debug asserts as they can't be relied upon to enforce soundness...)
The motivating example is a discussion around a
#[repr(simd)] struct i32x3([i32; 3]);
type having size 12:<3 x i32>
is 16 bytes, so that would be illegal#[repr(packed)]
doesn't seem to do anything today, in combination with#[repr(simd)]
, so you couldn't get the 12-byte layout without changing e.g. thevector_align
algorithm in the compiler)I'm unsure about the GCC backend but presumably it should also be able to do this? (cc @antoyo)
cc @rust-lang/wg-llvm @bjorn3
The text was updated successfully, but these errors were encountered: