Skip to content

Commit 38de6b7

Browse files
committed
Add test for alloca addrspacecast
Add a test to check that `alloca`s are casted to `addrspace(0)` before a pointer to an `alloca` is used.
1 parent 6a9115b commit 38de6b7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/codegen/amdgpu-addrspacecast.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Check that pointers are casted to addrspace(0) before they are used
2+
3+
//@ compile-flags: --crate-type=rlib --target=amdgcn-amd-amdhsa -Ctarget-cpu=gfx900
4+
//@ needs-llvm-components: amdgpu
5+
#![feature(no_core, lang_items)]
6+
#![no_core]
7+
8+
#[lang = "sized"]
9+
trait Sized {}
10+
#[lang = "freeze"]
11+
trait Freeze {}
12+
#[lang = "copy"]
13+
trait Copy {}
14+
15+
// CHECK-LABEL: @ref_of_local
16+
// CHECK: [[alloca:%[0-9]]] = alloca
17+
// CHECK: %i = addrspacecast ptr addrspace(5) [[alloca]] to ptr
18+
#[no_mangle]
19+
pub fn ref_of_local(f: fn(&i32)) {
20+
let i = 0;
21+
f(&i);
22+
}

0 commit comments

Comments
 (0)