[InstCombine] Signed saturation patterns
[llvm-core.git] / test / CodeGen / AMDGPU / returnaddress.ll
blob1db6e3e0a8575fad93d8e9618d0da110cb8aca1f
1 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck --check-prefix=GCN %s
3 ; Test with zero frame
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 {
9 entry:
10   %0 = tail call i8* @llvm.returnaddress(i32 0)
11   ret i8* %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 {
20 entry:
21   %0 = tail call i8* @llvm.returnaddress(i32 1)
22   ret i8* %0
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 {
30 entry:
31   %tmp = tail call i8* @llvm.returnaddress(i32 0)
32   store i8* %tmp, i8** %out, align 4
33   ret void
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 {
41 entry:
42   %cmp = icmp ne i32 %val, 0
43   br i1 %cmp, label %store, label %exit
45 store:
46   %tmp = tail call i8* @llvm.returnaddress(i32 1)
47   store i8* %tmp, i8** %out, align 4
48   ret void
50 exit:
51   ret void
54 ; Test ending in unreachable
55 ; GCN-LABEL: {{^}}func5
56 ; GCN: v_mov_b32_e32 v0, 0
57 define void @func5() nounwind {
58 entry:
59   %tmp = tail call i8* @llvm.returnaddress(i32 2)
60   store volatile i32 0, i32 addrspace(3)* undef, align 4
61   unreachable
65 declare i8* @llvm.returnaddress(i32) nounwind readnone