1 # RUN: llc -mtriple=wasm32-unknown-unknown -exception-model=wasm -mattr=+exception-handling -run-pass wasm-late-eh-prepare -run-pass wasm-cfg-stackify %s -o - | FileCheck %s
4 target triple = "wasm32-unknown-unknown"
6 declare i32 @__gxx_wasm_personality_v0(...)
8 define void @eh_label_test() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
11 define void @unreachable_ehpad_test() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
14 define void @empty_cleanuppad_test() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
20 # This tests 'try' and 'catch' instructions are correctly placed with respect to
21 # EH_LABEL instructions.
22 # CHECK-LABEL: name: eh_label_test
25 - { reg: '$arguments' }
30 ; TRY should be before EH_LABEL wrappers of throwing calls
33 ; CHECK-NEXT: EH_LABEL
34 ; CHECK-NEXT: CALL @foo
35 ; CHECK-NEXT: EH_LABEL
36 successors: %bb.1, %bb.2
37 EH_LABEL <mcsymbol .Ltmp0>
38 CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
39 EH_LABEL <mcsymbol .Ltmp1>
40 BR %bb.2, implicit-def dead $arguments
45 ; CATCH_ALL should be after EH_LABELs in the beginning of an EH pad.
46 ; (Sometimes there are multiple EH_LABELs in an EH pad. This test tests
47 ; that.) GLOBAL_SET should follow right after that.
51 ; CHECK-NEXT: CATCH_ALL
52 ; CHECK-NEXT: GLOBAL_SET_I32
53 EH_LABEL <mcsymbol .Ltmp2>
54 EH_LABEL <mcsymbol .Ltmp2>
55 CATCHRET %bb.2, %bb.1, implicit-def dead $arguments
58 ; predecessors: %bb.0, %bb.1
59 RETURN implicit-def dead $arguments
63 # Unreachable EH pads should be removed by LateEHPrepare.
64 # CHECK-LABEL: name: unreachable_ehpad_test
65 name: unreachable_ehpad_test
67 - { reg: '$arguments' }
72 BR %bb.2, implicit-def dead $arguments
74 ; This EH pad is unreachable, so it should be removed by LateEHPrepare
75 ; CHECK-NOT: bb.1 (landing-pad)
78 EH_LABEL <mcsymbol .Ltmp2>
79 CATCHRET %bb.2, %bb.1, implicit-def dead $arguments
83 ; predecessors: %bb.0, %bb.1
84 RETURN implicit-def dead $arguments
88 # Regression test for a bug that LateEHPrepare::addCatchAll didn't handle empty
89 # cleanup pads. (It tried to get debug info from end() iterator.)
90 name: empty_cleanuppad_test
92 - { reg: '$arguments' }
95 successors: %bb.1, %bb.3
96 EH_LABEL <mcsymbol .Ltmp0>
97 CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
98 EH_LABEL <mcsymbol .Ltmp1>
99 BR %bb.3, implicit-def dead $arguments
104 EH_LABEL <mcsymbol .Ltmp2>
108 CLEANUPRET implicit-def dead $arguments
111 RETURN implicit-def dead $arguments