diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2025-07-27 23:05:22 +0200 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2025-08-31 16:07:28 +0200 |
| commit | 002751155d135de7ef6cfd88404f2bd2b7983b51 (patch) | |
| tree | ee07c5658c7743fbfc51df2de72d969befb56d62 /compiler | |
| parent | 1bc901e0cab0f150e3bcdb9e7cf99ab085682b3e (diff) | |
| download | rust-002751155d135de7ef6cfd88404f2bd2b7983b51.tar.gz rust-002751155d135de7ef6cfd88404f2bd2b7983b51.zip | |
round pointer to alignment without going via int
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/va_arg.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index ce079f3cb0a..7eb5d302058 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -28,9 +28,12 @@ fn round_pointer_up_to_alignment<'ll>( align: Align, ptr_ty: &'ll Type, ) -> &'ll Value { - let mut ptr_as_int = bx.ptrtoint(addr, bx.cx().type_isize()); - ptr_as_int = round_up_to_alignment(bx, ptr_as_int, align); - bx.inttoptr(ptr_as_int, ptr_ty) + let ptr = bx.inbounds_ptradd(addr, bx.const_i32(align.bytes() as i32 - 1)); + bx.call_intrinsic( + "llvm.ptrmask", + &[ptr_ty, bx.type_i32()], + &[ptr, bx.const_int(bx.isize_ty, -(align.bytes() as isize) as i64)], + ) } fn emit_direct_ptr_va_arg<'ll, 'tcx>( |
