1; Test support for the llvm.returnaddress intrinsic. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4 5; The current function's return address is in the link register. 6define ptr @rt0() norecurse nounwind readnone { 7entry: 8; CHECK-LABEL: rt0: 9; CHECK: lgr %r2, %r14 10; CHECK: br %r14 11 %0 = tail call ptr @llvm.returnaddress(i32 0) 12 ret ptr %0 13} 14 15; Check the caller's return address. 16define ptr @rtcaller() nounwind "backchain" { 17entry: 18; CHECK-LABEL: rtcaller: 19; CHECK: lg %r1, 0(%r15) 20; CHECK lg %r2, 112(%r1) 21; CHECK: br %r14 22 %0 = tail call ptr @llvm.returnaddress(i32 1) 23 ret ptr %0 24} 25 26; Check the caller's caller's return address. 27define ptr @rtcallercaller() nounwind "backchain" { 28entry: 29; CHECK-LABEL: rtcallercaller: 30; CHECK: lg %r1, 0(%r15) 31; CHECK: lg %r1, 0(%r1) 32; CHECK lg %r2, 112(%r1) 33; CHECK: br %r14 34 %0 = tail call ptr @llvm.returnaddress(i32 2) 35 ret ptr %0 36} 37 38declare ptr @llvm.returnaddress(i32) nounwind readnone 39