blob: b2742913b5485824f681ddad83d89c213e645058 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
;; RUN: wasm-opt %s --dce -all -S -o - | filecheck %s
;; If either try_table body or any of catch handler is reachable, the whole
;; try_table construct is reachable.
(module
;; CHECK: (tag $e)
(tag $e)
;; CHECK: (tag $e-i32 (param i32))
(tag $e-i32 (param i32))
;; CHECK: (func $foo (type $0)
;; CHECK-NEXT: )
(func $foo)
;; CHECK: (func $try_table_unreachable (type $0)
;; CHECK-NEXT: (block $catch
;; CHECK-NEXT: (try_table (catch_all $catch)
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (call $foo)
;; CHECK-NEXT: )
(func $try_table_unreachable
(block $catch
(try_table (catch_all $catch)
(unreachable)
)
)
(call $foo) ;; shouldn't be dce'd
)
;; CHECK: (func $catch_unreachable (type $0)
;; CHECK-NEXT: (block $tryend
;; CHECK-NEXT: (block $catch
;; CHECK-NEXT: (try_table (catch_all $catch)
;; CHECK-NEXT: (br $tryend)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: (call $foo)
;; CHECK-NEXT: )
(func $catch_unreachable
(block $tryend
(block $catch
(try_table (catch_all $catch)
(br $tryend)
)
)
(unreachable)
)
(call $foo) ;; shouldn't be dce'd
)
;; CHECK: (func $both_unreachable (type $0)
;; CHECK-NEXT: (block $tryend
;; CHECK-NEXT: (block $catch
;; CHECK-NEXT: (try_table (catch_all $catch)
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $both_unreachable
(block $tryend
(block $catch
(try_table (catch_all $catch)
(unreachable)
)
)
(unreachable)
)
(call $foo) ;; should be dce'd
)
;; CHECK: (func $throw (type $0)
;; CHECK-NEXT: (block $label$0
;; CHECK-NEXT: (block $label$1
;; CHECK-NEXT: (throw $e)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $throw
;; All these wrapping expressions before 'throw' will be dce'd.
(drop
(block $label$0 (result externref)
(if
(i32.clz
(block $label$1 (result i32)
(throw $e)
)
)
(then
(nop)
)
)
(ref.null extern)
)
)
)
;; CHECK: (func $throw_ref (type $0)
;; CHECK-NEXT: (local $ex exnref)
;; CHECK-NEXT: (block $tryend
;; CHECK-NEXT: (local.set $ex
;; CHECK-NEXT: (block $catch (result exnref)
;; CHECK-NEXT: (try_table (catch_all_ref $catch)
;; CHECK-NEXT: (br $tryend)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (block
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (throw_ref
;; CHECK-NEXT: (local.get $ex)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $throw_ref
(local $ex exnref)
(block $tryend
(local.set $ex
(block $catch (result exnref)
(try_table (catch_all_ref $catch)
(br $tryend)
)
)
)
(drop
;; This i32.add will be dce'd.
(i32.add
(i32.const 0)
(throw_ref (local.get $ex))
)
)
)
)
)
|