1 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
3 ; Test lowering of @llvm.frameaddress with packed-stack.
6 attributes #0 = { nounwind "packed-stack" "backchain" "use-soft-float"="true" }
10 ; CHECK: la %r2, 152(%r15)
12 %0 = tail call ptr @llvm.frameaddress(i32 0)
16 define ptr @fp0f() #0 {
19 ; CHECK: lgr %r1, %r15
20 ; CHECK-NEXT: aghi %r15, -16
21 ; CHECK-NEXT: stg %r1, 152(%r15)
22 ; CHECK-NEXT: la %r2, 168(%r15)
23 ; CHECK-NEXT: aghi %r15, 16
25 %0 = alloca i64, align 8
26 %1 = tail call ptr @llvm.frameaddress(i32 0)
30 ; Check the caller's frame address.
31 define ptr @fpcaller() #0 {
33 ; CHECK-LABEL: fpcaller:
34 ; CHECK: lghi %r2, 152
35 ; CHECK: ag %r2, 152(%r15)
37 %0 = tail call ptr @llvm.frameaddress(i32 1)
41 ; Check the caller's caller's frame address.
42 define ptr @fpcallercaller() #0 {
44 ; CHECK-LABEL: fpcallercaller:
45 ; CHECK: lg %r1, 152(%r15)
46 ; CHECK: lghi %r2, 152
47 ; CHECK: ag %r2, 152(%r1)
49 %0 = tail call ptr @llvm.frameaddress(i32 2)
55 attributes #1 = { nounwind "packed-stack" }
56 define ptr @fp1() #1 {
59 ; CHECK: la %r2, 152(%r15)
61 %0 = tail call ptr @llvm.frameaddress(i32 0)
65 ; No saved registers: returning address of unused slot where backcahin would
67 define ptr @fp1f() #1 {
70 ; CHECK: aghi %r15, -16
71 ; CHECK-NEXT: la %r2, 168(%r15)
72 ; CHECK-NEXT: aghi %r15, 16
74 %0 = alloca i64, align 8
75 %1 = tail call ptr @llvm.frameaddress(i32 0)
79 ; Saved registers: returning address for first saved GPR.
80 declare void @foo(ptr %Arg)
81 define ptr @fp2() #1 {
84 ; CHECK: stmg %r14, %r15, 144(%r15)
85 ; CHECK-NEXT: aghi %r15, -16
86 ; CHECK-NEXT: la %r2, 168(%r15)
87 ; CHECK-NEXT: brasl %r14, foo@PLT
88 ; CHECK-NEXT: la %r2, 168(%r15)
89 ; CHECK-NEXT: lmg %r14, %r15, 160(%r15)
91 %0 = tail call ptr @llvm.frameaddress(i32 0)
92 call void @foo(ptr %0);
96 declare ptr @llvm.frameaddress(i32) nounwind readnone