about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-12-06 09:46:41 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-01-26 14:14:33 +0000
commit1c1c13a18411f8fd00024c0eb8fc88dee08bda96 (patch)
tree2083b1224ec837fe82cf13c47632cde2c0b3802a
parent062bc02dc7af12336c41d04a6e4496aeca61c279 (diff)
downloadrust-1c1c13a18411f8fd00024c0eb8fc88dee08bda96.tar.gz
rust-1c1c13a18411f8fd00024c0eb8fc88dee08bda96.zip
Restore previous ABI for f_single_u8_arg
-rw-r--r--compiler/rustc_target/src/callconv/nvptx64.rs11
-rw-r--r--tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs2
2 files changed, 11 insertions, 2 deletions
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<Ty>(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) {}