1*5eb64110SUlrich Weigand; RUN: llc -mtriple=s390x-linux-gnu < %s | FileCheck %s
2*5eb64110SUlrich Weigand
3*5eb64110SUlrich Weigand; Test invoking of patchpoints
4*5eb64110SUlrich Weigand;
5*5eb64110SUlrich Weiganddefine i64 @patchpoint_invoke(i64 %p1, i64 %p2) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
6*5eb64110SUlrich Weigandentry:
7*5eb64110SUlrich Weigand; CHECK-LABEL: patchpoint_invoke:
8*5eb64110SUlrich Weigand; CHECK-NEXT:  [[FUNC_BEGIN:.L.*]]:
9*5eb64110SUlrich Weigand; CHECK-NEXT: .cfi_startproc
10*5eb64110SUlrich Weigand; CHECK:      .cfi_lsda 0, [[EXCEPTION_LABEL:.L[^ ]*]]
11*5eb64110SUlrich Weigand; CHECK:      aghi %r15, -160
12*5eb64110SUlrich Weigand
13*5eb64110SUlrich Weigand; Unfortunately, hardcode the name of the label that begins the patchpoint:
14*5eb64110SUlrich Weigand; CHECK:      .Ltmp0:
15*5eb64110SUlrich Weigand; CHECK:      llilf   %r1, 559038736
16*5eb64110SUlrich Weigand; CHECK-NEXT: basr    %r14, %r1
17*5eb64110SUlrich Weigand; CHECK-NEXT: bcr     0, %r0
18*5eb64110SUlrich Weigand; CHECK-NEXT: [[PP_END:.L.*]]:
19*5eb64110SUlrich Weigand; CHECK:      br %r14
20*5eb64110SUlrich Weigand  %resolveCall = inttoptr i64 559038736 to i8*
21*5eb64110SUlrich Weigand  %result = invoke i64 (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.i64(i64 2, i32 10, i8* %resolveCall, i32 1, i64 %p1, i64 %p2)
22*5eb64110SUlrich Weigand            to label %success unwind label %threw
23*5eb64110SUlrich Weigand
24*5eb64110SUlrich Weigandsuccess:
25*5eb64110SUlrich Weigand  ret i64 %result
26*5eb64110SUlrich Weigand
27*5eb64110SUlrich Weigandthrew:
28*5eb64110SUlrich Weigand  %0 = landingpad { i8*, i32 }
29*5eb64110SUlrich Weigand          catch i8* null
30*5eb64110SUlrich Weigand  ret i64 0
31*5eb64110SUlrich Weigand}
32*5eb64110SUlrich Weigand
33*5eb64110SUlrich Weigand; Verify that the exception table was emitted:
34*5eb64110SUlrich Weigand; CHECK:      [[EXCEPTION_LABEL]]:
35*5eb64110SUlrich Weigand; CHECK-NEXT: .byte 255
36*5eb64110SUlrich Weigand; CHECK-NEXT: .byte 0
37*5eb64110SUlrich Weigand; CHECK-NEXT: .uleb128 .Lttbase{{[0-9]+}}-[[TTBASEREF:.Lttbaseref[0-9]+]]
38*5eb64110SUlrich Weigand; CHECK-NEXT: [[TTBASEREF]]:
39*5eb64110SUlrich Weigand; CHECK-NEXT: .byte 1
40*5eb64110SUlrich Weigand; CHECK-NEXT: .uleb128 .Lcst_end{{[0-9]+}}-[[CST_BEGIN:.Lcst_begin[0-9]+]]
41*5eb64110SUlrich Weigand; CHECK-NEXT: [[CST_BEGIN]]:
42*5eb64110SUlrich Weigand; Verify that the unwind data covers the entire patchpoint region:
43*5eb64110SUlrich Weigand; CHECK-NEXT: .uleb128 .Ltmp0-[[FUNC_BEGIN]]
44*5eb64110SUlrich Weigand; CHECK-NEXT: .uleb128 [[PP_END]]-.Ltmp0
45*5eb64110SUlrich Weigand
46*5eb64110SUlrich Weigand
47*5eb64110SUlrich Weigand; Verify that the stackmap section got emitted:
48*5eb64110SUlrich Weigand; CHECK-LABEL: __LLVM_StackMaps:
49*5eb64110SUlrich Weigand; Header
50*5eb64110SUlrich Weigand; CHECK-NEXT:   .byte 3
51*5eb64110SUlrich Weigand; CHECK-NEXT:   .byte 0
52*5eb64110SUlrich Weigand; CHECK-NEXT:   .short 0
53*5eb64110SUlrich Weigand; Num Functions
54*5eb64110SUlrich Weigand; CHECK-NEXT:   .long 1
55*5eb64110SUlrich Weigand; Num LargeConstants
56*5eb64110SUlrich Weigand; CHECK-NEXT:   .long 0
57*5eb64110SUlrich Weigand; Num Callsites
58*5eb64110SUlrich Weigand; CHECK-NEXT:   .long 1
59*5eb64110SUlrich Weigand; CHECK-NEXT:   .quad patchpoint_invoke
60*5eb64110SUlrich Weigand
61*5eb64110SUlrich Weigand
62*5eb64110SUlrich Weiganddeclare void @llvm.experimental.stackmap(i64, i32, ...)
63*5eb64110SUlrich Weiganddeclare void @llvm.experimental.patchpoint.void(i64, i32, i8*, i32, ...)
64*5eb64110SUlrich Weiganddeclare i64 @llvm.experimental.patchpoint.i64(i64, i32, i8*, i32, ...)
65*5eb64110SUlrich Weiganddeclare i32 @__gxx_personality_v0(...)
66