Use the aligned size for alloca at args when the pass mode is cast.

The `load` and `store` instructions in LLVM access the aligned size.
This commit is contained in:
DianQK 2024-06-30 21:33:46 +08:00
parent 09e0abb0d1
commit c453dcd62a
No known key found for this signature in database
5 changed files with 21 additions and 31 deletions

View file

@ -226,7 +226,8 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
// when passed by value, making it smaller.
// - On some ABIs, the Rust layout { u16, u16, u16 } may be padded up to 8 bytes
// when passed by value, making it larger.
let copy_bytes = cmp::min(scratch_size.bytes(), self.layout.size.bytes());
let copy_bytes =
cmp::min(cast.unaligned_size(bx).bytes(), self.layout.size.bytes());
// Allocate some scratch space...
let llscratch = bx.alloca(scratch_size, scratch_align);
bx.lifetime_start(llscratch, scratch_size);