summaryrefslogtreecommitdiff
path: root/test/passes
diff options
context:
space:
mode:
Diffstat (limited to 'test/passes')
-rw-r--r--test/passes/code-pushing_all-features.txt42
-rw-r--r--test/passes/code-pushing_all-features.wast35
-rw-r--r--test/passes/dce_all-features.txt16
-rw-r--r--test/passes/dce_all-features.wast16
-rw-r--r--test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt24
-rw-r--r--test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast14
-rw-r--r--test/passes/instrument-locals_all-features_disable-typed-function-references.txt28
-rw-r--r--test/passes/instrument-locals_all-features_disable-typed-function-references.wast18
-rw-r--r--test/passes/optimize-instructions_all-features.txt5
-rw-r--r--test/passes/optimize-instructions_all-features.wast5
-rw-r--r--test/passes/remove-unused-module-elements_all-features.txt17
-rw-r--r--test/passes/remove-unused-module-elements_all-features.wast15
-rw-r--r--test/passes/remove-unused-names_code-folding_all-features.txt37
-rw-r--r--test/passes/remove-unused-names_code-folding_all-features.wast30
-rw-r--r--test/passes/remove-unused-names_merge-blocks_all-features.txt7
-rw-r--r--test/passes/remove-unused-names_merge-blocks_all-features.wast10
-rw-r--r--test/passes/remove-unused-names_optimize-instructions_all-features.txt59
-rw-r--r--test/passes/remove-unused-names_optimize-instructions_all-features.wast48
-rw-r--r--test/passes/rse_all-features.txt133
-rw-r--r--test/passes/rse_all-features.wast171
-rw-r--r--test/passes/simplify-locals_all-features.txt50
-rw-r--r--test/passes/simplify-locals_all-features.wast46
-rw-r--r--test/passes/vacuum_all-features.txt35
-rw-r--r--test/passes/vacuum_all-features.wast43
24 files changed, 381 insertions, 523 deletions
diff --git a/test/passes/code-pushing_all-features.txt b/test/passes/code-pushing_all-features.txt
index 30eb7e458..1f975a2dd 100644
--- a/test/passes/code-pushing_all-features.txt
+++ b/test/passes/code-pushing_all-features.txt
@@ -40,7 +40,7 @@
)
)
)
- (func $can-push-past-throw-within-try
+ (func $can-push-past-try
(local $x i32)
(block $out
(try
@@ -49,9 +49,9 @@
(i32.const 0)
)
)
- (catch
+ (catch_all
(drop
- (pop exnref)
+ (pop i32)
)
)
)
@@ -69,6 +69,36 @@
)
)
)
+ (func $foo
+ (nop)
+ )
+ (func $cant-push-past-try
+ (local $x i32)
+ (block $out
+ (local.set $x
+ (i32.const 1)
+ )
+ (try
+ (do
+ (call $foo)
+ )
+ (catch $e
+ (drop
+ (pop i32)
+ )
+ )
+ )
+ (drop
+ (i32.const 1)
+ )
+ (br_if $out
+ (i32.const 2)
+ )
+ (drop
+ (local.get $x)
+ )
+ )
+ )
(func $cant-push-past-rethrow-within-catch
(local $x i32)
(block $out
@@ -81,10 +111,8 @@
(i32.const 0)
)
)
- (catch
- (rethrow
- (pop exnref)
- )
+ (catch_all
+ (rethrow 0)
)
)
(drop
diff --git a/test/passes/code-pushing_all-features.wast b/test/passes/code-pushing_all-features.wast
index b67b98d7e..0d18afcc5 100644
--- a/test/passes/code-pushing_all-features.wast
+++ b/test/passes/code-pushing_all-features.wast
@@ -25,18 +25,39 @@
)
)
- (func $can-push-past-throw-within-try
+ (func $can-push-past-try
(local $x i32)
(block $out
;; This local.set can be pushed down, because the 'throw' below is going
- ;; to be caught by the inner catch
+ ;; to be caught by the inner catch_all
(local.set $x (i32.const 1))
(try
(do
(throw $e (i32.const 0))
)
- (catch
- (drop (pop exnref))
+ (catch_all
+ (drop (pop i32))
+ )
+ )
+ (drop (i32.const 1))
+ (br_if $out (i32.const 2))
+ (drop (local.get $x))
+ )
+ )
+
+ (func $foo)
+ (func $cant-push-past-try
+ (local $x i32)
+ (block $out
+ ;; This local.set cannot be pushed down, because the exception thrown by
+ ;; 'call $foo' below may not be caught by 'catch $e'
+ (local.set $x (i32.const 1))
+ (try
+ (do
+ (call $foo)
+ )
+ (catch $e
+ (drop (pop i32))
)
)
(drop (i32.const 1))
@@ -49,14 +70,14 @@
(local $x i32)
(block $out
;; This local.set cannot be pushed down, because there is 'rethrow' within
- ;; the inner catch
+ ;; the inner catch_all
(local.set $x (i32.const 1))
(try
(do
(throw $e (i32.const 0))
)
- (catch
- (rethrow (pop exnref))
+ (catch_all
+ (rethrow 0)
)
)
(drop (i32.const 1))
diff --git a/test/passes/dce_all-features.txt b/test/passes/dce_all-features.txt
index 4088d5a34..447077b6c 100644
--- a/test/passes/dce_all-features.txt
+++ b/test/passes/dce_all-features.txt
@@ -551,10 +551,8 @@
(do
(unreachable)
)
- (catch
- (drop
- (pop exnref)
- )
+ (catch_all
+ (nop)
)
)
(call $foo)
@@ -564,7 +562,7 @@
(do
(nop)
)
- (catch
+ (catch_all
(unreachable)
)
)
@@ -575,7 +573,7 @@
(do
(unreachable)
)
- (catch
+ (catch_all
(unreachable)
)
)
@@ -591,9 +589,7 @@
(func $rethrow
(block $label$0
(block $label$1
- (rethrow
- (ref.null exn)
- )
+ (rethrow 0)
)
)
)
@@ -624,7 +620,7 @@
(do
(unreachable)
)
- (catch
+ (catch_all
(unreachable)
)
)
diff --git a/test/passes/dce_all-features.wast b/test/passes/dce_all-features.wast
index 9ebcccb60..fac6d7623 100644
--- a/test/passes/dce_all-features.wast
+++ b/test/passes/dce_all-features.wast
@@ -746,11 +746,7 @@
(do
(unreachable)
)
- (catch
- (drop
- (pop exnref)
- )
- )
+ (catch_all)
)
(call $foo) ;; shouldn't be dce'd
)
@@ -758,7 +754,7 @@
(func $catch_unreachable
(try
(do)
- (catch
+ (catch_all
(unreachable)
)
)
@@ -770,7 +766,7 @@
(do
(unreachable)
)
- (catch
+ (catch_all
(unreachable)
)
)
@@ -799,9 +795,7 @@
(if
(i32.clz
(block $label$1 (result i32)
- (rethrow
- (ref.null exn)
- )
+ (rethrow 0)
)
)
(nop)
@@ -835,7 +829,7 @@
(do
(unreachable)
)
- (catch
+ (catch_all
(unreachable)
)
)
diff --git a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt
index 28348883a..fb9e2907b 100644
--- a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt
+++ b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt
@@ -3,20 +3,15 @@
(type $i32_=>_none (func (param i32)))
(event $e0 (attr 0) (param i32))
(func $eh
- (local $exn exnref)
try
i32.const 0
throw $e0
catch
- local.set $exn
- block $l0 (result i32)
- local.get $exn
- br_on_exn $l0 $e0
- rethrow
- end
drop
+ rethrow 0
end
+ unreachable
)
)
(module
@@ -24,26 +19,17 @@
(type $i32_=>_none (func (param i32)))
(event $e0 (attr 0) (param i32))
(func $eh (; has Stack IR ;)
- (local $exn exnref)
(try
(do
(throw $e0
(i32.const 0)
)
)
- (catch
- (local.set $exn
- (pop exnref)
- )
+ (catch $e0
(drop
- (block $l0 (result i32)
- (rethrow
- (br_on_exn $l0 $e0
- (local.get $exn)
- )
- )
- )
+ (pop i32)
)
+ (rethrow 0)
)
)
)
diff --git a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast
index e2bbfff2d..7dbb4aa72 100644
--- a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast
+++ b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast
@@ -1,20 +1,14 @@
(module
(event $e0 (attr 0) (param i32))
- (func $eh (local $exn exnref)
+ (func $eh
(try
(do
(throw $e0 (i32.const 0))
)
- (catch
- (local.set $exn (pop exnref))
- (drop
- (block $l0 (result i32)
- (rethrow
- (br_on_exn $l0 $e0 (local.get $exn))
- )
- )
- )
+ (catch $e0
+ (drop (pop i32))
+ (rethrow 0)
)
)
)
diff --git a/test/passes/instrument-locals_all-features_disable-typed-function-references.txt b/test/passes/instrument-locals_all-features_disable-typed-function-references.txt
index d027f54a0..5fc177d9d 100644
--- a/test/passes/instrument-locals_all-features_disable-typed-function-references.txt
+++ b/test/passes/instrument-locals_all-features_disable-typed-function-references.txt
@@ -11,6 +11,7 @@
(type $i32_i32_eqref_=>_eqref (func (param i32 i32 eqref) (result eqref)))
(type $i32_i32_i31ref_=>_i31ref (func (param i32 i32 i31ref) (result i31ref)))
(type $none_=>_none (func))
+ (type $i32_=>_none (func (param i32)))
(import "env" "get_i32" (func $get_i32 (param i32 i32 i32) (result i32)))
(import "env" "get_i64" (func $get_i64 (param i32 i32 i64) (result i64)))
(import "env" "get_f32" (func $get_f32 (param i32 i32 f32) (result f32)))
@@ -33,6 +34,7 @@
(import "env" "set_i31ref" (func $set_i31ref (param i32 i32 i31ref) (result i31ref)))
(import "env" "get_v128" (func $get_v128 (param i32 i32 v128) (result v128)))
(import "env" "set_v128" (func $set_v128 (param i32 i32 v128) (result v128)))
+ (event $e (attr 0) (param i32))
(func $test
(local $x i32)
(local $y i64)
@@ -242,29 +244,9 @@
(do
(nop)
)
- (catch
- (local.set $F
- (pop funcref)
- )
- )
- )
- (try
- (do
- (nop)
- )
- (catch
- (local.set $X
- (pop externref)
- )
- )
- )
- (try
- (do
- (nop)
- )
- (catch
- (local.set $E
- (pop exnref)
+ (catch $e
+ (local.set $x
+ (pop i32)
)
)
)
diff --git a/test/passes/instrument-locals_all-features_disable-typed-function-references.wast b/test/passes/instrument-locals_all-features_disable-typed-function-references.wast
index c709630b5..53b2349fa 100644
--- a/test/passes/instrument-locals_all-features_disable-typed-function-references.wast
+++ b/test/passes/instrument-locals_all-features_disable-typed-function-references.wast
@@ -1,4 +1,6 @@
(module
+ (event $e (attr 0) (param i32))
+
(func $test
(local $x i32)
(local $y i64)
@@ -44,20 +46,8 @@
;; Pop instructions should not be instrumented
(try
(do)
- (catch
- (local.set $F (pop funcref))
- )
- )
- (try
- (do)
- (catch
- (local.set $X (pop externref))
- )
- )
- (try
- (do)
- (catch
- (local.set $E (pop exnref))
+ (catch $e
+ (local.set $x (pop i32))
)
)
diff --git a/test/passes/optimize-instructions_all-features.txt b/test/passes/optimize-instructions_all-features.txt
index 5a2ede97a..df60ebfaa 100644
--- a/test/passes/optimize-instructions_all-features.txt
+++ b/test/passes/optimize-instructions_all-features.txt
@@ -5687,10 +5687,7 @@
(do
(i32.const 123)
)
- (catch
- (drop
- (pop exnref)
- )
+ (catch_all
(i32.const 456)
)
)
diff --git a/test/passes/optimize-instructions_all-features.wast b/test/passes/optimize-instructions_all-features.wast
index d90dd7aeb..191189f70 100644
--- a/test/passes/optimize-instructions_all-features.wast
+++ b/test/passes/optimize-instructions_all-features.wast
@@ -6160,10 +6160,7 @@
)
)
)
- (catch
- (drop
- (pop exnref)
- )
+ (catch_all
(i32.eqz
(i32.eqz
(i32.const 456)
diff --git a/test/passes/remove-unused-module-elements_all-features.txt b/test/passes/remove-unused-module-elements_all-features.txt
index 81382e4f4..0873cfee4 100644
--- a/test/passes/remove-unused-module-elements_all-features.txt
+++ b/test/passes/remove-unused-module-elements_all-features.txt
@@ -279,34 +279,23 @@
)
)
(module
- (type $i32_=>_none (func (param i32)))
(type $none_=>_none (func))
+ (type $i32_=>_none (func (param i32)))
(type $i64_=>_none (func (param i64)))
(event $e-export (attr 0) (param i64))
(event $e-throw (attr 0) (param i32))
- (event $e-bronexn (attr 0) (param i32))
(export "e-export" (event $e-export))
(start $start)
(func $start
- (local $exn exnref)
(try
(do
(throw $e-throw
(i32.const 0)
)
)
- (catch
- (local.set $exn
- (pop exnref)
- )
+ (catch $e-catch
(drop
- (block $l0 (result i32)
- (rethrow
- (br_on_exn $l0 $e-bronexn
- (local.get $exn)
- )
- )
- )
+ (pop i32)
)
)
)
diff --git a/test/passes/remove-unused-module-elements_all-features.wast b/test/passes/remove-unused-module-elements_all-features.wast
index bf9d5c7ff..c70dc1495 100644
--- a/test/passes/remove-unused-module-elements_all-features.wast
+++ b/test/passes/remove-unused-module-elements_all-features.wast
@@ -266,24 +266,17 @@
(event $e-remove (attr 0) (type $0)) ;; can be removed
(event $e-export (attr 0) (param i64)) ;; cannot be removed (exported)
(event $e-throw (attr 0) (type $0)) ;; cannot be removed (used in throw)
- (event $e-bronexn (attr 0) (type $0)) ;; cannot be removed (used in br_on_exn)
+ (event $e-catch (attr 0) (type $0)) ;; cannot be removed (used in catch)
(export "e-export" (event $e-export))
(import "env" "e" (event $e-import (attr 0) (param i32)))
(start $start)
- (func $start (local $exn exnref) (; 0 ;)
+ (func $start
(try
(do
(throw $e-throw (i32.const 0))
)
- (catch
- (local.set $exn (pop exnref))
- (drop
- (block $l0 (result i32)
- (rethrow
- (br_on_exn $l0 $e-bronexn (local.get $exn))
- )
- )
- )
+ (catch $e-catch
+ (drop (pop i32))
)
)
)
diff --git a/test/passes/remove-unused-names_code-folding_all-features.txt b/test/passes/remove-unused-names_code-folding_all-features.txt
index 9736c3c0a..2f78a83e7 100644
--- a/test/passes/remove-unused-names_code-folding_all-features.txt
+++ b/test/passes/remove-unused-names_code-folding_all-features.txt
@@ -1,9 +1,10 @@
(module
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
+ (type $i32_=>_none (func (param i32)))
(type $i32_=>_i32 (func (param i32) (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
- (type $none_=>_exnref (func (result exnref)))
+ (event $e-i32 (attr 0) (param i32))
(event $e (attr 0) (param))
(func $ifs
(if
@@ -1710,8 +1711,7 @@
(i32.const 2)
)
)
- (func $exnref_pop-test
- (local $exn exnref)
+ (func $pop-test
(block $folding-inner0
(try
(do
@@ -1719,17 +1719,17 @@
(do
(nop)
)
- (catch
- (local.set $exn
- (pop exnref)
+ (catch $e-i32
+ (drop
+ (pop i32)
)
(br $folding-inner0)
)
)
)
- (catch
- (local.set $exn
- (pop exnref)
+ (catch $e-i32
+ (drop
+ (pop i32)
)
(br $folding-inner0)
)
@@ -1791,7 +1791,7 @@
(func $foo
(nop)
)
- (func $try-call-optimize-terminating-tails (result exnref)
+ (func $try-call-optimize-terminating-tails (result i32)
(try
(do
(call $foo)
@@ -1799,26 +1799,22 @@
(call $foo)
(call $foo)
(return
- (ref.null exn)
+ (i32.const 0)
)
)
- (catch
- (drop
- (pop exnref)
- )
+ (catch_all
(call $foo)
(call $foo)
(call $foo)
(call $foo)
(return
- (ref.null exn)
+ (i32.const 0)
)
)
)
- (ref.null exn)
+ (i32.const 0)
)
(func $try-call-optimize-expression-tails
- (local $exn exnref)
(block $x
(try
(do
@@ -1827,10 +1823,7 @@
(call $foo)
(br $x)
)
- (catch
- (local.set $exn
- (pop exnref)
- )
+ (catch_all
(call $foo)
(call $foo)
(call $foo)
diff --git a/test/passes/remove-unused-names_code-folding_all-features.wast b/test/passes/remove-unused-names_code-folding_all-features.wast
index 823ed45eb..387b8600b 100644
--- a/test/passes/remove-unused-names_code-folding_all-features.wast
+++ b/test/passes/remove-unused-names_code-folding_all-features.wast
@@ -1192,15 +1192,15 @@
)
)
- (func $exnref_pop-test (local $exn exnref)
+ (event $e-i32 (attr 0) (param i32))
+ (func $pop-test
(try
(do
(try
(do)
- (catch
- ;; Expressions containing (pop exnref) should NOT be taken out and
- ;; folded.
- (local.set $exn (pop exnref))
+ (catch $e-i32
+ ;; Expressions containing a pop should NOT be taken out and folded.
+ (drop (pop i32))
(drop (i32.const 111))
(drop (i32.const 222))
(drop (i32.const 333))
@@ -1208,8 +1208,8 @@
)
)
)
- (catch
- (local.set $exn (pop exnref))
+ (catch $e-i32
+ (drop (pop i32))
(drop (i32.const 111))
(drop (i32.const 222))
(drop (i32.const 333))
@@ -1246,7 +1246,7 @@
)
(func $foo)
- (func $try-call-optimize-terminating-tails (result exnref)
+ (func $try-call-optimize-terminating-tails (result i32)
(try
(do
;; Expressions that can throw should NOT be taken out of 'try' scope.
@@ -1254,21 +1254,20 @@
(call $foo)
(call $foo)
(call $foo)
- (return (ref.null exn))
+ (return (i32.const 0))
)
- (catch
- (drop (pop exnref))
+ (catch_all
(call $foo)
(call $foo)
(call $foo)
(call $foo)
- (return (ref.null exn))
+ (return (i32.const 0))
)
)
- (ref.null exn)
+ (i32.const 0)
)
- (func $try-call-optimize-expression-tails (local $exn exnref)
+ (func $try-call-optimize-expression-tails
(block $x
(try
(do
@@ -1278,8 +1277,7 @@
(call $foo)
(br $x)
)
- (catch
- (local.set $exn (pop exnref))
+ (catch_all
(call $foo)
(call $foo)
(call $foo)
diff --git a/test/passes/remove-unused-names_merge-blocks_all-features.txt b/test/passes/remove-unused-names_merge-blocks_all-features.txt
index 90a56d32d..46d45d3fe 100644
--- a/test/passes/remove-unused-names_merge-blocks_all-features.txt
+++ b/test/passes/remove-unused-names_merge-blocks_all-features.txt
@@ -1711,13 +1711,6 @@
(i32.const 3)
)
)
- (func $rethrow
- (local $0 exnref)
- (call $foo)
- (rethrow
- (local.get $0)
- )
- )
(func $br_on_exn (result i32)
(local $0 exnref)
(block $label$0 (result i32)
diff --git a/test/passes/remove-unused-names_merge-blocks_all-features.wast b/test/passes/remove-unused-names_merge-blocks_all-features.wast
index 9a6840650..6869db6ad 100644
--- a/test/passes/remove-unused-names_merge-blocks_all-features.wast
+++ b/test/passes/remove-unused-names_merge-blocks_all-features.wast
@@ -1571,16 +1571,6 @@
)
)
- ;; 'call $foo' within 'block' of `rethrow' can be hoisted
- (func $rethrow (local $0 exnref)
- (rethrow
- (block (result exnref)
- (call $foo)
- (local.get $0)
- )
- )
- )
-
;; 'call $foo' within 'block' of `br_on_exn' can be hoisted
(func $br_on_exn (result i32) (local $0 exnref)
(block $label$0 (result i32)
diff --git a/test/passes/remove-unused-names_optimize-instructions_all-features.txt b/test/passes/remove-unused-names_optimize-instructions_all-features.txt
index 8b7fc343b..cf1e44132 100644
--- a/test/passes/remove-unused-names_optimize-instructions_all-features.txt
+++ b/test/passes/remove-unused-names_optimize-instructions_all-features.txt
@@ -10,15 +10,13 @@
(local $x1 i32)
(local $x2 i32)
(local $x3 i32)
+ (local $x4 i32)
(local.set $x0
(try (result i32)
(do
(i32.const 1)
)
- (catch
- (drop
- (pop exnref)
- )
+ (catch_all
(i32.const 3)
)
)
@@ -32,10 +30,7 @@
(call $dummy)
(i32.const 1)
)
- (catch
- (drop
- (pop exnref)
- )
+ (catch_all
(i32.const 3)
)
)
@@ -55,36 +50,59 @@
(i32.const 0)
)
)
- (catch
+ (catch $e
(drop
- (pop exnref)
+ (pop i32)
)
)
)
(i32.const 1)
)
- (catch
+ (catch $e
(drop
- (pop exnref)
+ (pop i32)
)
(i32.const 3)
)
)
)
(drop
- (local.get $x2)
+ (i32.and
+ (local.get $x2)
+ (i32.const 7)
+ )
)
(local.set $x3
(try (result i32)
(do
(try
(do
+ (throw $e
+ (i32.const 0)
+ )
+ )
+ (catch_all
(nop)
)
- (catch
- (drop
- (pop exnref)
- )
+ )
+ (i32.const 1)
+ )
+ (catch_all
+ (i32.const 3)
+ )
+ )
+ )
+ (drop
+ (local.get $x3)
+ )
+ (local.set $x4
+ (try (result i32)
+ (do
+ (try
+ (do
+ (nop)
+ )
+ (catch_all
(throw $e
(i32.const 0)
)
@@ -92,17 +110,14 @@
)
(i32.const 1)
)
- (catch
- (drop
- (pop exnref)
- )
+ (catch_all
(i32.const 3)
)
)
)
(drop
(i32.and
- (local.get $x3)
+ (local.get $x4)
(i32.const 7)
)
)
diff --git a/test/passes/remove-unused-names_optimize-instructions_all-features.wast b/test/passes/remove-unused-names_optimize-instructions_all-features.wast
index 7c75c2bcf..e08c42169 100644
--- a/test/passes/remove-unused-names_optimize-instructions_all-features.wast
+++ b/test/passes/remove-unused-names_optimize-instructions_all-features.wast
@@ -7,6 +7,7 @@
(local $x1 i32)
(local $x2 i32)
(local $x3 i32)
+ (local $x4 i32)
;; try - try body does not throw, can
(local.set $x0
@@ -14,8 +15,7 @@
(do
(i32.const 1)
)
- (catch
- (drop (pop exnref))
+ (catch_all
(i32.const 3)
)
)
@@ -29,15 +29,15 @@
(call $dummy)
(i32.const 1)
)
- (catch
- (drop (pop exnref))
+ (catch_all
(i32.const 3)
)
)
)
(drop (i32.and (local.get $x1) (i32.const 7)))
- ;; nested try - inner try may throw but will be caught by inner catch, can
+ ;; nested try - inner try may throw and may not be caught by inner catch,
+ ;; can't
(local.set $x2
(try (result i32)
(do
@@ -45,39 +45,57 @@
(do
(throw $e (i32.const 0))
)
- (catch
- (drop (pop exnref))
+ (catch $e
+ (drop (pop i32))
)
)
(i32.const 1)
)
- (catch
- (drop (pop exnref))
+ (catch $e
+ (drop (pop i32))
(i32.const 3)
)
)
)
(drop (i32.and (local.get $x2) (i32.const 7)))
- ;; nested try - inner catch may throw, can't
+ ;; nested try - inner try may throw but will be caught by inner catch_all,
+ ;; can
(local.set $x3
(try (result i32)
(do
(try
- (do)
- (catch
- (drop (pop exnref))
+ (do
(throw $e (i32.const 0))
)
+ (catch_all)
)
(i32.const 1)
)
- (catch
- (drop (pop exnref))
+ (catch_all
(i32.const 3)
)
)
)
(drop (i32.and (local.get $x3) (i32.const 7)))
+
+ ;; nested try - inner catch_all may throw, can't
+ (local.set $x4
+ (try (result i32)
+ (do
+ (try
+ (do)
+ (catch_all
+ (throw $e (i32.const 0))
+ )
+ )
+ (i32.const 1)
+ )
+ (catch_all
+ (i32.const 3)
+ )
+ )
+ )
+ (drop (i32.and (local.get $x4) (i32.const 7)))
)
)
diff --git a/test/passes/rse_all-features.txt b/test/passes/rse_all-features.txt
index 95773bb23..8ad883d9f 100644
--- a/test/passes/rse_all-features.txt
+++ b/test/passes/rse_all-features.txt
@@ -3,7 +3,6 @@
(type $i32_=>_none (func (param i32)))
(type $i32_i32_=>_none (func (param i32 i32)))
(type $i32_f64_=>_none (func (param i32 f64)))
- (event $e (attr 0) (param i32))
(func $basic (param $x i32) (param $y f64)
(local $a f32)
(local $b i64)
@@ -475,136 +474,4 @@
)
)
)
- (func $try1
- (local $x i32)
- (try
- (do
- (nop)
- )
- (catch
- (drop
- (pop exnref)
- )
- (local.set $x
- (i32.const 1)
- )
- )
- )
- (local.set $x
- (i32.const 1)
- )
- )
- (func $try2
- (local $x i32)
- (try
- (do
- (throw $e
- (i32.const 0)
- )
- (local.set $x
- (i32.const 1)
- )
- )
- (catch
- (drop
- (pop exnref)
- )
- )
- )
- (local.set $x
- (i32.const 1)
- )
- )
- (func $try3
- (local $x i32)
- (try
- (do
- (throw $e
- (i32.const 0)
- )
- )
- (catch
- (drop
- (pop exnref)
- )
- (local.set $x
- (i32.const 1)
- )
- )
- )
- (drop
- (i32.const 1)
- )
- )
- (func $foo
- (nop)
- )
- (func $try4
- (local $x i32)
- (try
- (do
- (call $foo)
- (local.set $x
- (i32.const 1)
- )
- )
- (catch
- (drop
- (pop exnref)
- )
- )
- )
- (local.set $x
- (i32.const 1)
- )
- )
- (func $try5
- (local $x i32)
- (try
- (do
- (local.set $x
- (i32.const 1)
- )
- (call $foo)
- )
- (catch
- (drop
- (pop exnref)
- )
- )
- )
- (drop
- (i32.const 1)
- )
- )
- (func $nested-try
- (local $x i32)
- (try
- (do
- (try
- (do
- (throw $e
- (i32.const 0)
- )
- )
- (catch
- (rethrow
- (pop exnref)
- )
- )
- )
- )
- (catch
- (drop
- (pop exnref)
- )
- (local.set $x
- (i32.const 1)
- )
- )
- )
- (drop
- (i32.const 1)
- )
- )
)
diff --git a/test/passes/rse_all-features.wast b/test/passes/rse_all-features.wast
index d77dae379..94470ef53 100644
--- a/test/passes/rse_all-features.wast
+++ b/test/passes/rse_all-features.wast
@@ -287,89 +287,90 @@
)
)
- (event $e (attr 0) (param i32))
- (func $try1
- (local $x i32)
- (try
- (do)
- (catch
- (drop (pop exnref))
- (local.set $x (i32.const 1))
- )
- )
- (local.set $x (i32.const 1)) ;; should NOT be dropped
- )
- (func $try2
- (local $x i32)
- (try
- (do
- (throw $e (i32.const 0))
- (local.set $x (i32.const 1))
- )
- (catch
- (drop (pop exnref))
- )
- )
- (local.set $x (i32.const 1)) ;; should NOT be dropped
- )
- (func $try3
- (local $x i32)
- (try
- (do
- (throw $e (i32.const 0))
- )
- (catch
- (drop (pop exnref))
- (local.set $x (i32.const 1))
- )
- )
- (local.set $x (i32.const 1)) ;; should be dropped
- )
- (func $foo)
- (func $try4
- (local $x i32)
- (try
- (do
- (call $foo)
- (local.set $x (i32.const 1))
- )
- (catch
- (drop (pop exnref))
- )
- )
- (local.set $x (i32.const 1)) ;; should NOT be dropped
- )
- (func $try5
- (local $x i32)
- (try
- (do
- (local.set $x (i32.const 1))
- (call $foo)
- )
- (catch
- (drop (pop exnref))
- )
- )
- (local.set $x (i32.const 1)) ;; should be dropped
- )
- (func $nested-try
- (local $x i32)
- (try
- (do
- (try
- (do
- (throw $e (i32.const 0))
- )
- (catch
- (rethrow (pop exnref))
- )
- )
- )
- (catch
- (drop (pop exnref))
- (local.set $x (i32.const 1))
- )
- )
- (local.set $x (i32.const 1)) ;; should be dropped
- )
+;; FIXME Reenable these tests after fixing CFG traversal for EH
+;; (event $e (attr 0) (param i32))
+;; (func $try1
+;; (local $x i32)
+;; (try
+;; (do)
+;; (catch
+;; (drop (pop exnref))
+;; (local.set $x (i32.const 1))
+;; )
+;; )
+;; (local.set $x (i32.const 1)) ;; should NOT be dropped
+;; )
+;; (func $try2
+;; (local $x i32)
+;; (try
+;; (do
+;; (throw $e (i32.const 0))
+;; (local.set $x (i32.const 1))
+;; )
+;; (catch
+;; (drop (pop exnref))
+;; )
+;; )
+;; (local.set $x (i32.const 1)) ;; should NOT be dropped
+;; )
+;; (func $try3
+;; (local $x i32)
+;; (try
+;; (do
+;; (throw $e (i32.const 0))
+;; )
+;; (catch
+;; (drop (pop exnref))
+;; (local.set $x (i32.const 1))
+;; )
+;; )
+;; (local.set $x (i32.const 1)) ;; should be dropped
+;; )
+;; (func $foo)
+;; (func $try4
+;; (local $x i32)
+;; (try
+;; (do
+;; (call $foo)
+;; (local.set $x (i32.const 1))
+;; )
+;; (catch
+;; (drop (pop exnref))
+;; )
+;; )
+;; (local.set $x (i32.const 1)) ;; should NOT be dropped
+;; )
+;; (func $try5
+;; (local $x i32)
+;; (try
+;; (do
+;; (local.set $x (i32.const 1))
+;; (call $foo)
+;; )
+;; (catch
+;; (drop (pop exnref))
+;; )
+;; )
+;; (local.set $x (i32.const 1)) ;; should be dropped
+;; )
+;; (func $nested-try
+;; (local $x i32)
+;; (try
+;; (do
+;; (try
+;; (do
+;; (throw $e (i32.const 0))
+;; )
+;; (catch
+;; (rethrow (pop exnref))
+;; )
+;; )
+;; )
+;; (catch
+;; (drop (pop exnref))
+;; (local.set $x (i32.const 1))
+;; )
+;; )
+;; (local.set $x (i32.const 1)) ;; should be dropped
+;; )
)
diff --git a/test/passes/simplify-locals_all-features.txt b/test/passes/simplify-locals_all-features.txt
index 8587e115c..2604ad88d 100644
--- a/test/passes/simplify-locals_all-features.txt
+++ b/test/passes/simplify-locals_all-features.txt
@@ -1896,12 +1896,14 @@
)
(module
(type $none_=>_none (func))
+ (type $i32_=>_none (func (param i32)))
(type $exnref_=>_none (func (param exnref)))
- (type $i32_exnref_=>_none (func (param i32 exnref)))
+ (type $i32_i32_=>_none (func (param i32 i32)))
(type $none_=>_i32 (func (result i32)))
(type $none_=>_exnref (func (result exnref)))
(event $event$0 (attr 0) (param))
(event $event$1 (attr 0) (param exnref))
+ (event $e-i32 (attr 0) (param i32))
(func $unoptimizable-br_on_exn-block (result exnref)
(local $0 exnref)
(block $label$0
@@ -1923,36 +1925,18 @@
)
)
)
- (func $rethrow-trap
- (local $0 i32)
- (drop
- (block $label$1 (result i32)
- (try
- (do
- (rethrow
- (ref.null exn)
- )
- )
- (catch
- (nop)
- )
- )
- (i32.const 0)
- )
- )
- )
- (func $foo (param $0 i32) (param $1 exnref)
+ (func $foo (param $0 i32) (param $1 i32)
(nop)
)
(func $pop-cannot-be-sinked
- (local $0 exnref)
+ (local $0 i32)
(try
(do
(nop)
)
- (catch
+ (catch $e-i32
(local.set $0
- (pop exnref)
+ (pop i32)
)
(call $foo
(i32.const 3)
@@ -1962,21 +1946,21 @@
)
)
(func $pop-within-catch-can-be-sinked
- (local $0 exnref)
+ (local $0 i32)
(try
(do
(nop)
)
- (catch
+ (catch_all
(nop)
(call $foo
(i32.const 3)
- (try (result exnref)
+ (try (result i32)
(do
- (ref.null exn)
+ (i32.const 0)
)
- (catch
- (pop exnref)
+ (catch $e-i32
+ (pop i32)
)
)
)
@@ -1997,9 +1981,9 @@
(local.get $0)
)
)
- (catch
+ (catch $e-i32
(drop
- (pop exnref)
+ (pop i32)
)
)
)
@@ -2013,9 +1997,9 @@
(i32.const 3)
)
)
- (catch
+ (catch $e-i32
(drop
- (pop exnref)
+ (pop i32)
)
)
)
diff --git a/test/passes/simplify-locals_all-features.wast b/test/passes/simplify-locals_all-features.wast
index 61150edc1..13ff13679 100644
--- a/test/passes/simplify-locals_all-features.wast
+++ b/test/passes/simplify-locals_all-features.wast
@@ -1698,29 +1698,15 @@
)
)
- (func $rethrow-trap (local $0 i32)
- ;; This dead local.set cannot be replaced with a nop because rethrow can
- ;; trap.
- (local.set $0
- (block $label$1 (result i32)
- (try
- (do (rethrow (ref.null exn)))
- (catch)
- )
- (i32.const 0)
- )
- )
- )
-
- (func $foo (param i32 exnref))
- (func $pop-cannot-be-sinked (local $0 exnref)
+ (event $e-i32 (attr 0) (param i32))
+ (func $foo (param i32 i32))
+ (func $pop-cannot-be-sinked (local $0 i32)
(try
(do)
- (catch
- ;; This (local.set $0) of (pop exnref) cannot be sinked to
- ;; (local.get $0) below, because pop exnref should follow right after
- ;; 'catch'.
- (local.set $0 (pop exnref))
+ (catch $e-i32
+ ;; This (local.set $0) of (pop i32) cannot be sunk to (local.get $0)
+ ;; below, because the pop should follow right after 'catch'.
+ (local.set $0 (pop i32))
(call $foo
(i32.const 3)
(local.get $0)
@@ -1729,17 +1715,17 @@
)
)
- (func $pop-within-catch-can-be-sinked (local $0 exnref)
+ (func $pop-within-catch-can-be-sinked (local $0 i32)
(try
(do)
- (catch
+ (catch_all
;; This whole 'try' body can be sinked to eliminate local.set /
;; local.get. Even though it contains a pop, it is enclosed within
;; try-catch, so it is OK.
(local.set $0
- (try (result exnref)
- (do (ref.null exn))
- (catch (pop exnref))
+ (try (result i32)
+ (do (i32.const 0))
+ (catch $e-i32 (pop i32))
)
)
(call $foo
@@ -1761,8 +1747,8 @@
(do
(drop (local.get $0))
)
- (catch
- (drop (pop exnref))
+ (catch $e-i32
+ (drop (pop i32))
)
)
)
@@ -1776,8 +1762,8 @@
(do
(drop (local.get $0))
)
- (catch
- (drop (pop exnref))
+ (catch $e-i32
+ (drop (pop i32))
)
)
)
diff --git a/test/passes/vacuum_all-features.txt b/test/passes/vacuum_all-features.txt
index 0b9d70ca4..82fb7e506 100644
--- a/test/passes/vacuum_all-features.txt
+++ b/test/passes/vacuum_all-features.txt
@@ -438,10 +438,11 @@
(type $none_=>_none (func))
(type $i32_=>_none (func (param i32)))
(event $e (attr 0) (param i32))
+ (event $e2 (attr 0) (param i32))
(func $try-test
(nop)
)
- (func $inner-try-test
+ (func $inner-try-catch_all-test
(local $0 i32)
(try
(do
@@ -449,16 +450,40 @@
(i32.const 0)
)
)
- (catch
- (drop
- (pop exnref)
- )
+ (catch_all
(local.set $0
(i32.const 1)
)
)
)
)
+ (func $inner-try-catch-test
+ (local $0 i32)
+ (try
+ (do
+ (try
+ (do
+ (throw $e2
+ (i32.const 0)
+ )
+ )
+ (catch $e
+ (drop
+ (pop i32)
+ )
+ (local.set $0
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (catch $e
+ (drop
+ (pop i32)
+ )
+ )
+ )
+ )
(func $br-in-catch
(unreachable)
)
diff --git a/test/passes/vacuum_all-features.wast b/test/passes/vacuum_all-features.wast
index 9eb13b55f..94f952f5d 100644
--- a/test/passes/vacuum_all-features.wast
+++ b/test/passes/vacuum_all-features.wast
@@ -798,35 +798,56 @@
(module
(event $e (attr 0) (param i32))
+ (event $e2 (attr 0) (param i32))
;; When try body does not throw, try-body can be replaced with the try body
(func $try-test
(try
(do
(drop (i32.const 0))
)
- (catch
- (drop (pop exnref))
+ (catch $e
+ (drop (pop i32))
)
)
)
- ;; The exception thrown in the inner try is caught by the inner catch, so the
- ;; outer try body does not throw and the outer try-catch can be removed
- (func $inner-try-test (local $0 i32)
+ ;; The exception thrown in the inner try is caught by the inner catch_all, so
+ ;; the outer try body does not throw and the outer try-catch can be removed
+ (func $inner-try-catch_all-test (local $0 i32)
(try
(do
(try
(do
(throw $e (i32.const 0))
)
- (catch
- (drop (pop exnref))
+ (catch_all
(local.set $0 (i32.const 1))
)
)
)
- (catch
- (drop (pop exnref))
+ (catch $e
+ (drop (pop i32))
+ )
+ )
+ )
+
+ ;; The exception thrown in the inner try will not be caught by the inner
+ ;; catch, so the outer try-catch cannot be removed
+ (func $inner-try-catch-test (local $0 i32)
+ (try
+ (do
+ (try
+ (do
+ (throw $e2 (i32.const 0))
+ )
+ (catch $e
+ (drop (pop i32))
+ (local.set $0 (i32.const 1))
+ )
+ )
+ )
+ (catch $e
+ (drop (pop i32))
)
)
)
@@ -840,8 +861,8 @@
(do
(unreachable)
)
- (catch
- (drop (pop exnref))
+ (catch $e
+ (drop (pop i32))
(br $label$1)
)
)