summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2020-01-16 14:49:20 -0800
committerGitHub <noreply@github.com>2020-01-16 14:49:20 -0800
commit0848a27fdecf3ffd5170986dceec7ba04c4e50a0 (patch)
tree385d6c888d91c51c805b145e7ed1c8ec74486d9c /test
parent987bbca3a13678b1974cba7838178c81e2d76d02 (diff)
downloadbinaryen-0848a27fdecf3ffd5170986dceec7ba04c4e50a0.tar.gz
binaryen-0848a27fdecf3ffd5170986dceec7ba04c4e50a0.tar.bz2
binaryen-0848a27fdecf3ffd5170986dceec7ba04c4e50a0.zip
Add EH support for CFGWalker (#2597)
This adds EH instruction support for `CFGWalker`. This also implements `call` instruction handling within a try-catch; every call can possibly throw and unwind to the innermost catch block. This adds tests for RedundantSetElimination pass, which uses `CFGWalker`.
Diffstat (limited to 'test')
-rw-r--r--test/passes/rse_all-features.txt (renamed from test/passes/rse.txt)125
-rw-r--r--test/passes/rse_all-features.wast (renamed from test/passes/rse.wast)79
2 files changed, 204 insertions, 0 deletions
diff --git a/test/passes/rse.txt b/test/passes/rse_all-features.txt
index 6eb7996bf..82dc115ac 100644
--- a/test/passes/rse.txt
+++ b/test/passes/rse_all-features.txt
@@ -3,6 +3,7 @@
(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 (; 0 ;) (param $x i32) (param $y f64)
(local $a f32)
(local $b i64)
@@ -459,4 +460,128 @@
)
)
)
+ (func $try1 (; 19 ;)
+ (local $x i32)
+ (try
+ (nop)
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ (local.set $x
+ (i32.const 1)
+ )
+ )
+ )
+ (local.set $x
+ (i32.const 1)
+ )
+ )
+ (func $try2 (; 20 ;)
+ (local $x i32)
+ (try
+ (block $block
+ (throw $e
+ (i32.const 0)
+ )
+ (local.set $x
+ (i32.const 1)
+ )
+ )
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ )
+ )
+ (local.set $x
+ (i32.const 1)
+ )
+ )
+ (func $try3 (; 21 ;)
+ (local $x i32)
+ (try
+ (throw $e
+ (i32.const 0)
+ )
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ (local.set $x
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (i32.const 1)
+ )
+ )
+ (func $foo (; 22 ;)
+ (nop)
+ )
+ (func $try4 (; 23 ;)
+ (local $x i32)
+ (try
+ (block $block
+ (call $foo)
+ (local.set $x
+ (i32.const 1)
+ )
+ )
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ )
+ )
+ (local.set $x
+ (i32.const 1)
+ )
+ )
+ (func $try5 (; 24 ;)
+ (local $x i32)
+ (try
+ (block $block
+ (local.set $x
+ (i32.const 1)
+ )
+ (call $foo)
+ )
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ )
+ )
+ (drop
+ (i32.const 1)
+ )
+ )
+ (func $nested-try (; 25 ;)
+ (local $x i32)
+ (try
+ (try
+ (throw $e
+ (i32.const 0)
+ )
+ (catch
+ (rethrow
+ (exnref.pop)
+ )
+ )
+ )
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ (local.set $x
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (i32.const 1)
+ )
+ )
)
diff --git a/test/passes/rse.wast b/test/passes/rse_all-features.wast
index 22d13c491..09b0d720d 100644
--- a/test/passes/rse.wast
+++ b/test/passes/rse_all-features.wast
@@ -277,5 +277,84 @@
)
)
)
+
+ (event $e (attr 0) (param i32))
+ (func $try1
+ (local $x i32)
+ (try
+ (catch
+ (drop (exnref.pop))
+ (local.set $x (i32.const 1))
+ )
+ )
+ (local.set $x (i32.const 1)) ;; should NOT be dropped
+ )
+ (func $try2
+ (local $x i32)
+ (try
+ (block
+ (throw $e (i32.const 0))
+ (local.set $x (i32.const 1))
+ )
+ (catch
+ (drop (exnref.pop))
+ )
+ )
+ (local.set $x (i32.const 1)) ;; should NOT be dropped
+ )
+ (func $try3
+ (local $x i32)
+ (try
+ (throw $e (i32.const 0))
+ (catch
+ (drop (exnref.pop))
+ (local.set $x (i32.const 1))
+ )
+ )
+ (local.set $x (i32.const 1)) ;; should be dropped
+ )
+ (func $foo)
+ (func $try4
+ (local $x i32)
+ (try
+ (block
+ (call $foo)
+ (local.set $x (i32.const 1))
+ )
+ (catch
+ (drop (exnref.pop))
+ )
+ )
+ (local.set $x (i32.const 1)) ;; should NOT be dropped
+ )
+ (func $try5
+ (local $x i32)
+ (try
+ (block
+ (local.set $x (i32.const 1))
+ (call $foo)
+ )
+ (catch
+ (drop (exnref.pop))
+ )
+ )
+ (local.set $x (i32.const 1)) ;; should be dropped
+ )
+ (func $nested-try
+ (local $x i32)
+ (try
+ (try
+ (throw $e (i32.const 0))
+ (catch
+ (rethrow (exnref.pop))
+ )
+ )
+ (catch
+ (drop (exnref.pop))
+ (local.set $x (i32.const 1))
+ )
+ )
+ (local.set $x (i32.const 1)) ;; should be dropped
+ )
)