summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-11-01 13:51:50 -0700
committerGitHub <noreply@github.com>2019-11-01 13:51:50 -0700
commite53d4bdae0fffb6763ec4ae4fbf6f727d0da04d2 (patch)
tree243df8cdedf7e48fe8ef2d65b893f9e2265b40dc /test
parentfb78a120277c023531020b146dd6506608aa9bcc (diff)
downloadbinaryen-e53d4bdae0fffb6763ec4ae4fbf6f727d0da04d2.tar.gz
binaryen-e53d4bdae0fffb6763ec4ae4fbf6f727d0da04d2.tar.bz2
binaryen-e53d4bdae0fffb6763ec4ae4fbf6f727d0da04d2.zip
Don't remove events used in instructions (#2412)
Previously RemoveUnusedModuleElements pass only preserved exported events and did not preserve events used in `throw` and `br_on_exn` instructions. This fixes it.
Diffstat (limited to 'test')
-rw-r--r--test/passes/remove-unused-module-elements_all-features.txt29
-rw-r--r--test/passes/remove-unused-module-elements_all-features.wast27
2 files changed, 48 insertions, 8 deletions
diff --git a/test/passes/remove-unused-module-elements_all-features.txt b/test/passes/remove-unused-module-elements_all-features.txt
index 3d80f96e9..92216271f 100644
--- a/test/passes/remove-unused-module-elements_all-features.txt
+++ b/test/passes/remove-unused-module-elements_all-features.txt
@@ -279,7 +279,32 @@
)
)
(module
+ (type $0 (func (param i32)))
+ (type $FUNCSIG$v (func))
(type $FUNCSIG$vj (func (param i64)))
- (event $e1 (attr 0) (param i64))
- (export "e1" (event $e1))
+ (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 (; 0 ;) (type $FUNCSIG$v)
+ (local $exn exnref)
+ (throw $e-throw
+ (i32.const 0)
+ )
+ (block
+ (local.set $exn
+ (exnref.pop)
+ )
+ (drop
+ (block $l0 (result i32)
+ (rethrow
+ (br_on_exn $l0 $e-bronexn
+ (local.get $exn)
+ )
+ )
+ )
+ )
+ )
+ )
)
diff --git a/test/passes/remove-unused-module-elements_all-features.wast b/test/passes/remove-unused-module-elements_all-features.wast
index 3d0248848..283e539fd 100644
--- a/test/passes/remove-unused-module-elements_all-features.wast
+++ b/test/passes/remove-unused-module-elements_all-features.wast
@@ -261,11 +261,26 @@
)
)
)
-(module ;; non-exported events can be removed
+(module ;; non-exported and unused events can be removed
(type $0 (func (param i32)))
- (event $e0 (attr 0) (type $0))
- (event $e1 (attr 0) (param i64))
- (export "e1" (event $e1))
- (import "env" "e" (event $e2 (attr 0) (param i32)))
- (func $f (; 0 ;) (type $0))
+ (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)
+ (export "e-export" (event $e-export))
+ (import "env" "e" (event $e-import (attr 0) (param i32)))
+ (start $start)
+ (func $start (local $exn exnref) (; 0 ;)
+ (throw $e-throw (i32.const 0))
+ (catch
+ (local.set $exn (exnref.pop))
+ (drop
+ (block $l0 (result i32)
+ (rethrow
+ (br_on_exn $l0 $e-bronexn (local.get $exn))
+ )
+ )
+ )
+ )
+ )
)