Skip to content

Commit

Permalink
Add test for alloca addrspacecast
Browse files Browse the repository at this point in the history
Add a test to check that `alloca`s are casted to `addrspace(0)` before a
pointer to an `alloca` is used.
  • Loading branch information
Flakebi committed Feb 5, 2025
1 parent 6a9115b commit 38de6b7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/codegen/amdgpu-addrspacecast.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Check that pointers are casted to addrspace(0) before they are used

//@ compile-flags: --crate-type=rlib --target=amdgcn-amd-amdhsa -Ctarget-cpu=gfx900
//@ needs-llvm-components: amdgpu
#![feature(no_core, lang_items)]
#![no_core]

#[lang = "sized"]
trait Sized {}
#[lang = "freeze"]
trait Freeze {}
#[lang = "copy"]
trait Copy {}

// CHECK-LABEL: @ref_of_local
// CHECK: [[alloca:%[0-9]]] = alloca
// CHECK: %i = addrspacecast ptr addrspace(5) [[alloca]] to ptr
#[no_mangle]
pub fn ref_of_local(f: fn(&i32)) {
let i = 0;
f(&i);
}

0 comments on commit 38de6b7

Please # to comment.