xref: /llvm-project/llvm/test/CodeGen/SystemZ/zos-ret-addr.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 %s
3
4; The current function's return address is in the link register.
5define ptr @rt0() norecurse nounwind readnone {
6; CHECK-LABEL: rt0:
7; CHECK:         lgr 3,7
8; CHECK-NEXT:    b 2(7)
9entry:
10  %0 = tail call ptr @llvm.returnaddress(i32 0)
11  ret ptr %0
12}
13
14; Check the caller's return address.
15define ptr @rtcaller() nounwind "backchain" {
16; CHECK-LABEL: rtcaller:
17; CHECK:         stmg 4,7,2048(4)
18; CHECK-NEXT:    lg 1,2048(4)
19; CHECK-NEXT:    lg 3,24(1)
20; CHECK-NEXT:    lmg 4,7,2048(4)
21; CHECK-NEXT:    b 2(7)
22entry:
23  %0 = tail call ptr @llvm.returnaddress(i32 1)
24  ret ptr %0
25}
26
27; Check the caller's caller's return address.
28define ptr @rtcallercaller() nounwind "backchain" {
29; CHECK-LABEL: rtcallercaller:
30; CHECK:         stmg 4,7,2048(4)
31; CHECK-NEXT:    lg 1,2048(4)
32; CHECK-NEXT:    lg 1,0(1)
33; CHECK-NEXT:    lg 3,24(1)
34; CHECK-NEXT:    lmg 4,7,2048(4)
35; CHECK-NEXT:    b 2(7)
36entry:
37  %0 = tail call ptr @llvm.returnaddress(i32 2)
38  ret ptr %0
39}
40
41declare ptr @llvm.returnaddress(i32) nounwind readnone
42