1 ; RUN: llc -verify-machineinstrs -mtriple=i686-pc-windows-msvc < %s | FileCheck --check-prefix=X86 %s
2 ; RUN: llc -verify-machineinstrs -mtriple=x86_64-pc-windows-msvc < %s | FileCheck --check-prefix=X64 %s
4 %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
5 %eh.CatchableType = type { i32, i8*, i32, i32, i32, i32, i8* }
6 %eh.CatchableTypeArray.1 = type { i32, [1 x %eh.CatchableType*] }
7 %eh.ThrowInfo = type { i32, i8*, i8*, i8* }
9 $"\01??_R0H@8" = comdat any
11 @"\01??_7type_info@@6B@" = external constant i8*
12 @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
15 declare void @useints(...)
16 declare void @f(i32 %p)
17 declare i32 @__CxxFrameHandler3(...)
19 define i32 @try_catch_catch() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
21 %a = call i32 @getint()
22 %b = call i32 @getint()
23 %c = call i32 @getint()
24 %d = call i32 @getint()
25 call void (...) @useints(i32 %a, i32 %b, i32 %c, i32 %d)
27 to label %try.cont unwind label %catch.dispatch
29 catch.dispatch: ; preds = %entry
30 %0 = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
31 to label %catch unwind label %catchendblock
35 to label %invoke.cont.2 unwind label %catchendblock
37 invoke.cont.2: ; preds = %catch
38 catchret %0 to label %try.cont
40 try.cont: ; preds = %entry, %invoke.cont.2, %invoke.cont.3
43 catchendblock: ; preds = %catch,
44 catchendpad unwind to caller
47 ; X86-LABEL: _try_catch_catch:
49 ; X86: movl %esp, %ebp
53 ; X86: subl ${{[0-9]+}}, %esp
59 ; X86: movl $0, -{{[0-9]+}}(%ebp)
60 ; X86: movl $1, (%esp)
62 ; X86: [[contbb:LBB0_[0-9]+]]: # %try.cont
69 ; X86: [[restorebb:LBB0_[0-9]+]]:
73 ; X86: "?catch$[[catch1bb:[0-9]+]]@?0?try_catch_catch@4HA":
74 ; X86: LBB0_[[catch1bb]]: # %catch.dispatch{{$}}
79 ; X86: movl $1, -{{[0-9]+}}(%ebp)
80 ; X86: movl $2, (%esp)
82 ; X86: movl $[[restorebb]], %eax
83 ; X86-NEXT: addl $16, %esp
87 ; X86: L__ehtable$try_catch_catch:
88 ; X86: $handlerMap$0$try_catch_catch:
90 ; X86: .long "??_R0H@8"
92 ; X86: .long "?catch$[[catch1bb]]@?0?try_catch_catch@4HA"
94 ; X64-LABEL: try_catch_catch:
100 ; X64: .seh_pushreg 7
102 ; X64: .seh_pushreg 3
103 ; X64: subq $40, %rsp
104 ; X64: .seh_stackalloc 40
105 ; X64: leaq 32(%rsp), %rbp
106 ; X64: .seh_setframe 5, 32
107 ; X64: .seh_endprologue
108 ; X64: movq $-2, (%rbp)
116 ; X64: [[contbb:\.LBB0_[0-9]+]]: # Block address taken
117 ; X64-NEXT: # %try.cont
118 ; X64: addq $40, %rsp
122 ; X64: "?catch$[[catch1bb:[0-9]+]]@?0?try_catch_catch@4HA":
123 ; X64: LBB0_[[catch1bb]]: # %catch.dispatch{{$}}
124 ; X64: movq %rdx, 16(%rsp)
126 ; X64: .seh_pushreg 5
128 ; X64: .seh_pushreg 6
130 ; X64: .seh_pushreg 7
132 ; X64: .seh_pushreg 3
133 ; X64: subq $40, %rsp
134 ; X64: .seh_stackalloc 40
135 ; X64: leaq 32(%rdx), %rbp
136 ; X64: .seh_endprologue
139 ; X64: leaq [[contbb]](%rip), %rax
140 ; X64: addq $40, %rsp
147 ; X64: $handlerMap$0$try_catch_catch:
149 ; X64: .long "??_R0H@8"@IMGREL
151 ; X64: .long "?catch$[[catch1bb]]@?0?try_catch_catch@4HA"@IMGREL
154 define i32 @try_one_csr() personality i32 (...)* @__CxxFrameHandler3 {
156 %a = call i32 @getint()
157 %b = call i32 @getint()
158 call void (...) @useints(i32 %a)
159 invoke void @f(i32 1)
160 to label %try.cont unwind label %catch.dispatch
162 catch.dispatch: ; preds = %entry
163 %0 = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
164 to label %catch unwind label %catchendblock
167 catchret %0 to label %try.cont
169 try.cont: ; preds = %entry, %invoke.cont.2, %invoke.cont.3
172 catchendblock: ; preds = %catch,
173 catchendpad unwind to caller
176 ; X64-LABEL: try_one_csr:
178 ; X64: .seh_pushreg 5
180 ; X64: .seh_pushreg 6
182 ; X64: subq $40, %rsp
183 ; X64: .seh_stackalloc 40
184 ; X64: leaq 32(%rsp), %rbp
185 ; X64: .seh_setframe 5, 32
186 ; X64: .seh_endprologue
192 ; X64: [[contbb:\.LBB1_[0-9]+]]: # Block address taken
193 ; X64-NEXT: # %try.cont
194 ; X64: addq $40, %rsp
200 ; X64: "?catch$[[catch1bb:[0-9]+]]@?0?try_one_csr@4HA":
201 ; X64: LBB1_[[catch1bb]]: # %catch.dispatch{{$}}
202 ; X64: movq %rdx, 16(%rsp)
204 ; X64: .seh_pushreg 5
206 ; X64: .seh_pushreg 6
207 ; X64: subq $40, %rsp
208 ; X64: .seh_stackalloc 40
209 ; X64: leaq 32(%rdx), %rbp
210 ; X64: .seh_endprologue
211 ; X64: leaq [[contbb]](%rip), %rax
212 ; X64: addq $40, %rsp
217 ; X64: $handlerMap$0$try_one_csr:
219 ; X64: .long "??_R0H@8"@IMGREL
221 ; X64: .long "?catch$[[catch1bb]]@?0?try_one_csr@4HA"@IMGREL
224 define i32 @try_no_csr() personality i32 (...)* @__CxxFrameHandler3 {
226 invoke void @f(i32 1)
227 to label %try.cont unwind label %catch.dispatch
229 catch.dispatch: ; preds = %entry
230 %0 = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
231 to label %catch unwind label %catchendblock
234 catchret %0 to label %try.cont
236 try.cont: ; preds = %entry, %invoke.cont.2, %invoke.cont.3
239 catchendblock: ; preds = %catch,
240 catchendpad unwind to caller
243 ; X64-LABEL: try_no_csr:
245 ; X64: .seh_pushreg 5
247 ; X64: subq $48, %rsp
248 ; X64: .seh_stackalloc 48
249 ; X64: leaq 48(%rsp), %rbp
250 ; X64: .seh_setframe 5, 48
251 ; X64: .seh_endprologue
254 ; X64: [[contbb:\.LBB2_[0-9]+]]: # Block address taken
255 ; X64-NEXT: # %try.cont
256 ; X64: addq $48, %rsp
261 ; X64: "?catch$[[catch1bb:[0-9]+]]@?0?try_no_csr@4HA":
262 ; X64: LBB2_[[catch1bb]]: # %catch.dispatch{{$}}
263 ; X64: movq %rdx, 16(%rsp)
265 ; X64: .seh_pushreg 5
266 ; X64: subq $32, %rsp
267 ; X64: .seh_stackalloc 32
268 ; X64: leaq 48(%rdx), %rbp
269 ; X64: .seh_endprologue
270 ; X64: leaq [[contbb]](%rip), %rax
271 ; X64: addq $32, %rsp
275 ; X64: $handlerMap$0$try_no_csr:
277 ; X64: .long "??_R0H@8"@IMGREL
279 ; X64: .long "?catch$[[catch1bb]]@?0?try_no_csr@4HA"@IMGREL