1 ; Test the backchain attribute.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck -allow-deprecated-dag-overlap %s
5 declare ptr@llvm.stacksave()
6 declare void @llvm.stackrestore(ptr)
9 ; nothing should happen if no stack frame is needed.
10 define void @f1() "backchain" {
16 ; check that backchain is saved if we call someone
17 define void @f2() "backchain" {
19 ; CHECK: stmg %r14, %r15, 112(%r15)
20 ; CHECK: lgr %r1, %r15
21 ; CHECK: aghi %r15, -160
22 ; CHECK: stg %r1, 0(%r15)
28 ; check that backchain is saved if we have an alloca
29 define void @f3() "backchain" {
32 ; CHECK: lgr %r1, %r15
33 ; CHECK: aghi %r15, -168
34 ; CHECK: stg %r1, 0(%r15)
35 %ign = alloca i8, i32 4
39 ; check that alloca copies the backchain
40 define void @f4(i32 %len) "backchain" {
42 ; CHECK: stmg %r11, %r15, 88(%r15)
43 ; CHECK: lgr %r1, %r15
44 ; CHECK: aghi %r15, -160
45 ; CHECK: stg %r1, 0(%r15)
46 ; CHECK: lgr %r11, %r15
47 ; CHECK-DAG: lg [[BC:%r[0-9]+]], 0(%r15)
48 ; CHECK-DAG: lgr [[NEWSP:%r[0-9]+]], %r15
49 ; CHECK: lgr %r15, [[NEWSP]]
50 ; CHECK: stg [[BC]], 0([[NEWSP]])
51 %ign = alloca i8, i32 %len
55 ; check that llvm.stackrestore restores the backchain
56 define void @f5(i32 %count1, i32 %count2) "backchain" {
58 ; CHECK: stmg %r11, %r15, 88(%r15)
59 ; CHECK: lgr %r1, %r15
60 ; CHECK: aghi %r15, -160
61 ; CHECK: stg %r1, 0(%r15)
62 ; CHECK: lgr %r11, %r15
63 ; CHECK-DAG: lgr [[SAVESP:%r[0-9]+]], %r15
64 ; CHECK-DAG: lg [[BC:%r[0-9]+]], 0(%r15)
65 ; CHECK-DAG: lgr [[NEWSP:%r[0-9]+]], %r15
66 ; CHECK-DAG: lgr %r15, [[NEWSP]]
67 ; CHECK-DAG: stg [[BC]], 0([[NEWSP]])
68 ; CHECK-DAG: lg [[BC2:%r[0-9]+]], 0(%r15)
69 ; CHECK-DAG: lgr %r15, [[SAVESP]]
70 ; CHECK-DAG: stg [[BC2]], 0([[SAVESP]])
71 ; CHECK-DAG: lg [[BC3:%r[0-9]+]], 0(%r15)
72 ; CHECK-DAG: lgr [[NEWSP2:%r[0-9]+]], %r15
73 ; CHECK-DAG: lgr %r15, [[NEWSP2]]
74 ; CHECK-DAG: stg [[BC3]], 0([[NEWSP2]])
75 ; CHECK: lmg %r11, %r15, 248(%r11)
77 %src = call ptr@llvm.stacksave()
78 %array1 = alloca i8, i32 %count1
79 store volatile i8 0, ptr %array1
80 call void @llvm.stackrestore(ptr %src)
81 %array2 = alloca i8, i32 %count2
82 store volatile i8 0, ptr %array2
86 ; same, but with the kernel backchain
87 define void @f6(i32 %count1, i32 %count2) #0 {
89 ; CHECK: stmg %r11, %r15, 112(%r15)
90 ; CHECK: lgr %r1, %r15
91 ; CHECK: aghi %r15, -48
92 ; CHECK: stg %r1, 152(%r15)
93 ; CHECK: lgr %r11, %r15
94 ; CHECK-DAG: lgr [[SAVESP:%r[0-9]+]], %r15
95 ; CHECK-DAG: lg [[BC:%r[0-9]+]], 152(%r15)
96 ; CHECK-DAG: lgr [[NEWSP:%r[0-9]+]], %r15
97 ; CHECK-DAG: lgr %r15, [[NEWSP]]
98 ; CHECK-DAG: stg [[BC]], 152([[NEWSP]])
99 ; CHECK-DAG: lg [[BC2:%r[0-9]+]], 152(%r15)
100 ; CHECK-DAG: lgr %r15, [[SAVESP]]
101 ; CHECK-DAG: stg [[BC2]], 152([[SAVESP]])
102 ; CHECK-DAG: lg [[BC3:%r[0-9]+]], 152(%r15)
103 ; CHECK-DAG: lgr [[NEWSP2:%r[0-9]+]], %r15
104 ; CHECK-DAG: lgr %r15, [[NEWSP2]]
105 ; CHECK-DAG: stg [[BC3]], 152([[NEWSP2]])
106 ; CHECK: lmg %r11, %r15, 160(%r11)
108 %src = call ptr@llvm.stacksave()
109 %array1 = alloca i8, i32 %count1
110 store volatile i8 0, ptr %array1
111 call void @llvm.stackrestore(ptr %src)
112 %array2 = alloca i8, i32 %count2
113 store volatile i8 0, ptr %array2
117 attributes #0 = { "backchain" "packed-stack" "use-soft-float"="true" }