From 8d68e71c86cdf63aececf92c9c93992a32d357f6 Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Thu, 7 Aug 2025 18:11:29 -0400 Subject: [PATCH] Remove incorrect pointer cast in `volatile_load` intrinsic The PassMode::Cast check was incorrectly casting the input pointer based on the return value's ABI mode. This is wrong because `volatile_load` reads raw memory at the pointer's target type...any ABI transformations should happen after loading, not on the pointer itself. --- crates/rustc_codegen_nvvm/src/intrinsic.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/rustc_codegen_nvvm/src/intrinsic.rs b/crates/rustc_codegen_nvvm/src/intrinsic.rs index b6a7c28c..8a6463d1 100644 --- a/crates/rustc_codegen_nvvm/src/intrinsic.rs +++ b/crates/rustc_codegen_nvvm/src/intrinsic.rs @@ -296,11 +296,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { } } sym::volatile_load | sym::unaligned_volatile_load => { - let mut ptr = args[0].immediate(); - // Handle cast if the ABI requires it - if let PassMode::Cast { cast: ty, .. } = &fn_abi.ret.mode { - ptr = self.pointercast(ptr, self.type_ptr_to(ty.llvm_type(self))); - } + let ptr = args[0].immediate(); let load = self.volatile_load(result.layout.llvm_type(self), ptr); let align = if name == sym::unaligned_volatile_load { 1