change llvm.ptrmask argument to isize

we were saying that the type is i32, but would often provide an i64.
That never failed so far, but starts failing (like, crashing LLVM) when
working with 128-bit values that are 16-byte aligned. So, we may as well
use the more robust approach now.
This commit is contained in:
Folkert de Vries
2026-04-22 00:09:41 +02:00
parent 45f98b9aa7
commit 5149a31515
+4 -2
View File
@@ -29,10 +29,12 @@ fn round_pointer_up_to_alignment<'ll>(
align: Align,
) -> &'ll Value {
let ptr = bx.inbounds_ptradd(addr, bx.const_i32(align.bytes() as i32 - 1));
let pointer_width = bx.tcx().sess.target.pointer_width;
let mask = align.bytes().wrapping_neg() & (u64::MAX >> (64 - pointer_width));
bx.call_intrinsic(
"llvm.ptrmask",
&[bx.type_ptr(), bx.type_i32()],
&[ptr, bx.const_int(bx.isize_ty, -(align.bytes() as isize) as i64)],
&[bx.type_ptr(), bx.type_isize()],
&[ptr, bx.const_usize(mask)],
)
}