2 ; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -disable-block-placement -verify-machineinstrs -fast-isel=false -machine-sink-split-probability-threshold=0 -cgp-freq-ratio-to-skip-merge=1000 -exception-model=wasm -mattr=+exception-handling | FileCheck %s
3 ; RUN: llc < %s -O0 -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -verify-machineinstrs -exception-model=wasm -mattr=+exception-handling | FileCheck %s --check-prefix=NOOPT
4 ; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -disable-block-placement -verify-machineinstrs -fast-isel=false -machine-sink-split-probability-threshold=0 -cgp-freq-ratio-to-skip-merge=1000 -exception-model=wasm -mattr=+exception-handling -wasm-disable-ehpad-sort | FileCheck %s --check-prefix=NOSORT
5 ; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -disable-block-placement -verify-machineinstrs -fast-isel=false -machine-sink-split-probability-threshold=0 -cgp-freq-ratio-to-skip-merge=1000 -exception-model=wasm -mattr=+exception-handling -wasm-disable-ehpad-sort -stats 2>&1 | FileCheck %s --check-prefix=NOSORT-STAT
7 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
8 target triple = "wasm32-unknown-unknown"
10 @_ZTIi = external constant i8*
11 @_ZTId = external constant i8*
13 ; Simple test case with two catch clauses
29 ; CHECK: br_if 0, {{.*}} # 0: down to label2
30 ; CHECK: i32.call $drop=, __cxa_begin_catch
31 ; CHECK: call __cxa_end_catch
32 ; CHECK: br 1 # 1: down to label0
33 ; CHECK: end_block # label2:
35 ; CHECK: br_if 0, {{.*}} # 0: down to label3
36 ; CHECK: i32.call $drop=, __cxa_begin_catch
37 ; CHECK: call __cxa_end_catch
38 ; CHECK: br 1 # 1: down to label0
39 ; CHECK: end_block # label3:
40 ; CHECK: rethrow {{.*}} # to caller
41 ; CHECK: end_try # label0:
42 define void @test0() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
45 to label %try.cont unwind label %catch.dispatch
47 catch.dispatch: ; preds = %entry
48 %0 = catchswitch within none [label %catch.start] unwind to caller
50 catch.start: ; preds = %catch.dispatch
51 %1 = catchpad within %0 [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
52 %2 = call i8* @llvm.wasm.get.exception(token %1)
53 %3 = call i32 @llvm.wasm.get.ehselector(token %1)
54 %4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
55 %matches = icmp eq i32 %3, %4
56 br i1 %matches, label %catch2, label %catch.fallthrough
58 catch2: ; preds = %catch.start
59 %5 = call i8* @__cxa_begin_catch(i8* %2) [ "funclet"(token %1) ]
60 call void @__cxa_end_catch() [ "funclet"(token %1) ]
61 catchret from %1 to label %try.cont
63 catch.fallthrough: ; preds = %catch.start
64 %6 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*))
65 %matches1 = icmp eq i32 %3, %6
66 br i1 %matches1, label %catch, label %rethrow
68 catch: ; preds = %catch.fallthrough
69 %7 = call i8* @__cxa_begin_catch(i8* %2) [ "funclet"(token %1) ]
70 call void @__cxa_end_catch() [ "funclet"(token %1) ]
71 catchret from %1 to label %try.cont
73 rethrow: ; preds = %catch.fallthrough
74 call void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %1) ]
77 try.cont: ; preds = %catch, %catch2, %entry
81 ; Nested try-catches within a catch
100 ; CHECK: br_if 0, {{.*}} # 0: down to label7
101 ; CHECK: i32.call $drop=, __cxa_begin_catch
104 ; CHECK: br 2 # 2: down to label6
108 ; CHECK: br_if 0, {{.*}} # 0: down to label11
109 ; CHECK: i32.call $drop=, __cxa_begin_catch
112 ; CHECK: br 2 # 2: down to label9
114 ; CHECK: call __cxa_end_catch
115 ; CHECK: rethrow {{.*}} # down to catch3
117 ; CHECK: end_block # label11:
118 ; CHECK: rethrow {{.*}} # down to catch3
119 ; CHECK: catch {{.*}} # catch3:
120 ; CHECK: call __cxa_end_catch
121 ; CHECK: rethrow {{.*}} # to caller
122 ; CHECK: end_try # label9:
123 ; CHECK: call __cxa_end_catch
124 ; CHECK: br 2 # 2: down to label6
126 ; CHECK: end_block # label7:
127 ; CHECK: rethrow {{.*}} # to caller
128 ; CHECK: end_block # label6:
129 ; CHECK: call __cxa_end_catch
131 define void @test1() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
134 to label %try.cont11 unwind label %catch.dispatch
136 catch.dispatch: ; preds = %entry
137 %0 = catchswitch within none [label %catch.start] unwind to caller
139 catch.start: ; preds = %catch.dispatch
140 %1 = catchpad within %0 [i8* bitcast (i8** @_ZTIi to i8*)]
141 %2 = call i8* @llvm.wasm.get.exception(token %1)
142 %3 = call i32 @llvm.wasm.get.ehselector(token %1)
143 %4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
144 %matches = icmp eq i32 %3, %4
145 br i1 %matches, label %catch, label %rethrow
147 catch: ; preds = %catch.start
148 %5 = call i8* @__cxa_begin_catch(i8* %2) [ "funclet"(token %1) ]
149 %6 = bitcast i8* %5 to i32*
150 %7 = load i32, i32* %6, align 4
151 invoke void @foo() [ "funclet"(token %1) ]
152 to label %try.cont unwind label %catch.dispatch2
154 catch.dispatch2: ; preds = %catch
155 %8 = catchswitch within %1 [label %catch.start3] unwind label %ehcleanup9
157 catch.start3: ; preds = %catch.dispatch2
158 %9 = catchpad within %8 [i8* bitcast (i8** @_ZTIi to i8*)]
159 %10 = call i8* @llvm.wasm.get.exception(token %9)
160 %11 = call i32 @llvm.wasm.get.ehselector(token %9)
161 %12 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
162 %matches4 = icmp eq i32 %11, %12
163 br i1 %matches4, label %catch6, label %rethrow5
165 catch6: ; preds = %catch.start3
166 %13 = call i8* @__cxa_begin_catch(i8* %10) [ "funclet"(token %9) ]
167 %14 = bitcast i8* %13 to i32*
168 %15 = load i32, i32* %14, align 4
169 invoke void @foo() [ "funclet"(token %9) ]
170 to label %invoke.cont8 unwind label %ehcleanup
172 invoke.cont8: ; preds = %catch6
173 call void @__cxa_end_catch() [ "funclet"(token %9) ]
174 catchret from %9 to label %try.cont
176 rethrow5: ; preds = %catch.start3
177 invoke void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %9) ]
178 to label %unreachable unwind label %ehcleanup9
180 try.cont: ; preds = %invoke.cont8, %catch
181 call void @__cxa_end_catch() [ "funclet"(token %1) ]
182 catchret from %1 to label %try.cont11
184 rethrow: ; preds = %catch.start
185 call void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %1) ]
188 try.cont11: ; preds = %try.cont, %entry
191 ehcleanup: ; preds = %catch6
192 %16 = cleanuppad within %9 []
193 call void @__cxa_end_catch() [ "funclet"(token %16) ]
194 cleanupret from %16 unwind label %ehcleanup9
196 ehcleanup9: ; preds = %ehcleanup, %rethrow5, %catch.dispatch2
197 %17 = cleanuppad within %1 []
198 call void @__cxa_end_catch() [ "funclet"(token %17) ]
199 cleanupret from %17 unwind to caller
201 unreachable: ; preds = %rethrow5
205 ; Nested loop within a catch clause
210 ; for (int i = 0; i < 50; i++)
219 ; CHECK: i32.call $drop=, __cxa_begin_catch
220 ; CHECK: loop # label15:
223 ; CHECK: br_if 0, {{.*}} # 0: down to label17
226 ; CHECK: br 2 # 2: down to label16
229 ; CHECK: call __cxa_end_catch
231 ; CHECK: call __clang_call_terminate
234 ; CHECK: rethrow {{.*}} # to caller
236 ; CHECK: end_block # label17:
237 ; CHECK: call __cxa_end_catch
238 ; CHECK: br 2 # 2: down to label13
239 ; CHECK: end_block # label16:
240 ; CHECK: br 0 # 0: up to label15
242 ; CHECK: end_try # label13:
243 define void @test2() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
246 to label %try.cont unwind label %catch.dispatch
248 catch.dispatch: ; preds = %entry
249 %0 = catchswitch within none [label %catch.start] unwind to caller
251 catch.start: ; preds = %catch.dispatch
252 %1 = catchpad within %0 [i8* null]
253 %2 = call i8* @llvm.wasm.get.exception(token %1)
254 %3 = call i32 @llvm.wasm.get.ehselector(token %1)
255 %4 = call i8* @__cxa_begin_catch(i8* %2) [ "funclet"(token %1) ]
258 for.cond: ; preds = %for.inc, %catch.start
259 %i.0 = phi i32 [ 0, %catch.start ], [ %inc, %for.inc ]
260 %cmp = icmp slt i32 %i.0, 50
261 br i1 %cmp, label %for.body, label %for.end
263 for.body: ; preds = %for.cond
264 invoke void @foo() [ "funclet"(token %1) ]
265 to label %for.inc unwind label %ehcleanup
267 for.inc: ; preds = %for.body
268 %inc = add nsw i32 %i.0, 1
271 for.end: ; preds = %for.cond
272 call void @__cxa_end_catch() [ "funclet"(token %1) ]
273 catchret from %1 to label %try.cont
275 try.cont: ; preds = %for.end, %entry
278 ehcleanup: ; preds = %for.body
279 %5 = cleanuppad within %1 []
280 invoke void @__cxa_end_catch() [ "funclet"(token %5) ]
281 to label %invoke.cont2 unwind label %terminate
283 invoke.cont2: ; preds = %ehcleanup
284 cleanupret from %5 unwind to caller
286 terminate: ; preds = %ehcleanup
287 %6 = cleanuppad within %5 []
288 %7 = call i8* @llvm.wasm.get.exception(token %6)
289 call void @__clang_call_terminate(i8* %7) [ "funclet"(token %6) ]
293 ; Tests if block and try markers are correctly placed. Even if two predecessors
294 ; of the EH pad are bb2 and bb3 and their nearest common dominator is bb1, the
295 ; TRY marker should be placed at bb0 because there's a branch from bb0 to bb2,
296 ; and scopes cannot be interleaved.
308 ; NOOPT: catch {{.*}}
310 define void @test3() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
312 br i1 undef, label %bb1, label %bb2
315 br i1 undef, label %bb3, label %bb4
322 to label %try.cont unwind label %catch.dispatch
326 to label %try.cont unwind label %catch.dispatch
328 catch.dispatch: ; preds = %bb4, %bb3
329 %0 = catchswitch within none [label %catch.start] unwind to caller
331 catch.start: ; preds = %catch.dispatch
332 %1 = catchpad within %0 [i8* null]
333 %2 = call i8* @llvm.wasm.get.exception(token %1)
334 %3 = call i32 @llvm.wasm.get.ehselector(token %1)
335 catchret from %1 to label %try.cont
337 try.cont: ; preds = %catch.start, %bb4, %bb3, %bb2
341 ; Tests if try/end_try markers are placed correctly wrt loop/end_loop markers,
342 ; when try and loop markers are in the same BB and end_try and end_loop are in
350 define void @test4(i32* %p) personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
352 store volatile i32 0, i32* %p
355 loop: ; preds = %try.cont, %entry
356 store volatile i32 1, i32* %p
358 to label %try.cont unwind label %catch.dispatch
360 catch.dispatch: ; preds = %loop
361 %0 = catchswitch within none [label %catch.start] unwind to caller
363 catch.start: ; preds = %catch.dispatch
364 %1 = catchpad within %0 [i8* null]
365 %2 = call i8* @llvm.wasm.get.exception(token %1)
366 %3 = call i32 @llvm.wasm.get.ehselector(token %1)
367 catchret from %1 to label %try.cont
369 try.cont: ; preds = %catch.start, %loop
373 ; Some of test cases below are hand-tweaked by deleting some library calls to
374 ; simplify tests and changing the order of basic blocks to cause unwind
375 ; destination mismatches. And we use -wasm-disable-ehpad-sort to create maximum
376 ; number of mismatches in several tests below.
378 ; 'call bar''s original unwind destination was 'catch14', but after control flow
379 ; linearization, its unwind destination incorrectly becomes 'catch15'. We fix
380 ; this by wrapping the call with a nested try/catch/end_try and branching to the
381 ; right destination (label32).
383 ; NOSORT-LABEL: test5
388 ; --- Nested try/catch/end_try starts
391 ; NOSORT: catch $drop=
392 ; NOSORT: br 2 # 2: down to label32
394 ; --- Nested try/catch/end_try ends
395 ; NOSORT: br 2 # 2: down to label31
396 ; NOSORT: catch $drop= # catch15:
397 ; NOSORT: br 2 # 2: down to label31
399 ; NOSORT: catch $drop= # catch14:
400 ; NOSORT: end_try # label32:
401 ; NOSORT: end_block # label31:
404 define void @test5() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
407 to label %bb1 unwind label %catch.dispatch0
411 to label %try.cont unwind label %catch.dispatch1
413 catch.dispatch0: ; preds = %bb0
414 %0 = catchswitch within none [label %catch.start0] unwind to caller
416 catch.start0: ; preds = %catch.dispatch0
417 %1 = catchpad within %0 [i8* null]
418 %2 = call i8* @llvm.wasm.get.exception(token %1)
419 %3 = call i32 @llvm.wasm.get.ehselector(token %1)
420 catchret from %1 to label %try.cont
422 catch.dispatch1: ; preds = %bb1
423 %4 = catchswitch within none [label %catch.start1] unwind to caller
425 catch.start1: ; preds = %catch.dispatch1
426 %5 = catchpad within %4 [i8* null]
427 %6 = call i8* @llvm.wasm.get.exception(token %5)
428 %7 = call i32 @llvm.wasm.get.ehselector(token %5)
429 catchret from %5 to label %try.cont
431 try.cont: ; preds = %catch.start1, %catch.start0, %bb1
435 ; Two 'call bar''s original unwind destination was the caller, but after control
436 ; flow linearization, their unwind destination incorrectly becomes 'catch17'. We
437 ; fix this by wrapping the call with a nested try/catch/end_try and branching to
438 ; the right destination (label4), from which we rethrow the exception to the
441 ; And the return value of 'baz' should NOT be stackified because the BB is split
442 ; during fixing unwind mismatches.
444 ; NOSORT-LABEL: test6
447 ; --- Nested try/catch/end_try starts
450 ; NOSORT: i32.call ${{[0-9]+}}=, baz
451 ; NOSORT-NOT: i32.call $push{{.*}}=, baz
452 ; NOSORT: catch $[[REG:[0-9]+]]=
453 ; NOSORT: br 1 # 1: down to label35
455 ; --- Nested try/catch/end_try ends
457 ; NOSORT: catch $drop= # catch17:
459 ; NOSORT: end_try # label35:
460 ; NOSORT: rethrow $[[REG]] # to caller
462 define void @test6() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
465 to label %bb1 unwind label %catch.dispatch0
469 %call = call i32 @baz()
470 call void @nothrow(i32 %call) #0
473 catch.dispatch0: ; preds = %bb0
474 %0 = catchswitch within none [label %catch.start0] unwind to caller
476 catch.start0: ; preds = %catch.dispatch0
477 %1 = catchpad within %0 [i8* null]
478 %2 = call i8* @llvm.wasm.get.exception(token %1)
479 %3 = call i32 @llvm.wasm.get.ehselector(token %1)
480 catchret from %1 to label %try.cont
482 try.cont: ; preds = %catch.start0
486 ; If not for the unwind destination mismatch, the LOOP marker here would have an
487 ; i32 signature. But because we add a rethrow instruction at the end of the
488 ; appendix block, now the LOOP marker does not have a signature (= has a void
489 ; signature). Here the two calls two 'bar' are supposed to throw up to the
490 ; caller, but incorrectly unwind to 'catch19' after linearizing the CFG.
492 ; NOSORT-LABEL: test7
494 ; NOSORT-NOT: loop i32
495 ; NOSORT: loop # label38:
498 ; --- Nested try/catch/end_try starts
502 ; NOSORT: catch $[[REG:[0-9]+]]=
503 ; NOSORT: br 1 # 1: down to label39
505 ; --- Nested try/catch/end_try ends
506 ; NOSORT: return {{.*}}
507 ; NOSORT: catch $drop= # catch19:
508 ; NOSORT: br 1 # 1: up to label38
509 ; NOSORT: end_try # label39:
512 ; NOSORT: rethrow $[[REG]] # to caller
514 define i32 @test7(i32* %p) personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
516 store volatile i32 0, i32* %p
519 loop: ; preds = %try.cont, %entry
520 store volatile i32 1, i32* %p
522 to label %bb unwind label %catch.dispatch
529 catch.dispatch: ; preds = %loop
530 %0 = catchswitch within none [label %catch.start] unwind to caller
532 catch.start: ; preds = %catch.dispatch
533 %1 = catchpad within %0 [i8* null]
534 %2 = call i8* @llvm.wasm.get.exception(token %1)
535 %3 = call i32 @llvm.wasm.get.ehselector(token %1)
536 catchret from %1 to label %try.cont
538 try.cont: ; preds = %catch.start
542 ; When we have both kinds of EH pad unwind mismatches:
543 ; - A may-throw instruction unwinds to an incorrect EH pad after linearizing the
544 ; CFG, when it is supposed to unwind to another EH pad.
545 ; - A may-throw instruction unwinds to an incorrect EH pad after linearizing the
546 ; CFG, when it is supposed to unwind to the caller.
548 ; NOSORT-LABEL: test8
554 ; --- Nested try/catch/end_try starts
557 ; NOSORT: catch $[[REG0:[0-9]+]]=
558 ; NOSORT: br 2 # 2: down to label43
560 ; --- Nested try/catch/end_try ends
561 ; NOSORT: br 2 # 2: down to label42
562 ; NOSORT: catch {{.*}}
564 ; NOSORT: br_on_exn 0, {{.*}} # 0: down to label46
565 ; --- Nested try/catch/end_try starts
567 ; NOSORT: rethrow {{.*}} # down to catch24
568 ; NOSORT: catch $[[REG1:[0-9]+]]= # catch24:
569 ; NOSORT: br 5 # 5: down to label41
571 ; --- Nested try/catch/end_try ends
572 ; NOSORT: end_block # label46:
573 ; NOSORT: i32.call $drop=, __cxa_begin_catch
574 ; --- Nested try/catch/end_try starts
576 ; NOSORT: call __cxa_end_catch
577 ; NOSORT: catch $[[REG1]]=
578 ; NOSORT: br 4 # 4: down to label41
580 ; --- Nested try/catch/end_try ends
581 ; NOSORT: br 2 # 2: down to label42
583 ; NOSORT: catch $[[REG0]]=
584 ; NOSORT: end_try # label43:
585 ; NOSORT: i32.call $drop=, __cxa_begin_catch
586 ; NOSORT: call __cxa_end_catch
587 ; NOSORT: end_block # label42:
589 ; NOSORT: end_block # label41:
590 ; NOSORT: rethrow $[[REG1]] # to caller
591 define void @test8() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
594 to label %bb1 unwind label %catch.dispatch0
598 to label %try.cont unwind label %catch.dispatch1
600 catch.dispatch0: ; preds = %bb0
601 %0 = catchswitch within none [label %catch.start0] unwind to caller
603 catch.start0: ; preds = %catch.dispatch0
604 %1 = catchpad within %0 [i8* null]
605 %2 = call i8* @llvm.wasm.get.exception(token %1)
606 %3 = call i32 @llvm.wasm.get.ehselector(token %1)
607 %4 = call i8* @__cxa_begin_catch(i8* %2) [ "funclet"(token %1) ]
608 call void @__cxa_end_catch() [ "funclet"(token %1) ]
609 catchret from %1 to label %try.cont
611 catch.dispatch1: ; preds = %bb1
612 %5 = catchswitch within none [label %catch.start1] unwind to caller
614 catch.start1: ; preds = %catch.dispatch1
615 %6 = catchpad within %5 [i8* null]
616 %7 = call i8* @llvm.wasm.get.exception(token %6)
617 %8 = call i32 @llvm.wasm.get.ehselector(token %6)
618 %9 = call i8* @__cxa_begin_catch(i8* %7) [ "funclet"(token %6) ]
619 call void @__cxa_end_catch() [ "funclet"(token %6) ]
620 catchret from %6 to label %try.cont
622 try.cont: ; preds = %catch.start1, %catch.start0, %bb1
626 ; In CFGSort, EH pads should be sorted as soon as it is available and
627 ; 'Preferred' queue and should NOT be entered into 'Ready' queue unless we are
628 ; in the middle of sorting another region that does not contain the EH pad. In
629 ; this example, 'catch.start' should be sorted right after 'if.then' is sorted
630 ; (before 'cont' is sorted) and there should not be any unwind destination
631 ; mismatches in CFGStackify.
641 define void @test9(i32 %arg) personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
643 %tobool = icmp ne i32 %arg, 0
644 br i1 %tobool, label %if.then, label %if.end
646 catch.dispatch: ; preds = %if.then
647 %0 = catchswitch within none [label %catch.start] unwind to caller
649 catch.start: ; preds = %catch.dispatch
650 %1 = catchpad within %0 [i8* null]
651 %2 = call i8* @llvm.wasm.get.exception(token %1)
652 %3 = call i32 @llvm.wasm.get.ehselector(token %1)
653 %4 = call i8* @__cxa_begin_catch(i8* %2) [ "funclet"(token %1) ]
654 call void @__cxa_end_catch() [ "funclet"(token %1) ]
655 catchret from %1 to label %if.end
657 if.then: ; preds = %entry
659 to label %cont unwind label %catch.dispatch
661 cont: ; preds = %if.then
665 if.end: ; preds = %cont, %catch.start, %entry
669 %class.Object = type { i8 }
671 ; Intrinsics like memcpy, memmove, and memset don't throw and are lowered into
672 ; calls to external symbols (not global addresses) in instruction selection,
673 ; which will be eventually lowered to library function calls.
674 ; Because this test runs with -wasm-disable-ehpad-sort, these library calls in
675 ; invoke.cont BB fall within try~end_try, but they shouldn't cause crashes or
676 ; unwinding destination mismatches in CFGStackify.
678 ; NOSORT-LABEL: test10
681 ; NOSORT: i32.call {{.*}} memcpy
682 ; NOSORT: i32.call {{.*}} memmove
683 ; NOSORT: i32.call {{.*}} memset
688 define void @test10(i8* %a, i8* %b) personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
690 %o = alloca %class.Object, align 1
692 to label %invoke.cont unwind label %ehcleanup
694 invoke.cont: ; preds = %entry
695 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %a, i8* %b, i32 100, i1 false)
696 call void @llvm.memmove.p0i8.p0i8.i32(i8* %a, i8* %b, i32 100, i1 false)
697 call void @llvm.memset.p0i8.i32(i8* %a, i8 0, i32 100, i1 false)
698 %call = call %class.Object* @_ZN6ObjectD2Ev(%class.Object* %o) #1
701 ehcleanup: ; preds = %entry
702 %0 = cleanuppad within none []
703 %call2 = call %class.Object* @_ZN6ObjectD2Ev(%class.Object* %o) #1 [ "funclet"(token %0) ]
704 cleanupret from %0 unwind to caller
707 ; Tests if 'try' marker is placed correctly. In this test, 'try' should be
708 ; placed before the call to 'nothrow_i32' and not between the call to
709 ; 'nothrow_i32' and 'fun', because the return value of 'nothrow_i32' is
710 ; stackified and pushed onto the stack to be consumed by the call to 'fun'.
712 ; CHECK-LABEL: test11
714 ; CHECK: i32.call $push{{.*}}=, nothrow_i32
715 ; CHECK: call fun, $pop{{.*}}
716 define void @test11() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
718 %call = call i32 @nothrow_i32()
719 invoke void @fun(i32 %call)
720 to label %invoke.cont unwind label %terminate
722 invoke.cont: ; preds = %entry
725 terminate: ; preds = %entry
726 %0 = cleanuppad within none []
727 %1 = tail call i8* @llvm.wasm.get.exception(token %0)
728 call void @__clang_call_terminate(i8* %1) [ "funclet"(token %0) ]
732 ; Check if the unwind destination mismatch stats are correct
733 ; NOSORT-STAT: 11 wasm-cfg-stackify - Number of EH pad unwind mismatches found
738 declare void @fun(i32)
739 ; Function Attrs: nounwind
740 declare void @nothrow(i32) #0
741 declare i32 @nothrow_i32() #0
742 ; Function Attrs: nounwind
743 declare %class.Object* @_ZN6ObjectD2Ev(%class.Object* returned) #0
744 declare i32 @__gxx_wasm_personality_v0(...)
745 declare i8* @llvm.wasm.get.exception(token)
746 declare i32 @llvm.wasm.get.ehselector(token)
747 declare void @llvm.wasm.rethrow.in.catch()
748 declare i32 @llvm.eh.typeid.for(i8*)
749 declare i8* @__cxa_begin_catch(i8*)
750 declare void @__cxa_end_catch()
751 declare void @__clang_call_terminate(i8*)
752 declare void @_ZSt9terminatev()
753 ; Function Attrs: nounwind
754 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #0
755 ; Function Attrs: nounwind
756 declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i1 immarg) #0
757 ; Function Attrs: nounwind
758 declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1 immarg) #0
760 attributes #0 = { nounwind }