1 ; RUN: llc -mtriple=x86_64-pc-windows-coreclr -verify-machineinstrs < %s | FileCheck %s
3 declare void @ProcessCLRException()
5 declare void @g(i8 addrspace(1)*)
6 declare i8 addrspace(1)* @llvm.eh.exceptionpointer.p1i8(token)
8 ; Simplified IR for pseudo-C# like the following:
30 ; CHECK-LABEL: test1: # @test1
31 ; CHECK-NEXT: [[test1_begin:.*func_begin.*]]:
32 define void @test1() personality i8* bitcast (void ()* @ProcessCLRException to i8*) {
35 ; CHECK: leaq [[FPOffset:[0-9]+]](%rsp), %rbp
36 ; CHECK: .seh_endprologue
37 ; CHECK: movq %rsp, [[PSPSymOffset:[0-9]+]](%rsp)
38 ; CHECK: [[test1_before_f1:.+]]:
39 ; CHECK-NEXT: movl $1, %ecx
41 ; CHECK-NEXT: [[test1_after_f1:.+]]:
43 to label %inner_try unwind label %finally
46 ; CHECK: [[test1_before_f2:.+]]:
47 ; CHECK-NEXT: movl $2, %ecx
49 ; CHECK-NEXT: [[test1_after_f2:.+]]:
51 to label %finally.clone unwind label %exn.dispatch
53 %catchswitch = catchswitch within none [label %catch1, label %catch2] unwind label %finally
55 %catch.pad1 = catchpad within %catchswitch [i32 1]
56 ; CHECK: .seh_proc [[test1_catch1:[^ ]+]]
57 ; CHECK: .seh_stackalloc [[FuncletFrameSize:[0-9]+]]
58 ; ^ all funclets use the same frame size
59 ; CHECK: movq [[PSPSymOffset]](%rcx), %rcx
60 ; ^ establisher frame pointer passed in rcx
61 ; CHECK: movq %rcx, [[PSPSymOffset]](%rsp)
62 ; CHECK: leaq [[FPOffset]](%rcx), %rbp
63 ; CHECK: .seh_endprologue
64 ; CHECK: movq %rdx, %rcx
65 ; ^ exception pointer passed in rdx
67 %exn1 = call i8 addrspace(1)* @llvm.eh.exceptionpointer.p1i8(token %catch.pad1)
68 call void @g(i8 addrspace(1)* %exn1) [ "funclet"(token %catch.pad1) ]
69 ; CHECK: [[test1_before_f3:.+]]:
70 ; CHECK-NEXT: movl $3, %ecx
72 ; CHECK-NEXT: [[test1_after_f3:.+]]:
73 invoke void @f(i32 3) [ "funclet"(token %catch.pad1) ]
74 to label %catch1.ret unwind label %finally
76 catchret from %catch.pad1 to label %finally.clone
78 %catch.pad2 = catchpad within %catchswitch [i32 2]
79 ; CHECK: .seh_proc [[test1_catch2:[^ ]+]]
80 ; CHECK: .seh_stackalloc [[FuncletFrameSize:[0-9]+]]
81 ; ^ all funclets use the same frame size
82 ; CHECK: movq [[PSPSymOffset]](%rcx), %rcx
83 ; ^ establisher frame pointer passed in rcx
84 ; CHECK: movq %rcx, [[PSPSymOffset]](%rsp)
85 ; CHECK: leaq [[FPOffset]](%rcx), %rbp
86 ; CHECK: .seh_endprologue
87 ; CHECK: movq %rdx, %rcx
88 ; ^ exception pointer passed in rdx
90 %exn2 = call i8 addrspace(1)* @llvm.eh.exceptionpointer.p1i8(token %catch.pad2)
91 call void @g(i8 addrspace(1)* %exn2) [ "funclet"(token %catch.pad2) ]
92 ; CHECK: [[test1_before_f4:.+]]:
93 ; CHECK-NEXT: movl $4, %ecx
95 ; CHECK-NEXT: [[test1_after_f4:.+]]:
96 invoke void @f(i32 4) [ "funclet"(token %catch.pad2) ]
97 to label %try_in_catch unwind label %finally
99 ; CHECK: # %try_in_catch
100 ; CHECK: [[test1_before_f5:.+]]:
101 ; CHECK-NEXT: movl $5, %ecx
102 ; CHECK-NEXT: callq f
103 ; CHECK-NEXT: [[test1_after_f5:.+]]:
104 invoke void @f(i32 5) [ "funclet"(token %catch.pad2) ]
105 to label %catch2.ret unwind label %fault
107 ; CHECK: .seh_proc [[test1_fault:[^ ]+]]
108 %fault.pad = cleanuppad within %catch.pad2 [i32 undef]
109 ; CHECK: .seh_stackalloc [[FuncletFrameSize:[0-9]+]]
110 ; ^ all funclets use the same frame size
111 ; CHECK: movq [[PSPSymOffset]](%rcx), %rcx
112 ; ^ establisher frame pointer passed in rcx
113 ; CHECK: movq %rcx, [[PSPSymOffset]](%rsp)
114 ; CHECK: leaq [[FPOffset]](%rcx), %rbp
115 ; CHECK: .seh_endprologue
116 ; CHECK: [[test1_before_f6:.+]]:
117 ; CHECK-NEXT: movl $6, %ecx
118 ; CHECK-NEXT: callq f
119 ; CHECK-NEXT: [[test1_after_f6:.+]]:
120 invoke void @f(i32 6) [ "funclet"(token %fault.pad) ]
121 to label %fault.ret unwind label %finally
123 cleanupret from %fault.pad unwind label %finally
125 catchret from %catch.pad2 to label %finally.clone
130 ; CHECK: .seh_proc [[test1_finally:[^ ]+]]
131 %finally.pad = cleanuppad within none []
132 ; CHECK: .seh_stackalloc [[FuncletFrameSize:[0-9]+]]
133 ; ^ all funclets use the same frame size
134 ; CHECK: movq [[PSPSymOffset]](%rcx), %rcx
135 ; ^ establisher frame pointer passed in rcx
136 ; CHECK: movq %rcx, [[PSPSymOffset]](%rsp)
137 ; CHECK: leaq [[FPOffset]](%rcx), %rbp
138 ; CHECK: .seh_endprologue
139 ; CHECK-NEXT: movl $7, %ecx
140 ; CHECK-NEXT: callq f
141 call void @f(i32 7) [ "funclet"(token %finally.pad) ]
142 cleanupret from %finally.pad unwind to caller
146 ; CHECK: [[test1_end:.*func_end.*]]:
149 ; Now check for EH table in xdata (following standard xdata)
150 ; CHECK-LABEL: .section .xdata
151 ; standard xdata comes here
152 ; CHECK: .long 4{{$}}
153 ; ^ number of funclets
154 ; CHECK-NEXT: .long [[test1_catch1]]-[[test1_begin]]
155 ; ^ offset from L_begin to start of 1st funclet
156 ; CHECK-NEXT: .long [[test1_catch2]]-[[test1_begin]]
157 ; ^ offset from L_begin to start of 2nd funclet
158 ; CHECK-NEXT: .long [[test1_fault]]-[[test1_begin]]
159 ; ^ offset from L_begin to start of 3rd funclet
160 ; CHECK-NEXT: .long [[test1_finally]]-[[test1_begin]]
161 ; ^ offset from L_begin to start of 4th funclet
162 ; CHECK-NEXT: .long [[test1_end]]-[[test1_begin]]
163 ; ^ offset from L_begin to end of last funclet
164 ; CHECK-NEXT: .long 7
165 ; ^ number of EH clauses
166 ; Clause 1: call f(2) is guarded by catch1
167 ; CHECK-NEXT: .long 0
168 ; ^ flags (0 => catch handler)
169 ; CHECK-NEXT: .long ([[test1_before_f2]]-[[test1_begin]])+1
170 ; ^ offset of start of clause
171 ; CHECK-NEXT: .long ([[test1_after_f2]]-[[test1_begin]])+1
172 ; ^ offset of end of clause
173 ; CHECK-NEXT: .long [[test1_catch1]]-[[test1_begin]]
174 ; ^ offset of start of handler
175 ; CHECK-NEXT: .long [[test1_catch2]]-[[test1_begin]]
176 ; ^ offset of end of handler
177 ; CHECK-NEXT: .long 1
178 ; ^ type token of catch (from catchpad)
179 ; Clause 2: call f(2) is also guarded by catch2
180 ; CHECK-NEXT: .long 0
181 ; ^ flags (0 => catch handler)
182 ; CHECK-NEXT: .long ([[test1_before_f2]]-[[test1_begin]])+1
183 ; ^ offset of start of clause
184 ; CHECK-NEXT: .long ([[test1_after_f2]]-[[test1_begin]])+1
185 ; ^ offset of end of clause
186 ; CHECK-NEXT: .long [[test1_catch2]]-[[test1_begin]]
187 ; ^ offset of start of handler
188 ; CHECK-NEXT: .long [[test1_fault]]-[[test1_begin]]
189 ; ^ offset of end of handler
190 ; CHECK-NEXT: .long 2
191 ; ^ type token of catch (from catchpad)
192 ; Clause 3: calls f(1) and f(2) are guarded by finally
193 ; CHECK-NEXT: .long 2
194 ; ^ flags (2 => finally handler)
195 ; CHECK-NEXT: .long ([[test1_before_f1]]-[[test1_begin]])+1
196 ; ^ offset of start of clause
197 ; CHECK-NEXT: .long ([[test1_after_f2]]-[[test1_begin]])+1
198 ; ^ offset of end of clause
199 ; CHECK-NEXT: .long [[test1_finally]]-[[test1_begin]]
200 ; ^ offset of start of handler
201 ; CHECK-NEXT: .long [[test1_end]]-[[test1_begin]]
202 ; ^ offset of end of handler
203 ; CHECK-NEXT: .long 0
204 ; ^ type token slot (null for finally)
205 ; Clause 4: call f(3) is guarded by finally
206 ; This is a "duplicate" because the protected range (f(3))
207 ; is in funclet catch1 but the finally's immediate parent
208 ; is the main function, not that funclet.
209 ; CHECK-NEXT: .long 10
210 ; ^ flags (2 => finally handler | 8 => duplicate)
211 ; CHECK-NEXT: .long ([[test1_before_f3]]-[[test1_begin]])+1
212 ; ^ offset of start of clause
213 ; CHECK-NEXT: .long ([[test1_after_f3]]-[[test1_begin]])+1
214 ; ^ offset of end of clause
215 ; CHECK-NEXT: .long [[test1_finally]]-[[test1_begin]]
216 ; ^ offset of start of handler
217 ; CHECK-NEXT: .long [[test1_end]]-[[test1_begin]]
218 ; ^ offset of end of handler
219 ; CHECK-NEXT: .long 0
220 ; ^ type token slot (null for finally)
221 ; Clause 5: call f(5) is guarded by fault
222 ; CHECK-NEXT: .long 4
223 ; ^ flags (4 => fault handler)
224 ; CHECK-NEXT: .long ([[test1_before_f5]]-[[test1_begin]])+1
225 ; ^ offset of start of clause
226 ; CHECK-NEXT: .long ([[test1_after_f5]]-[[test1_begin]])+1
227 ; ^ offset of end of clause
228 ; CHECK-NEXT: .long [[test1_fault]]-[[test1_begin]]
229 ; ^ offset of start of handler
230 ; CHECK-NEXT: .long [[test1_finally]]-[[test1_begin]]
231 ; ^ offset of end of handler
232 ; CHECK-NEXT: .long 0
233 ; ^ type token slot (null for fault)
234 ; Clause 6: calls f(4) and f(5) are guarded by finally
235 ; This is a "duplicate" because the protected range (f(4)-f(5))
236 ; is in funclet catch2 but the finally's immediate parent
237 ; is the main function, not that funclet.
238 ; CHECK-NEXT: .long 10
239 ; ^ flags (2 => finally handler | 8 => duplicate)
240 ; CHECK-NEXT: .long ([[test1_before_f4]]-[[test1_begin]])+1
241 ; ^ offset of start of clause
242 ; CHECK-NEXT: .long ([[test1_after_f5]]-[[test1_begin]])+1
243 ; ^ offset of end of clause
244 ; CHECK-NEXT: .long [[test1_finally]]-[[test1_begin]]
245 ; ^ offset of start of handler
246 ; CHECK-NEXT: .long [[test1_end]]-[[test1_begin]]
247 ; ^ offset of end of handler
248 ; CHECK-NEXT: .long 0
249 ; ^ type token slot (null for finally)
250 ; Clause 7: call f(6) is guarded by finally
251 ; This is a "duplicate" because the protected range (f(3))
252 ; is in funclet catch1 but the finally's immediate parent
253 ; is the main function, not that funclet.
254 ; CHECK-NEXT: .long 10
255 ; ^ flags (2 => finally handler | 8 => duplicate)
256 ; CHECK-NEXT: .long ([[test1_before_f6]]-[[test1_begin]])+1
257 ; ^ offset of start of clause
258 ; CHECK-NEXT: .long ([[test1_after_f6]]-[[test1_begin]])+1
259 ; ^ offset of end of clause
260 ; CHECK-NEXT: .long [[test1_finally]]-[[test1_begin]]
261 ; ^ offset of start of handler
262 ; CHECK-NEXT: .long [[test1_end]]-[[test1_begin]]
263 ; ^ offset of end of handler
264 ; CHECK-NEXT: .long 0
265 ; ^ type token slot (null for finally)
267 ; Test with a cleanup that has no cleanupret, and thus needs its unwind dest
268 ; inferred from an inner catchswitch
270 ; corresponds to C# along the lines of:
286 define void @test2() personality i8* bitcast (void ()* @ProcessCLRException to i8*) {
288 invoke void @f(i32 1)
289 to label %exit unwind label %fault
291 %fault.pad = cleanuppad within none [i32 undef]
292 invoke void @f(i32 2) ["funclet"(token %fault.pad)]
293 to label %unreachable unwind label %exn.dispatch.inner
295 %catchswitch.inner = catchswitch within %fault.pad [label %catch1] unwind label %exn.dispatch.outer
297 %catch.pad1 = catchpad within %catchswitch.inner [i32 1]
298 catchret from %catch.pad1 to label %unreachable
300 %catchswitch.outer = catchswitch within none [label %catch2] unwind to caller
302 %catch.pad2 = catchpad within %catchswitch.outer [i32 2]
303 catchret from %catch.pad2 to label %exit
309 ; CHECK-LABEL: test2: # @test2
310 ; CHECK-NEXT: [[test2_begin:.*func_begin.*]]:
311 ; CHECK: .seh_endprologue
312 ; CHECK: [[test2_before_f1:.+]]:
313 ; CHECK-NEXT: movl $1, %ecx
314 ; CHECK-NEXT: callq f
315 ; CHECK-NEXT: [[test2_after_f1:.+]]:
316 ; CHECK: .seh_proc [[test2_catch1:[^ ]+]]
317 ; CHECK: .seh_proc [[test2_catch2:[^ ]+]]
318 ; CHECK: .seh_proc [[test2_fault:[^ ]+]]
319 ; CHECK: .seh_endprologue
320 ; CHECK: [[test2_before_f2:.+]]:
321 ; CHECK-NEXT: movl $2, %ecx
322 ; CHECK-NEXT: callq f
323 ; CHECK-NEXT: [[test2_after_f2:.+]]:
324 ; CHECK: [[test2_end:.*func_end.*]]:
327 ; Now check for EH table in xdata (following standard xdata)
328 ; CHECK-LABEL: .section .xdata
329 ; standard xdata comes here
330 ; CHECK: .long 3{{$}}
331 ; ^ number of funclets
332 ; CHECK-NEXT: .long [[test2_catch1]]-[[test2_begin]]
333 ; ^ offset from L_begin to start of 2nd funclet
334 ; CHECK-NEXT: .long [[test2_catch2]]-[[test2_begin]]
335 ; ^ offset from L_begin to start of 3rd funclet
336 ; CHECK-NEXT: .long [[test2_fault]]-[[test2_begin]]
337 ; ^ offset from L_begin to start of 1st funclet
338 ; CHECK-NEXT: .long [[test2_end]]-[[test2_begin]]
339 ; ^ offset from L_begin to end of last funclet
340 ; CHECK-NEXT: .long 4
341 ; ^ number of EH clauses
342 ; Clause 1: call f(1) is guarded by fault
343 ; CHECK-NEXT: .long 4
344 ; ^ flags (4 => fault handler)
345 ; CHECK-NEXT: .long ([[test2_before_f1]]-[[test2_begin]])+1
346 ; ^ offset of start of clause
347 ; CHECK-NEXT: .long ([[test2_after_f1]]-[[test2_begin]])+1
348 ; ^ offset of end of clause
349 ; CHECK-NEXT: .long [[test2_fault]]-[[test2_begin]]
350 ; ^ offset of start of handler
351 ; CHECK-NEXT: .long [[test2_end]]-[[test2_begin]]
352 ; ^ offset of end of handler
353 ; CHECK-NEXT: .long 0
354 ; ^ type token slot (null for fault)
355 ; Clause 2: call f(1) is also guarded by catch2
356 ; CHECK-NEXT: .long 0
357 ; ^ flags (0 => catch handler)
358 ; CHECK-NEXT: .long ([[test2_before_f1]]-[[test2_begin]])+1
359 ; ^ offset of start of clause
360 ; CHECK-NEXT: .long ([[test2_after_f1]]-[[test2_begin]])+1
361 ; ^ offset of end of clause
362 ; CHECK-NEXT: .long [[test2_catch2]]-[[test2_begin]]
363 ; ^ offset of start of handler
364 ; CHECK-NEXT: .long [[test2_fault]]-[[test2_begin]]
365 ; ^ offset of end of handler
366 ; CHECK-NEXT: .long 2
367 ; ^ type token of catch (from catchpad)
368 ; Clause 3: calls f(2) is guarded by catch1
369 ; CHECK-NEXT: .long 0
370 ; ^ flags (0 => catch handler)
371 ; CHECK-NEXT: .long ([[test2_before_f2]]-[[test2_begin]])+1
372 ; ^ offset of start of clause
373 ; CHECK-NEXT: .long ([[test2_after_f2]]-[[test2_begin]])+1
374 ; ^ offset of end of clause
375 ; CHECK-NEXT: .long [[test2_catch1]]-[[test2_begin]]
376 ; ^ offset of start of handler
377 ; CHECK-NEXT: .long [[test2_catch2]]-[[test2_begin]]
378 ; ^ offset of end of handler
379 ; CHECK-NEXT: .long 1
380 ; ^ type token of catch (from catchpad)
381 ; Clause 4: call f(2) is also guarded by catch2
382 ; This is a "duplicate" because the protected range (f(2))
383 ; is in funclet fault but catch2's immediate parent
384 ; is the main function, not that funclet.
385 ; CHECK-NEXT: .long 8
386 ; ^ flags (0 => catch handler | 8 => duplicate)
387 ; CHECK-NEXT: .long ([[test2_before_f2]]-[[test2_begin]])+1
388 ; ^ offset of start of clause
389 ; CHECK-NEXT: .long ([[test2_after_f2]]-[[test2_begin]])+1
390 ; ^ offset of end of clause
391 ; CHECK-NEXT: .long [[test2_catch2]]-[[test2_begin]]
392 ; ^ offset of start of handler
393 ; CHECK-NEXT: .long [[test2_fault]]-[[test2_begin]]
394 ; ^ offset of end of handler
395 ; CHECK-NEXT: .long 2
396 ; ^ type token of catch (from catchpad)
398 ; Test with several cleanups that need to infer their unwind dests from each
399 ; other, the inner one needing to make the inference from an invoke, ignoring
400 ; not-really-unwinding calls/unwind-to-caller catchswitches, as well as some
401 ; internal invokes/catchswitches
403 ; Corresponds to something like:
407 ; } fault { // fault1
412 ; } fault { // fault2
415 ; } fault { // fault3
418 ; } fault { // fault4
419 ; f(5); // no unwind edge (e.g. front-end knew it wouldn't throw but
420 ; didn't bother to specify nounwind)
425 ; goto __unreachable;
427 ; } catch (type 2) { // marked "unwinds to caller" because we allow
428 ; // that if the unwind won't be taken (see
429 ; // SimplifyUnreachable & RemoveUnwindEdge)
437 ; } fault { // fault 5
442 ; CHECK-LABEL: test3: # @test3
443 ; CHECK-NEXT: [[test3_begin:.*func_begin.*]]:
444 define void @test3() personality i8* bitcast (void ()* @ProcessCLRException to i8*) {
446 ; CHECK: .seh_endprologue
447 ; CHECK: [[test3_before_f1:.+]]:
448 ; CHECK-NEXT: movl $1, %ecx
449 ; CHECK-NEXT: callq f
450 ; CHECK-NEXT: [[test3_after_f1:.+]]:
451 invoke void @f(i32 1)
452 to label %exit unwind label %fault1
454 ; check lines below since this gets reordered to end-of-func
455 %fault.pad1 = cleanuppad within none [i32 undef]
456 invoke void @f(i32 2) ["funclet"(token %fault.pad1)]
457 to label %unreachable unwind label %fault2
459 ; check lines below since this gets reordered to end-of-func
460 %fault.pad2 = cleanuppad within %fault.pad1 [i32 undef]
461 invoke void @f(i32 3) ["funclet"(token %fault.pad2)]
462 to label %unreachable unwind label %fault3
464 ; check lines below since this gets reordered to end-of-func
465 %fault.pad3 = cleanuppad within %fault.pad2 [i32 undef]
466 invoke void @f(i32 4) ["funclet"(token %fault.pad3)]
467 to label %unreachable unwind label %fault4
469 ; CHECK: .seh_proc [[test3_fault4:[^ ]+]]
470 %fault.pad4 = cleanuppad within %fault.pad3 [i32 undef]
471 ; CHECK: .seh_endprologue
472 call void @f(i32 5) ["funclet"(token %fault.pad4)]
473 ; CHECK: [[test3_before_f6:.+]]:
474 ; CHECK-NEXT: movl $6, %ecx
475 ; CHECK-NEXT: callq f
476 ; CHECK-NEXT: [[test3_after_f6:.+]]:
477 invoke void @f(i32 6) ["funclet"(token %fault.pad4)]
478 to label %fault4.cont unwind label %exn.dispatch1
480 ; CHECK: # %fault4.cont
481 ; CHECK: [[test3_before_f7:.+]]:
482 ; CHECK-NEXT: movl $7, %ecx
483 ; CHECK-NEXT: callq f
484 ; CHECK-NEXT: [[test3_after_f7:.+]]:
485 invoke void @f(i32 7) ["funclet"(token %fault.pad4)]
486 to label %unreachable unwind label %fault5
488 %catchswitch1 = catchswitch within %fault.pad4 [label %catch1] unwind label %exn.dispatch2
490 %catch.pad1 = catchpad within %catchswitch1 [i32 1]
491 ; CHECK: .seh_proc [[test3_catch1:[^ ]+]]
492 catchret from %catch.pad1 to label %unreachable
494 %catchswitch2 = catchswitch within %fault.pad4 [label %catch2] unwind to caller
496 %catch.pad2 = catchpad within %catchswitch2 [i32 2]
497 ; CHECK: .seh_proc [[test3_catch2:[^ ]+]]
498 catchret from %catch.pad2 to label %unreachable
500 ; CHECK: .seh_proc [[test3_fault5:[^ ]+]]
501 %fault.pad5 = cleanuppad within %fault.pad1 [i32 undef]
502 ; CHECK: .seh_endprologue
503 cleanupret from %fault.pad5 unwind to caller
508 ; CHECK: .seh_proc [[test3_fault3:[^ ]+]]
510 ; CHECK: .seh_endprologue
511 ; CHECK: [[test3_before_f4:.+]]:
512 ; CHECK-NEXT: movl $4, %ecx
513 ; CHECK-NEXT: callq f
514 ; CHECK-NEXT: [[test3_after_f4:.+]]:
515 ; CHECK: .seh_proc [[test3_fault2:[^ ]+]]
517 ; CHECK: .seh_endprologue
518 ; CHECK: [[test3_before_f3:.+]]:
519 ; CHECK-NEXT: movl $3, %ecx
520 ; CHECK-NEXT: callq f
521 ; CHECK-NEXT: [[test3_after_f3:.+]]:
522 ; CHECK: .seh_proc [[test3_fault1:[^ ]+]]
524 ; CHECK: .seh_endprologue
525 ; CHECK: [[test3_before_f2:.+]]:
526 ; CHECK-NEXT: movl $2, %ecx
527 ; CHECK-NEXT: callq f
528 ; CHECK-NEXT: [[test3_after_f2:.+]]:
529 ; CHECK: [[test3_end:.*func_end.*]]:
532 ; Now check for EH table in xdata (following standard xdata)
533 ; CHECK-LABEL: .section .xdata
534 ; standard xdata comes here
535 ; CHECK: .long 7{{$}}
536 ; ^ number of funclets
537 ; CHECK-NEXT: .long [[test3_fault4]]-[[test3_begin]]
538 ; ^ offset from L_begin to start of 1st funclet
539 ; CHECK-NEXT: .long [[test3_catch1]]-[[test3_begin]]
540 ; ^ offset from L_begin to start of 2nd funclet
541 ; CHECK-NEXT: .long [[test3_catch2]]-[[test3_begin]]
542 ; ^ offset from L_begin to start of 3rd funclet
543 ; CHECK-NEXT: .long [[test3_fault5]]-[[test3_begin]]
544 ; ^ offset from L_begin to start of 4th funclet
545 ; CHECK-NEXT: .long [[test3_fault3]]-[[test3_begin]]
546 ; ^ offset from L_begin to start of 5th funclet
547 ; CHECK-NEXT: .long [[test3_fault2]]-[[test3_begin]]
548 ; ^ offset from L_begin to start of 6th funclet
549 ; CHECK-NEXT: .long [[test3_fault1]]-[[test3_begin]]
550 ; ^ offset from L_begin to start of 7th funclet
551 ; CHECK-NEXT: .long [[test3_end]]-[[test3_begin]]
552 ; ^ offset from L_begin to end of last funclet
553 ; CHECK-NEXT: .long 10
554 ; ^ number of EH clauses
555 ; Clause 1: call f(1) is guarded by fault1
556 ; CHECK-NEXT: .long 4
557 ; ^ flags (4 => fault handler)
558 ; CHECK-NEXT: .long ([[test3_before_f1]]-[[test3_begin]])+1
559 ; ^ offset of start of clause
560 ; CHECK-NEXT: .long ([[test3_after_f1]]-[[test3_begin]])+1
561 ; ^ offset of end of clause
562 ; CHECK-NEXT: .long [[test3_fault1]]-[[test3_begin]]
563 ; ^ offset of start of handler
564 ; CHECK-NEXT: .long [[test3_end]]-[[test3_begin]]
565 ; ^ offset of end of handler
566 ; CHECK-NEXT: .long 0
567 ; ^ type token slot (null for fault)
568 ; Clause 3: call f(6) is guarded by catch1
569 ; CHECK-NEXT: .long 0
570 ; ^ flags (0 => catch handler)
571 ; CHECK-NEXT: .long ([[test3_before_f6]]-[[test3_begin]])+1
572 ; ^ offset of start of clause
573 ; CHECK-NEXT: .long ([[test3_after_f6]]-[[test3_begin]])+1
574 ; ^ offset of end of clause
575 ; CHECK-NEXT: .long [[test3_catch1]]-[[test3_begin]]
576 ; ^ offset of start of handler
577 ; CHECK-NEXT: .long [[test3_catch2]]-[[test3_begin]]
578 ; ^ offset of end of handler
579 ; CHECK-NEXT: .long 1
580 ; ^ type token of catch (from catchpad)
581 ; Clause 3: call f(6) is also guarded by catch2
582 ; CHECK-NEXT: .long 0
583 ; ^ flags (0 => catch handler)
584 ; CHECK-NEXT: .long ([[test3_before_f6]]-[[test3_begin]])+1
585 ; ^ offset of start of clause
586 ; CHECK-NEXT: .long ([[test3_after_f6]]-[[test3_begin]])+1
587 ; ^ offset of end of clause
588 ; CHECK-NEXT: .long [[test3_catch2]]-[[test3_begin]]
589 ; ^ offset of start of handler
590 ; CHECK-NEXT: .long [[test3_fault5]]-[[test3_begin]]
591 ; ^ offset of end of handler
592 ; CHECK-NEXT: .long 2
593 ; ^ type token of catch (from catchpad)
594 ; Clause 4: call f(7) is guarded by fault5
595 ; This is a "duplicate" because the protected range (f(6)-f(7))
596 ; is in funclet fault4 but fault5's immediate parent
597 ; is fault1, not that funclet.
598 ; CHECK-NEXT: .long 12
599 ; ^ flags (4 => fault handler | 8 => duplicate)
600 ; CHECK-NEXT: .long ([[test3_before_f7]]-[[test3_begin]])+1
601 ; ^ offset of start of clause
602 ; CHECK-NEXT: .long ([[test3_after_f7]]-[[test3_begin]])+1
603 ; ^ offset of end of clause
604 ; CHECK-NEXT: .long [[test3_fault5]]-[[test3_begin]]
605 ; ^ offset of start of handler
606 ; CHECK-NEXT: .long [[test3_fault3]]-[[test3_begin]]
607 ; ^ offset of end of handler
608 ; CHECK-NEXT: .long 0
609 ; ^ type token slot (null for fault)
610 ; Clause 5: call f(4) is guarded by fault4
611 ; CHECK-NEXT: .long 4
612 ; ^ flags (4 => fault handler)
613 ; CHECK-NEXT: .long ([[test3_before_f4]]-[[test3_begin]])+1
614 ; ^ offset of start of clause
615 ; CHECK-NEXT: .long ([[test3_after_f4]]-[[test3_begin]])+1
616 ; ^ offset of end of clause
617 ; CHECK-NEXT: .long [[test3_fault4]]-[[test3_begin]]
618 ; ^ offset of start of handler
619 ; CHECK-NEXT: .long [[test3_catch1]]-[[test3_begin]]
620 ; ^ offset of end of handler
621 ; CHECK-NEXT: .long 0
622 ; ^ type token slot (null for fault)
623 ; Clause 6: call f(4) is also guarded by fault5
624 ; This is a "duplicate" because the protected range (f(4))
625 ; is in funclet fault3 but fault5's immediate parent
626 ; is fault1, not that funclet.
627 ; CHECK-NEXT: .long 12
628 ; ^ flags (4 => fault handler)
629 ; CHECK-NEXT: .long ([[test3_before_f4]]-[[test3_begin]])+1
630 ; ^ offset of start of clause
631 ; CHECK-NEXT: .long ([[test3_after_f4]]-[[test3_begin]])+1
632 ; ^ offset of end of clause
633 ; CHECK-NEXT: .long [[test3_fault5]]-[[test3_begin]]
634 ; ^ offset of start of handler
635 ; CHECK-NEXT: .long [[test3_fault3]]-[[test3_begin]]
636 ; ^ offset of end of handler
637 ; CHECK-NEXT: .long 0
638 ; ^ type token slot (null for fault)
639 ; Clause 7: call f(3) is guarded by fault3
640 ; CHECK-NEXT: .long 4
641 ; ^ flags (4 => fault handler)
642 ; CHECK-NEXT: .long ([[test3_before_f3]]-[[test3_begin]])+1
643 ; ^ offset of start of clause
644 ; CHECK-NEXT: .long ([[test3_after_f3]]-[[test3_begin]])+1
645 ; ^ offset of end of clause
646 ; CHECK-NEXT: .long [[test3_fault3]]-[[test3_begin]]
647 ; ^ offset of start of handler
648 ; CHECK-NEXT: .long [[test3_fault2]]-[[test3_begin]]
649 ; ^ offset of end of handler
650 ; CHECK-NEXT: .long 0
651 ; ^ type token slot (null for fault)
652 ; Clause 8: call f(3) is guarded by fault5
653 ; This is a "duplicate" because the protected range (f(3))
654 ; is in funclet fault2 but fault5's immediate parent
655 ; is fault1, not that funclet.
656 ; CHECK-NEXT: .long 12
657 ; ^ flags (4 => fault handler | 8 => duplicate)
658 ; CHECK-NEXT: .long ([[test3_before_f3]]-[[test3_begin]])+1
659 ; ^ offset of start of clause
660 ; CHECK-NEXT: .long ([[test3_after_f3]]-[[test3_begin]])+1
661 ; ^ offset of end of clause
662 ; CHECK-NEXT: .long [[test3_fault5]]-[[test3_begin]]
663 ; ^ offset of start of handler
664 ; CHECK-NEXT: .long [[test3_fault3]]-[[test3_begin]]
665 ; ^ offset of end of handler
666 ; CHECK-NEXT: .long 0
667 ; ^ type token slot (null for fault)
668 ; Clause 9: call f(2) is guarded by fault2
669 ; CHECK-NEXT: .long 4
670 ; ^ flags (4 => fault handler)
671 ; CHECK-NEXT: .long ([[test3_before_f2]]-[[test3_begin]])+1
672 ; ^ offset of start of clause
673 ; CHECK-NEXT: .long ([[test3_after_f2]]-[[test3_begin]])+1
674 ; ^ offset of end of clause
675 ; CHECK-NEXT: .long [[test3_fault2]]-[[test3_begin]]
676 ; ^ offset of start of handler
677 ; CHECK-NEXT: .long [[test3_fault1]]-[[test3_begin]]
678 ; ^ offset of end of handler
679 ; CHECK-NEXT: .long 0
680 ; ^ type token slot (null for fault)
681 ; Clause 10: call f(2) is guarded by fault5
682 ; CHECK-NEXT: .long 4
683 ; ^ flags (4 => fault handler)
684 ; CHECK-NEXT: .long ([[test3_before_f2]]-[[test3_begin]])+1
685 ; ^ offset of start of clause
686 ; CHECK-NEXT: .long ([[test3_after_f2]]-[[test3_begin]])+1
687 ; ^ offset of end of clause
688 ; CHECK-NEXT: .long [[test3_fault5]]-[[test3_begin]]
689 ; ^ offset of start of handler
690 ; CHECK-NEXT: .long [[test3_fault3]]-[[test3_begin]]
691 ; ^ offset of end of handler
692 ; CHECK-NEXT: .long 0
693 ; ^ type token slot (null for fault)