1 ; Test the backchain attribute.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck -allow-deprecated-dag-overlap %s
5 declare i8 *@llvm.stacksave()
6 declare void @llvm.stackrestore(i8 *)
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 i8 *@llvm.stacksave()
78 %array1 = alloca i8, i32 %count1
79 store volatile i8 0, i8 *%array1
80 call void @llvm.stackrestore(i8 *%src)
81 %array2 = alloca i8, i32 %count2
82 store volatile i8 0, i8 *%array2