From 485bdafdcfb340e74b7342d716b2135d4c6c8ca1 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Wed, 3 Sep 2025 08:29:52 +0200 Subject: [PATCH 1/2] Add test for addrspacecasting global vars Global variables are casted to the default address space works, as the amdgpu target is now merged, a test can be added. --- tests/auxiliary/minicore.rs | 9 ++++++++- tests/codegen-llvm/amdgpu-addrspacecast.rs | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index da880100a10cd..4f4c653cb46e7 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -179,7 +179,14 @@ impl Add for isize { #[lang = "sync"] trait Sync {} -impl Sync for u8 {} +impl_marker_trait!( + Sync => [ + char, bool, + isize, i8, i16, i32, i64, i128, + usize, u8, u16, u32, u64, u128, + f16, f32, f64, f128, + ] +); #[lang = "drop_in_place"] fn drop_in_place(_: *mut T) {} diff --git a/tests/codegen-llvm/amdgpu-addrspacecast.rs b/tests/codegen-llvm/amdgpu-addrspacecast.rs index 7fe630a7efa0e..829133de00d8b 100644 --- a/tests/codegen-llvm/amdgpu-addrspacecast.rs +++ b/tests/codegen-llvm/amdgpu-addrspacecast.rs @@ -16,3 +16,12 @@ pub fn ref_of_local(f: fn(&i32)) { let i = 0; f(&i); } + +// CHECK-LABEL: @ref_of_global +// CHECK: addrspacecast (ptr addrspace(1) @I to ptr) +#[no_mangle] +pub fn ref_of_global(f: fn(&i32)) { + #[no_mangle] + static I: i32 = 0; + f(&I); +} From 15c6585e5c5352746302737c0a55de96d9514fd3 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Tue, 21 Jan 2025 23:21:29 +0100 Subject: [PATCH 2/2] Add amdgpu to gpu-kernel test Check that the gpu-kernel calling convention translates to `amdgpu_kernel` when compiling for the amdgpu target. --- tests/codegen-llvm/gpu-kernel-abi.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/codegen-llvm/gpu-kernel-abi.rs b/tests/codegen-llvm/gpu-kernel-abi.rs index 8ac376d93381b..d5a357ef65529 100644 --- a/tests/codegen-llvm/gpu-kernel-abi.rs +++ b/tests/codegen-llvm/gpu-kernel-abi.rs @@ -1,7 +1,9 @@ // Checks that the gpu-kernel calling convention correctly translates to LLVM calling conventions. //@ add-core-stubs -//@ revisions: nvptx +//@ revisions: amdgpu nvptx +//@ [amdgpu] compile-flags: --crate-type=rlib --target=amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 +//@ [amdgpu] needs-llvm-components: amdgpu //@ [nvptx] compile-flags: --crate-type=rlib --target=nvptx64-nvidia-cuda //@ [nvptx] needs-llvm-components: nvptx #![feature(no_core, lang_items, abi_gpu_kernel)] @@ -10,6 +12,7 @@ extern crate minicore; use minicore::*; +// amdgpu: define amdgpu_kernel void @fun(i32 // nvptx: define ptx_kernel void @fun(i32 #[no_mangle] pub extern "gpu-kernel" fn fun(_: i32) {}