From 5149a31515f2bb1ae9c1923acdc80b82531ad52b Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 22 Apr 2026 00:09:41 +0200 Subject: [PATCH] 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. --- compiler/rustc_codegen_llvm/src/va_arg.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index 931f8bae1acd..be1733086c83 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -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)], ) }