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 i32 @llvm.eh.typeid.for(ptr)
9 define internal i32 @catchall_filt() {
13 define void @use_except_handler3() personality ptr @_except_handler3 {
15 invoke void @may_throw_or_crash()
16 to label %cont unwind label %lpad
20 %cs = catchswitch within none [label %catch] unwind to caller
22 %p = catchpad within %cs [ptr @catchall_filt]
23 catchret from %p to label %cont
26 ; CHECK-LABEL: _use_except_handler3:
28 ; CHECK-NEXT: movl %esp, %ebp
29 ; CHECK-NEXT: pushl %ebx
30 ; CHECK-NEXT: pushl %edi
31 ; CHECK-NEXT: pushl %esi
32 ; CHECK-NEXT: subl ${{[0-9]+}}, %esp
33 ; CHECK-NEXT: movl %esp, -36(%ebp)
34 ; CHECK-NEXT: movl $-1, -16(%ebp)
35 ; CHECK-NEXT: movl $L__ehtable$use_except_handler3, -20(%ebp)
36 ; CHECK-NEXT: leal -28(%ebp), %[[node:[^ ,]*]]
37 ; CHECK-NEXT: movl $__except_handler3, -24(%ebp)
38 ; CHECK-NEXT: movl %fs:0, %[[next:[^ ,]*]]
39 ; CHECK-NEXT: movl %[[next]], -28(%ebp)
40 ; CHECK-NEXT: movl %[[node]], %fs:0
41 ; CHECK-NEXT: movl $0, -16(%ebp)
42 ; CHECK-NEXT: calll _may_throw_or_crash
44 ; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
45 ; CHECK-NEXT: movl %[[next]], %fs:0
47 ; CHECK-NEXT: LBB1_2: # %catch{{$}}
49 ; CHECK: .section .xdata,"dr"
50 ; CHECK-LABEL: L__ehtable$use_except_handler3:
51 ; CHECK-NEXT: .long -1
52 ; CHECK-NEXT: .long _catchall_filt
53 ; CHECK-NEXT: .long LBB1_2
55 define void @use_except_handler4() personality ptr @_except_handler4 {
57 invoke void @may_throw_or_crash()
58 to label %cont unwind label %lpad
62 %cs = catchswitch within none [label %catch] unwind to caller
64 %p = catchpad within %cs [ptr @catchall_filt]
65 catchret from %p to label %cont
68 ; CHECK-LABEL: _use_except_handler4:
70 ; CHECK-NEXT: movl %esp, %ebp
71 ; CHECK-NEXT: pushl %ebx
72 ; CHECK-NEXT: pushl %edi
73 ; CHECK-NEXT: pushl %esi
74 ; CHECK-NEXT: subl ${{[0-9]+}}, %esp
75 ; CHECK-NEXT: movl %ebp, %eax
76 ; CHECK-NEXT: movl %esp, -36(%ebp)
77 ; CHECK-NEXT: movl $-2, -16(%ebp)
78 ; CHECK-NEXT: movl $L__ehtable$use_except_handler4, %[[lsda:[^ ,]*]]
79 ; CHECK-NEXT: movl ___security_cookie, %[[seccookie:[^ ,]*]]
80 ; CHECK-NEXT: xorl %[[seccookie]], %[[lsda]]
81 ; CHECK-NEXT: movl %[[lsda]], -20(%ebp)
82 ; CHECK-NEXT: xorl %[[seccookie]], %[[tmp1:[^ ,]*]]
83 ; CHECK-NEXT: movl %[[tmp1]], -40(%ebp)
84 ; CHECK-NEXT: leal -28(%ebp), %[[node:[^ ,]*]]
85 ; CHECK-NEXT: movl $__except_handler4, -24(%ebp)
86 ; CHECK-NEXT: movl %fs:0, %[[next:[^ ,]*]]
87 ; CHECK-NEXT: movl %[[next]], -28(%ebp)
88 ; CHECK-NEXT: movl %[[node]], %fs:0
89 ; CHECK-NEXT: movl $0, -16(%ebp)
90 ; CHECK-NEXT: calll _may_throw_or_crash
92 ; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
93 ; CHECK-NEXT: movl %[[next]], %fs:0
94 ; CHECK-NEXT: addl $28, %esp
95 ; CHECK-NEXT: popl %esi
96 ; CHECK-NEXT: popl %edi
97 ; CHECK-NEXT: popl %ebx
98 ; CHECK-NEXT: popl %ebp
100 ; CHECK-NEXT: LBB2_2: # %catch{{$}}
102 ; CHECK: .section .xdata,"dr"
103 ; CHECK-LABEL: L__ehtable$use_except_handler4:
104 ; CHECK-NEXT: .long -2
105 ; CHECK-NEXT: .long 0
106 ; CHECK-NEXT: .long -40
107 ; CHECK-NEXT: .long 0
108 ; CHECK-NEXT: .long -2
109 ; CHECK-NEXT: .long _catchall_filt
110 ; CHECK-NEXT: .long LBB2_2
112 define void @use_except_handler4_ssp() sspstrong personality ptr @_except_handler4 {
114 invoke void @may_throw_or_crash()
115 to label %cont unwind label %lpad
119 %cs = catchswitch within none [label %catch] unwind to caller
121 %p = catchpad within %cs [ptr @catchall_filt]
122 catchret from %p to label %cont
125 ; CHECK-LABEL: _use_except_handler4_ssp:
127 ; CHECK-NEXT: movl %esp, %ebp
128 ; CHECK-NEXT: pushl %ebx
129 ; CHECK-NEXT: pushl %edi
130 ; CHECK-NEXT: pushl %esi
131 ; CHECK-NEXT: subl ${{[0-9]+}}, %esp
132 ; CHECK-NEXT: movl %ebp, %[[ehguard:[^ ,]*]]
133 ; CHECK-NEXT: movl %esp, -36(%ebp)
134 ; CHECK-NEXT: movl $-2, -16(%ebp)
135 ; CHECK-NEXT: movl $L__ehtable$use_except_handler4_ssp, %[[lsda:[^ ,]*]]
136 ; CHECK-NEXT: movl ___security_cookie, %[[seccookie:[^ ,]*]]
137 ; CHECK-NEXT: xorl %[[seccookie]], %[[lsda]]
138 ; CHECK-NEXT: movl %[[lsda]], -20(%ebp)
139 ; CHECK-NEXT: xorl %[[seccookie]], %[[ehguard]]
140 ; CHECK-NEXT: movl %[[ehguard]], -40(%ebp)
141 ; CHECK-NEXT: leal -28(%ebp), %[[node:[^ ,]*]]
142 ; CHECK-NEXT: movl $__except_handler4, -24(%ebp)
143 ; CHECK-NEXT: movl %fs:0, %[[next:[^ ,]*]]
144 ; CHECK-NEXT: movl %[[next]], -28(%ebp)
145 ; CHECK-NEXT: movl %[[node]], %fs:0
146 ; CHECK-NEXT: movl $0, -16(%ebp)
147 ; CHECK-NEXT: calll _may_throw_or_crash
148 ; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
149 ; CHECK-NEXT: movl %[[next]], %fs:0
151 ; CHECK-NEXT: [[catch:[^ ,]*]]: # %catch{{$}}
155 ; CHECK: .section .xdata,"dr"
156 ; CHECK-LABEL: L__ehtable$use_except_handler4_ssp:
157 ; CHECK-NEXT: .long -2
158 ; CHECK-NEXT: .long 0
159 ; CHECK-NEXT: .long -40
160 ; CHECK-NEXT: .long 0
161 ; CHECK-NEXT: .long -2
162 ; CHECK-NEXT: .long _catchall_filt
163 ; CHECK-NEXT: .long [[catch]]
165 define void @use_CxxFrameHandler3() personality ptr @__CxxFrameHandler3 {
166 invoke void @may_throw_or_crash()
167 to label %cont unwind label %catchall
172 %cs = catchswitch within none [label %catch] unwind to caller
174 %p = catchpad within %cs [ptr null, i32 64, ptr null]
175 catchret from %p to label %cont
178 ; CHECK-LABEL: _use_CxxFrameHandler3:
180 ; CHECK-NEXT: movl %esp, %ebp
181 ; CHECK-NEXT: pushl %ebx
182 ; CHECK-NEXT: pushl %edi
183 ; CHECK-NEXT: pushl %esi
184 ; CHECK-NEXT: subl ${{[0-9]+}}, %esp
185 ; CHECK-NEXT: movl %esp, -28(%ebp)
186 ; CHECK-NEXT: movl $-1, -16(%ebp)
187 ; CHECK-NEXT: leal -24(%ebp), %[[node:[^ ,]*]]
188 ; CHECK-NEXT: movl $___ehhandler$use_CxxFrameHandler3, -20(%ebp)
189 ; CHECK-NEXT: movl %fs:0, %[[next:[^ ,]*]]
190 ; CHECK-NEXT: movl %[[next]], -24(%ebp)
191 ; CHECK-NEXT: movl %[[node]], %fs:0
192 ; CHECK-NEXT: movl $0, -16(%ebp)
193 ; CHECK-NEXT: calll _may_throw_or_crash
194 ; CHECK: movl -24(%ebp), %[[next:[^ ,]*]]
195 ; CHECK-NEXT: movl %[[next]], %fs:0
198 ; CHECK: .section .xdata,"dr"
199 ; CHECK-NEXT: .p2align 2
200 ; CHECK-LABEL: L__ehtable$use_CxxFrameHandler3:
201 ; CHECK-NEXT: .long 429065506
202 ; CHECK-NEXT: .long 2
203 ; CHECK-NEXT: .long ($stateUnwindMap$use_CxxFrameHandler3)
204 ; CHECK-NEXT: .long 1
205 ; CHECK-NEXT: .long ($tryMap$use_CxxFrameHandler3)
206 ; CHECK-NEXT: .long 0
207 ; CHECK-NEXT: .long 0
208 ; CHECK-NEXT: .long 0
209 ; CHECK-NEXT: .long 1
211 ; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
212 ; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
213 ; CHECK-NEXT: jmp ___CxxFrameHandler3 # TAILCALL
215 ; CHECK: .safeseh __except_handler3
216 ; CHECK-NEXT: .safeseh __except_handler4
217 ; CHECK-NEXT: .safeseh ___ehhandler$use_CxxFrameHandler3