xref: /llvm-project/llvm/test/CodeGen/SystemZ/zos-frameaddr.ll (revision c17040599666c1f14906a899cabcf545c2c85744)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2; RUN: llc < %s -mtriple=s390x-ibm-zos | FileCheck --check-prefix=CHECK %s
3
4; The current function's frame address is the address of
5; the optional back chain slot.
6define ptr @fp0() nounwind {
7; CHECK-LABEL: fp0:
8; CHECK:         la 3,2048(4)
9; CHECK-NEXT:    b 2(7)
10entry:
11  %0 = tail call ptr @llvm.frameaddress(i32 0)
12  ret ptr %0
13}
14
15; Check that the frame address is correct in a presence
16; of a stack frame.
17define ptr @fp0f() nounwind {
18; CHECK-LABEL: fp0f:
19; CHECK:         stmg 6,7,1904(4)
20; CHECK-NEXT:    aghi 4,-160
21; CHECK-NEXT:    la 3,2048(4)
22; CHECK-NEXT:    lg 7,2072(4)
23; CHECK-NEXT:    aghi 4,160
24; CHECK-NEXT:    b 2(7)
25entry:
26  %0 = alloca i64, align 8
27  %1 = tail call ptr @llvm.frameaddress(i32 0)
28  ret ptr %1
29}
30
31; Check the caller's frame address.
32define ptr @fpcaller() nounwind "backchain" {
33; CHECK-LABEL: fpcaller:
34; CHECK:         stmg 4,7,2048(4)
35; CHECK-NEXT:    lg 3,2048(4)
36; CHECK-NEXT:    lmg 4,7,2048(4)
37; CHECK-NEXT:    b 2(7)
38entry:
39  %0 = tail call ptr @llvm.frameaddress(i32 1)
40  ret ptr %0
41}
42
43; Check the caller's frame address.
44define ptr @fpcallercaller() nounwind "backchain" {
45; CHECK-LABEL: fpcallercaller:
46; CHECK:         stmg 4,7,2048(4)
47; CHECK-NEXT:    lg 1,2048(4)
48; CHECK-NEXT:    lg 3,0(1)
49; CHECK-NEXT:    lmg 4,7,2048(4)
50; CHECK-NEXT:    b 2(7)
51entry:
52  %0 = tail call ptr @llvm.frameaddress(i32 2)
53  ret ptr %0
54}
55
56declare ptr @llvm.frameaddress(i32) nounwind readnone
57