39 lines · plain
1; Test support for the llvm.returnaddress intrinsic.2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s4 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, %r1410; CHECK: br %r1411 %0 = tail call ptr @llvm.returnaddress(i32 0)12 ret ptr %013}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 %r1422 %0 = tail call ptr @llvm.returnaddress(i32 1)23 ret ptr %024}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 %r1434 %0 = tail call ptr @llvm.returnaddress(i32 2)35 ret ptr %036}37 38declare ptr @llvm.returnaddress(i32) nounwind readnone39