1 ; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
3 declare void @may_throw_or_crash()
4 declare i32 @_except_handler3(...)
5 declare i32 @_except_handler4(...)
6 declare i32 @__CxxFrameHandler3(...)
7 declare void @llvm.eh.begincatch(i8*, i8*)
8 declare void @llvm.eh.endcatch()
9 declare i32 @llvm.eh.typeid.for(i8*)
11 define internal i32 @catchall_filt() {
15 define void @use_except_handler3() personality i32 (...)* @_except_handler3 {
17 invoke void @may_throw_or_crash()
18 to label %cont unwind label %lpad
22 %cs = catchswitch within none [label %catch] unwind to caller
24 %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)]
25 catchret from %p to label %cont
28 ; CHECK-LABEL: _use_except_handler3:
30 ; CHECK-NEXT: movl %esp, %ebp
31 ; CHECK-NEXT: pushl %ebx
32 ; CHECK-NEXT: pushl %edi
33 ; CHECK-NEXT: pushl %esi
34 ; CHECK-NEXT: subl ${{[0-9]+}}, %esp
35 ; CHECK-NEXT: movl %esp, -36(%ebp)
36 ; CHECK-NEXT: movl $-1, -16(%ebp)
37 ; CHECK-NEXT: movl $L__ehtable$use_except_handler3, -20(%ebp)
38 ; CHECK-NEXT: leal -28(%ebp), %[[node:[^ ,]*]]
39 ; CHECK-NEXT: movl $__except_handler3, -24(%ebp)
40 ; CHECK-NEXT: movl %fs:0, %[[next:[^ ,]*]]
41 ; CHECK-NEXT: movl %[[next]], -28(%ebp)
42 ; CHECK-NEXT: movl %[[node]], %fs:0
43 ; CHECK-NEXT: movl $0, -16(%ebp)
44 ; CHECK-NEXT: calll _may_throw_or_crash
46 ; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
47 ; CHECK-NEXT: movl %[[next]], %fs:0
49 ; CHECK-NEXT: LBB1_2: # %catch{{$}}
51 ; CHECK: .section .xdata,"dr"
52 ; CHECK-LABEL: L__ehtable$use_except_handler3:
53 ; CHECK-NEXT: .long -1
54 ; CHECK-NEXT: .long _catchall_filt
55 ; CHECK-NEXT: .long LBB1_2
57 define void @use_except_handler4() personality i32 (...)* @_except_handler4 {
59 invoke void @may_throw_or_crash()
60 to label %cont unwind label %lpad
64 %cs = catchswitch within none [label %catch] unwind to caller
66 %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)]
67 catchret from %p to label %cont
70 ; CHECK-LABEL: _use_except_handler4:
72 ; CHECK-NEXT: movl %esp, %ebp
73 ; CHECK-NEXT: pushl %ebx
74 ; CHECK-NEXT: pushl %edi
75 ; CHECK-NEXT: pushl %esi
76 ; CHECK-NEXT: subl ${{[0-9]+}}, %esp
77 ; CHECK-NEXT: movl %ebp, %eax
78 ; CHECK-NEXT: movl %esp, -36(%ebp)
79 ; CHECK-NEXT: movl $-2, -16(%ebp)
80 ; CHECK-NEXT: movl $L__ehtable$use_except_handler4, %[[lsda:[^ ,]*]]
81 ; CHECK-NEXT: movl ___security_cookie, %[[seccookie:[^ ,]*]]
82 ; CHECK-NEXT: xorl %[[seccookie]], %[[lsda]]
83 ; CHECK-NEXT: movl %[[lsda]], -20(%ebp)
84 ; CHECK-NEXT: xorl %[[seccookie]], %[[tmp1:[^ ,]*]]
85 ; CHECK-NEXT: movl %[[tmp1]], -40(%ebp)
86 ; CHECK-NEXT: leal -28(%ebp), %[[node:[^ ,]*]]
87 ; CHECK-NEXT: movl $__except_handler4, -24(%ebp)
88 ; CHECK-NEXT: movl %fs:0, %[[next:[^ ,]*]]
89 ; CHECK-NEXT: movl %[[next]], -28(%ebp)
90 ; CHECK-NEXT: movl %[[node]], %fs:0
91 ; CHECK-NEXT: movl $0, -16(%ebp)
92 ; CHECK-NEXT: calll _may_throw_or_crash
94 ; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
95 ; CHECK-NEXT: movl %[[next]], %fs:0
96 ; CHECK-NEXT: addl $28, %esp
97 ; CHECK-NEXT: popl %esi
98 ; CHECK-NEXT: popl %edi
99 ; CHECK-NEXT: popl %ebx
100 ; CHECK-NEXT: popl %ebp
102 ; CHECK-NEXT: LBB2_2: # %catch{{$}}
104 ; CHECK: .section .xdata,"dr"
105 ; CHECK-LABEL: L__ehtable$use_except_handler4:
106 ; CHECK-NEXT: .long -2
107 ; CHECK-NEXT: .long 0
108 ; CHECK-NEXT: .long -40
109 ; CHECK-NEXT: .long 0
110 ; CHECK-NEXT: .long -2
111 ; CHECK-NEXT: .long _catchall_filt
112 ; CHECK-NEXT: .long LBB2_2
114 define void @use_except_handler4_ssp() sspstrong personality i32 (...)* @_except_handler4 {
116 invoke void @may_throw_or_crash()
117 to label %cont unwind label %lpad
121 %cs = catchswitch within none [label %catch] unwind to caller
123 %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)]
124 catchret from %p to label %cont
127 ; CHECK-LABEL: _use_except_handler4_ssp:
129 ; CHECK-NEXT: movl %esp, %ebp
130 ; CHECK-NEXT: pushl %ebx
131 ; CHECK-NEXT: pushl %edi
132 ; CHECK-NEXT: pushl %esi
133 ; CHECK-NEXT: subl ${{[0-9]+}}, %esp
134 ; CHECK-NEXT: movl %ebp, %[[ehguard:[^ ,]*]]
135 ; CHECK-NEXT: movl %esp, -36(%ebp)
136 ; CHECK-NEXT: movl $-2, -16(%ebp)
137 ; CHECK-NEXT: movl $L__ehtable$use_except_handler4_ssp, %[[lsda:[^ ,]*]]
138 ; CHECK-NEXT: movl ___security_cookie, %[[seccookie:[^ ,]*]]
139 ; CHECK-NEXT: xorl %[[seccookie]], %[[lsda]]
140 ; CHECK-NEXT: movl %[[lsda]], -20(%ebp)
141 ; CHECK-NEXT: xorl %[[seccookie]], %[[ehguard]]
142 ; CHECK-NEXT: movl %[[ehguard]], -40(%ebp)
143 ; CHECK-NEXT: leal -28(%ebp), %[[node:[^ ,]*]]
144 ; CHECK-NEXT: movl $__except_handler4, -24(%ebp)
145 ; CHECK-NEXT: movl %fs:0, %[[next:[^ ,]*]]
146 ; CHECK-NEXT: movl %[[next]], -28(%ebp)
147 ; CHECK-NEXT: movl %[[node]], %fs:0
148 ; CHECK-NEXT: movl $0, -16(%ebp)
149 ; CHECK-NEXT: calll _may_throw_or_crash
150 ; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
151 ; CHECK-NEXT: movl %[[next]], %fs:0
153 ; CHECK-NEXT: [[catch:[^ ,]*]]: # %catch{{$}}
157 ; CHECK: .section .xdata,"dr"
158 ; CHECK-LABEL: L__ehtable$use_except_handler4_ssp:
159 ; CHECK-NEXT: .long -2
160 ; CHECK-NEXT: .long 0
161 ; CHECK-NEXT: .long -40
162 ; CHECK-NEXT: .long 0
163 ; CHECK-NEXT: .long -2
164 ; CHECK-NEXT: .long _catchall_filt
165 ; CHECK-NEXT: .long [[catch]]
167 define void @use_CxxFrameHandler3() personality i32 (...)* @__CxxFrameHandler3 {
168 invoke void @may_throw_or_crash()
169 to label %cont unwind label %catchall
174 %cs = catchswitch within none [label %catch] unwind to caller
176 %p = catchpad within %cs [i8* null, i32 64, i8* null]
177 catchret from %p to label %cont
180 ; CHECK-LABEL: _use_CxxFrameHandler3:
182 ; CHECK-NEXT: movl %esp, %ebp
183 ; CHECK-NEXT: pushl %ebx
184 ; CHECK-NEXT: pushl %edi
185 ; CHECK-NEXT: pushl %esi
186 ; CHECK-NEXT: subl ${{[0-9]+}}, %esp
187 ; CHECK-NEXT: movl %esp, -28(%ebp)
188 ; CHECK-NEXT: movl $-1, -16(%ebp)
189 ; CHECK-NEXT: leal -24(%ebp), %[[node:[^ ,]*]]
190 ; CHECK-NEXT: movl $___ehhandler$use_CxxFrameHandler3, -20(%ebp)
191 ; CHECK-NEXT: movl %fs:0, %[[next:[^ ,]*]]
192 ; CHECK-NEXT: movl %[[next]], -24(%ebp)
193 ; CHECK-NEXT: movl %[[node]], %fs:0
194 ; CHECK-NEXT: movl $0, -16(%ebp)
195 ; CHECK-NEXT: calll _may_throw_or_crash
196 ; CHECK: movl -24(%ebp), %[[next:[^ ,]*]]
197 ; CHECK-NEXT: movl %[[next]], %fs:0
200 ; CHECK: .section .xdata,"dr"
201 ; CHECK-NEXT: .p2align 2
202 ; CHECK-LABEL: L__ehtable$use_CxxFrameHandler3:
203 ; CHECK-NEXT: .long 429065506
204 ; CHECK-NEXT: .long 2
205 ; CHECK-NEXT: .long ($stateUnwindMap$use_CxxFrameHandler3)
206 ; CHECK-NEXT: .long 1
207 ; CHECK-NEXT: .long ($tryMap$use_CxxFrameHandler3)
208 ; CHECK-NEXT: .long 0
209 ; CHECK-NEXT: .long 0
210 ; CHECK-NEXT: .long 0
211 ; CHECK-NEXT: .long 1
213 ; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
214 ; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
215 ; CHECK-NEXT: jmp ___CxxFrameHandler3 # TAILCALL
217 ; CHECK: .safeseh __except_handler3
218 ; CHECK-NEXT: .safeseh __except_handler4
219 ; CHECK-NEXT: .safeseh ___ehhandler$use_CxxFrameHandler3