Skip to content

Commit 9fa4487

Browse files
committed
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.
1 parent 26b56cc commit 9fa4487

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

crates/rustc_codegen_nvvm/src/intrinsic.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
296296
}
297297
}
298298
sym::volatile_load | sym::unaligned_volatile_load => {
299-
let mut ptr = args[0].immediate();
300-
// Handle cast if the ABI requires it
301-
if let PassMode::Cast { cast: ty, .. } = &fn_abi.ret.mode {
302-
ptr = self.pointercast(ptr, self.type_ptr_to(ty.llvm_type(self)));
303-
}
299+
let ptr = args[0].immediate();
304300
let load = self.volatile_load(result.layout.llvm_type(self), ptr);
305301
let align = if name == sym::unaligned_volatile_load {
306302
1

0 commit comments

Comments
 (0)