diff --git a/compiler/rustc_target/src/callconv/nvptx64.rs b/compiler/rustc_target/src/callconv/nvptx64.rs index 73273396ecf..c64164372a1 100644 --- a/compiler/rustc_target/src/callconv/nvptx64.rs +++ b/compiler/rustc_target/src/callconv/nvptx64.rs @@ -75,7 +75,16 @@ where 16 => Reg::i128(), _ => unreachable!("Align is given as power of 2 no larger than 16 bytes"), }; - arg.cast_to(Uniform::new(unit, arg.layout.size)); + if arg.layout.size.bytes() / align_bytes == 1 { + // Make sure we pass the struct as array at the LLVM IR level and not as a single integer. + arg.cast_to(CastTarget { + prefix: [Some(unit), None, None, None, None, None, None, None], + rest: Uniform::new(unit, Size::ZERO), + attrs: ArgAttributes::new(), + }); + } else { + arg.cast_to(Uniform::new(unit, arg.layout.size)); + } } pub(crate) fn compute_abi_info(fn_abi: &mut FnAbi<'_, Ty>) { diff --git a/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs b/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs index 21a31b6bb66..b3bfc66a5a5 100644 --- a/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs +++ b/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs @@ -166,7 +166,7 @@ pub unsafe extern "ptx-kernel" fn f_f32_arg(_a: f32) {} pub unsafe extern "ptx-kernel" fn f_f64_arg(_a: f64) {} // CHECK: .visible .entry f_single_u8_arg( -// CHECK: .param .u8 f_single_u8_arg_param_0 +// CHECK: .param .align 1 .b8 f_single_u8_arg_param_0[1] #[no_mangle] pub unsafe extern "ptx-kernel" fn f_single_u8_arg(_a: SingleU8) {}