xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/deopt-bundles.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc     < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -O3 < %s | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -O3 -debug-only=stackmaps < %s 2>&1 | FileCheck -check-prefix=STACKMAPS %s
4*9880d681SAndroid Build Coastguard Worker; REQUIRES: asserts
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-macosx10.11.0"
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Worker; STACKMAPS: Stack Maps: callsite 2882400015
11*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps:   has 4 locations
12*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 0: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
13*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 1: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
14*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 2: Constant 1	[encoding: .byte 4, .byte 8, .short 0, .int 1]
15*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 3: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
16*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 	has 0 live-out registers
17*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: callsite 4242
18*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps:   has 4 locations
19*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 0: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
20*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 1: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
21*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 2: Constant 1	[encoding: .byte 4, .byte 8, .short 0, .int 1]
22*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 3: Constant 1	[encoding: .byte 4, .byte 8, .short 0, .int 1]
23*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 	has 0 live-out registers
24*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: callsite 4243
25*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps:   has 4 locations
26*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 0: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
27*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 1: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
28*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 2: Constant 1	[encoding: .byte 4, .byte 8, .short 0, .int 1]
29*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 3: Constant 16	[encoding: .byte 4, .byte 8, .short 0, .int 16]
30*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 	has 0 live-out registers
31*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: callsite 2882400015
32*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps:   has 4 locations
33*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 0: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
34*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 1: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
35*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 2: Constant 1	[encoding: .byte 4, .byte 8, .short 0, .int 1]
36*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 3: Constant 2	[encoding: .byte 4, .byte 8, .short 0, .int 2]
37*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 	has 0 live-out registers
38*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: callsite 2882400015
39*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps:   has 4 locations
40*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 0: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
41*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 1: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
42*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 2: Constant 1	[encoding: .byte 4, .byte 8, .short 0, .int 1]
43*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 3: Constant 3	[encoding: .byte 4, .byte 8, .short 0, .int 3]
44*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 	has 0 live-out registers
45*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: callsite 4243
46*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps:   has 4 locations
47*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 0: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
48*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 1: Constant 0	[encoding: .byte 4, .byte 8, .short 0, .int 0]
49*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 2: Constant 1	[encoding: .byte 4, .byte 8, .short 0, .int 1]
50*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 		Loc 3: Constant 55	[encoding: .byte 4, .byte 8, .short 0, .int 55]
51*9880d681SAndroid Build Coastguard Worker; STACKMAPS-NEXT: Stack Maps: 	has 0 live-out registers
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Workerdeclare i32 @callee_0()
55*9880d681SAndroid Build Coastguard Workerdeclare i32 @callee_1(i32)
56*9880d681SAndroid Build Coastguard Workerdeclare i32 @callee_vararg(...)
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Workerdefine i32 @caller_0() {
59*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _caller_0
60*9880d681SAndroid Build Coastguard Workerentry:
61*9880d681SAndroid Build Coastguard Worker  %v = call i32 @callee_0() [ "deopt"(i32 0) ]
62*9880d681SAndroid Build Coastguard Worker  %v2 = add i32 %v, 1
63*9880d681SAndroid Build Coastguard Worker  ret i32 %v2
64*9880d681SAndroid Build Coastguard Worker; CHECK:	callq	_callee_0
65*9880d681SAndroid Build Coastguard Worker; CHECK:	incl	%eax
66*9880d681SAndroid Build Coastguard Worker; CHECK:	retq
67*9880d681SAndroid Build Coastguard Worker}
68*9880d681SAndroid Build Coastguard Worker
69*9880d681SAndroid Build Coastguard Workerdefine i32 @caller_1() {
70*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _caller_1
71*9880d681SAndroid Build Coastguard Workerentry:
72*9880d681SAndroid Build Coastguard Worker  %v = call i32 @callee_1(i32 42) "statepoint-id"="4242" [ "deopt"(i32 1) ]
73*9880d681SAndroid Build Coastguard Worker  ret i32 %v
74*9880d681SAndroid Build Coastguard Worker; CHECK:	callq	_callee_1
75*9880d681SAndroid Build Coastguard Worker; CHECK:	popq	%rcx
76*9880d681SAndroid Build Coastguard Worker; CHECK:	retq
77*9880d681SAndroid Build Coastguard Worker}
78*9880d681SAndroid Build Coastguard Worker
79*9880d681SAndroid Build Coastguard Workerdefine i32 @caller_vararg() {
80*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _caller_vararg
81*9880d681SAndroid Build Coastguard Workerentry:
82*9880d681SAndroid Build Coastguard Worker; CHECK: movb    $1, %al
83*9880d681SAndroid Build Coastguard Worker; CHECK: callq   _callee_vararg
84*9880d681SAndroid Build Coastguard Worker  %v = call i32(...) @callee_vararg(i32 42, double 500.0) "statepoint-id"="4243" [ "deopt"(i32 16) ]
85*9880d681SAndroid Build Coastguard Worker  ret i32 %v
86*9880d681SAndroid Build Coastguard Worker}
87*9880d681SAndroid Build Coastguard Worker
88*9880d681SAndroid Build Coastguard Workerdefine i32 @invoker_0() personality i8 0 {
89*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _invoker_0
90*9880d681SAndroid Build Coastguard Workerentry:
91*9880d681SAndroid Build Coastguard Worker  %v = invoke i32 @callee_0() [ "deopt"(i32 2) ]
92*9880d681SAndroid Build Coastguard Worker          to label %normal unwind label %uw
93*9880d681SAndroid Build Coastguard Worker
94*9880d681SAndroid Build Coastguard Workernormal:
95*9880d681SAndroid Build Coastguard Worker  ret i32 %v
96*9880d681SAndroid Build Coastguard Worker
97*9880d681SAndroid Build Coastguard Workeruw:
98*9880d681SAndroid Build Coastguard Worker  %ehvals = landingpad { i8*, i32 }
99*9880d681SAndroid Build Coastguard Worker      cleanup
100*9880d681SAndroid Build Coastguard Worker  ret i32 1
101*9880d681SAndroid Build Coastguard Worker; CHECK:	callq	_callee_0
102*9880d681SAndroid Build Coastguard Worker; CHECK:	popq	%rcx
103*9880d681SAndroid Build Coastguard Worker; CHECK:	retq
104*9880d681SAndroid Build Coastguard Worker; CHECK:	movl	$1, %eax
105*9880d681SAndroid Build Coastguard Worker; CHECK:	popq	%rcx
106*9880d681SAndroid Build Coastguard Worker; CHECK:	retq
107*9880d681SAndroid Build Coastguard Worker}
108*9880d681SAndroid Build Coastguard Worker
109*9880d681SAndroid Build Coastguard Workerdefine i32 @invoker_1() personality i8 0 {
110*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _invoker_1
111*9880d681SAndroid Build Coastguard Workerentry:
112*9880d681SAndroid Build Coastguard Worker  %v = invoke i32 @callee_1(i32 45) "statepoint-num-patch-bytes"="9" [ "deopt"(i32 3) ]
113*9880d681SAndroid Build Coastguard Worker          to label %normal unwind label %uw
114*9880d681SAndroid Build Coastguard Worker
115*9880d681SAndroid Build Coastguard Workernormal:
116*9880d681SAndroid Build Coastguard Worker  ret i32 %v
117*9880d681SAndroid Build Coastguard Worker
118*9880d681SAndroid Build Coastguard Workeruw:
119*9880d681SAndroid Build Coastguard Worker  %ehvals = landingpad { i8*, i32 }
120*9880d681SAndroid Build Coastguard Worker      cleanup
121*9880d681SAndroid Build Coastguard Worker  ret i32 1
122*9880d681SAndroid Build Coastguard Worker; CHECK:	movl	$45, %edi
123*9880d681SAndroid Build Coastguard Worker; CHECK:	nopw    512(%rax,%rax)
124*9880d681SAndroid Build Coastguard Worker; CHECK:	popq	%rcx
125*9880d681SAndroid Build Coastguard Worker; CHECK:	retq
126*9880d681SAndroid Build Coastguard Worker; CHECK:	movl	$1, %eax
127*9880d681SAndroid Build Coastguard Worker; CHECK:	popq	%rcx
128*9880d681SAndroid Build Coastguard Worker; CHECK:	retq
129*9880d681SAndroid Build Coastguard Worker}
130*9880d681SAndroid Build Coastguard Worker
131*9880d681SAndroid Build Coastguard Workerdefine i32 @invoker_2() personality i32 (...)* @__CxxFrameHandler3 {
132*9880d681SAndroid Build Coastguard Workerentry:
133*9880d681SAndroid Build Coastguard Worker  %val = invoke i32 @callee_1(i32 1)
134*9880d681SAndroid Build Coastguard Worker          to label %try.cont unwind label %catch.dispatch
135*9880d681SAndroid Build Coastguard Worker
136*9880d681SAndroid Build Coastguard Workercatch.dispatch:
137*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %catch] unwind to caller
138*9880d681SAndroid Build Coastguard Worker
139*9880d681SAndroid Build Coastguard Workercatch:
140*9880d681SAndroid Build Coastguard Worker  %cp1 = catchpad within %cs1 [i8* null, i32 64, i8* null]
141*9880d681SAndroid Build Coastguard Worker  %val2 = call i32 @callee_1(i32 100) "statepoint-id"="4243" [ "funclet"(token %cp1), "deopt"(i32 55) ]
142*9880d681SAndroid Build Coastguard Worker  catchret from %cp1 to label %try.cont
143*9880d681SAndroid Build Coastguard Worker
144*9880d681SAndroid Build Coastguard Workertry.cont:
145*9880d681SAndroid Build Coastguard Worker  ret i32 0
146*9880d681SAndroid Build Coastguard Worker}
147*9880d681SAndroid Build Coastguard Worker
148*9880d681SAndroid Build Coastguard Workerdeclare i32 @__CxxFrameHandler3(...)
149*9880d681SAndroid Build Coastguard Worker
150*9880d681SAndroid Build Coastguard Workerdefine void @f_0(i64 %n) {
151*9880d681SAndroid Build Coastguard Worker  ; CHECK-LABEL: _f_0
152*9880d681SAndroid Build Coastguard Worker  %s = alloca i64
153*9880d681SAndroid Build Coastguard Worker  %vl = alloca i64, i64 %n
154*9880d681SAndroid Build Coastguard Worker  ; Check that the stackmap does not reference %s through
155*9880d681SAndroid Build Coastguard Worker  ; SP since the offset is not static because of %vl.
156*9880d681SAndroid Build Coastguard Worker  ; STACKMAPS: Loc 3: Direct 6
157*9880d681SAndroid Build Coastguard Worker  call void @g_0(i64* %vl) [ "deopt"(i64* %s) ]
158*9880d681SAndroid Build Coastguard Worker  ret void
159*9880d681SAndroid Build Coastguard Worker}
160*9880d681SAndroid Build Coastguard Worker
161*9880d681SAndroid Build Coastguard Workerdeclare void @g_0(i64* %vl)
162