1 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck --check-prefix=GCN %s
4 ; GCN-LABEL: {{^}}func1
5 ; GCN: v_mov_b32_e32 v0, s30
6 ; GCN: v_mov_b32_e32 v1, s31
7 ; GCN: s_setpc_b64 s[30:31]
8 define i8* @func1() nounwind {
10 %0 = tail call i8* @llvm.returnaddress(i32 0)
14 ; Test with non-zero frame
15 ; GCN-LABEL: {{^}}func2
16 ; GCN: v_mov_b32_e32 v0, 0
17 ; GCN: v_mov_b32_e32 v1, 0
18 ; GCN: s_setpc_b64 s[30:31]
19 define i8* @func2() nounwind {
21 %0 = tail call i8* @llvm.returnaddress(i32 1)
25 ; Test with amdgpu_kernel
26 ; GCN-LABEL: {{^}}func3
27 ; GCN: v_mov_b32_e32 v0, 0
28 ; GCN: v_mov_b32_e32 v1, v0
29 define amdgpu_kernel void @func3(i8** %out) nounwind {
31 %tmp = tail call i8* @llvm.returnaddress(i32 0)
32 store i8* %tmp, i8** %out, align 4
36 ; Test with use outside the entry-block
37 ; GCN-LABEL: {{^}}func4
38 ; GCN: v_mov_b32_e32 v0, 0
39 ; GCN: v_mov_b32_e32 v1, v0
40 define amdgpu_kernel void @func4(i8** %out, i32 %val) nounwind {
42 %cmp = icmp ne i32 %val, 0
43 br i1 %cmp, label %store, label %exit
46 %tmp = tail call i8* @llvm.returnaddress(i32 1)
47 store i8* %tmp, i8** %out, align 4
54 ; Test ending in unreachable
55 ; GCN-LABEL: {{^}}func5
56 ; GCN: v_mov_b32_e32 v0, 0
57 define void @func5() nounwind {
59 %tmp = tail call i8* @llvm.returnaddress(i32 2)
60 store volatile i32 0, i32 addrspace(3)* undef, align 4
65 declare i8* @llvm.returnaddress(i32) nounwind readnone