Skip to content

Commit 795cf28

Browse files
authored
[EH] Add TryTable to StripEH (WebAssembly#7020)
1 parent 245d915 commit 795cf28

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/passes/StripEH.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ struct StripEHImpl : public WalkerPass<PostWalker<StripEHImpl>> {
5151
refinalize = true;
5252
}
5353

54+
void visitTryTable(TryTable* curr) {
55+
replaceCurrent(curr->body);
56+
refinalize = true;
57+
}
58+
5459
void visitFunction(Function* curr) {
5560
if (refinalize) {
5661
ReFinalize().walkFunctionInModule(curr, getModule());

test/lit/passes/strip-eh.wast

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
2+
;; RUN: wasm-opt %s -all --strip-eh -S -o - | filecheck %s
3+
4+
;; Remove all EH instructions and tags. Converts 'throw's into 'unreachable's.
5+
6+
(module
7+
(tag $e-i32 (param i32))
8+
(tag $e-f32 (param f32))
9+
10+
;; CHECK: (func $throw-i32 (type $0)
11+
;; CHECK-NEXT: (unreachable)
12+
;; CHECK-NEXT: )
13+
(func $throw-i32
14+
(throw $e-i32 (i32.const 0))
15+
)
16+
;; CHECK: (func $throw-f32 (type $0)
17+
;; CHECK-NEXT: (unreachable)
18+
;; CHECK-NEXT: )
19+
(func $throw-f32
20+
(throw $e-f32 (f32.const 0.0))
21+
)
22+
23+
;; CHECK: (func $try-catch (type $0)
24+
;; CHECK-NEXT: (block $out
25+
;; CHECK-NEXT: (call $throw-f32)
26+
;; CHECK-NEXT: )
27+
;; CHECK-NEXT: )
28+
(func $try-catch
29+
(block $out
30+
(try_table (catch_all $out)
31+
(call $throw-f32)
32+
)
33+
)
34+
)
35+
)

0 commit comments

Comments
 (0)