1 # RUN: llc -mtriple=wasm32-unknown-unknown -exception-model=wasm -mattr=+exception-handling -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 @rethrow_arg_test() personality ptr @__gxx_wasm_personality_v0 {
11 define i32 @fix_end_function_test() personality ptr @__gxx_wasm_personality_v0 {
17 # CHECK-LABEL: name: rethrow_arg_test
18 name: rethrow_arg_test
20 - { reg: '$arguments' }
23 successors: %bb.1, %bb.3
26 EH_LABEL <mcsymbol .Ltmp0>
27 CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
28 EH_LABEL <mcsymbol .Ltmp1>
29 BR %bb.3, implicit-def dead $arguments
33 ; CHECK: bb.1 (landing-pad):
36 ; This RETHROW rethrows the exception caught by this BB's CATCH, but after
37 ; CFGStackify a TRY is placed between the CATCH and this RETHROW, so after
38 ; CFGStackify its immediate argument should become not 0, but 1.
40 EH_LABEL <mcsymbol .Ltmp2>
41 %0:i32 = CATCH &__cpp_exception, implicit-def dead $arguments
42 RETHROW 0, implicit-def dead $arguments
45 ; CHECK: bb.2 (landing-pad):
48 EH_LABEL <mcsymbol .Ltmp3>
49 %1:i32 = CATCH &__cpp_exception, implicit-def dead $arguments
50 RETHROW 0, implicit-def dead $arguments
56 RETURN implicit-def dead $arguments
60 # This function has i32 return type and the end of the function is unreachable,
61 # so CFGStackify's fixEndsAtEndOfFunction() propagates the return type while
62 # they encounter 'end' or 'delegate'. This is a regression test for a bug that
63 # we only handled 'end' but not 'delegate'.
64 # CHECK-LABEL: name: fix_end_function_test
65 name: fix_end_function_test
67 - { reg: '$arguments' }
82 ;; This TRY should have the return type i32 (127)
91 successors: %bb.1, %bb.3
92 EH_LABEL <mcsymbol .Ltmp0>
93 CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
94 EH_LABEL <mcsymbol .Ltmp1>
97 successors: %bb.2, %bb.4
98 EH_LABEL <mcsymbol .Ltmp2>
99 CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
100 EH_LABEL <mcsymbol .Ltmp3>
103 %0:i32 = CONST_I32 3, implicit-def dead $arguments
104 RETURN %0:i32, implicit-def dead $arguments
107 EH_LABEL <mcsymbol .Ltmp4>
108 %0:i32 = CATCH &__cpp_exception, implicit-def dead $arguments
109 RETHROW 0, implicit-def dead $arguments
112 EH_LABEL <mcsymbol .Ltmp5>
113 %1:i32 = CATCH &__cpp_exception, implicit-def dead $arguments
114 RETHROW 0, implicit-def dead $arguments