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