summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-11-18 13:20:20 -0800
committerGitHub <noreply@github.com>2020-11-18 13:20:20 -0800
commitf7547064e38bcc8518d6ebf1a2de0d7a76d6ad15 (patch)
tree6ff879becd4f4163828aee36a028319e5d0d99f7 /test
parent1e527ec6c1553a47bceb60b6c70011552019b7e6 (diff)
downloadbinaryen-f7547064e38bcc8518d6ebf1a2de0d7a76d6ad15.tar.gz
binaryen-f7547064e38bcc8518d6ebf1a2de0d7a76d6ad15.tar.bz2
binaryen-f7547064e38bcc8518d6ebf1a2de0d7a76d6ad15.zip
[DeadArgumentElimination] Don't DAE a ref.func-ed class (#3380)
If we take a reference of a function, it is dangerous to change the function's type (which removing dead arguments does), as that would be an observable different from the outside - the type changes, and some params are now ignored, and others are reordered. In theory we could find out if the reference does not escape, but that's not trivial. Related to #3378 but not quite the same.
Diffstat (limited to 'test')
-rw-r--r--test/passes/dae_all-features.txt (renamed from test/passes/dae_enable-tail-call.txt)12
-rw-r--r--test/passes/dae_all-features.wast (renamed from test/passes/dae_enable-tail-call.wast)11
2 files changed, 23 insertions, 0 deletions
diff --git a/test/passes/dae_enable-tail-call.txt b/test/passes/dae_all-features.txt
index 0b2f6721c..9a1a4d89a 100644
--- a/test/passes/dae_enable-tail-call.txt
+++ b/test/passes/dae_all-features.txt
@@ -279,3 +279,15 @@
)
)
)
+(module
+ (type $funcref_i32_f64_=>_i64 (func (param funcref i32 f64) (result i64)))
+ (type $f32_=>_funcref (func (param f32) (result funcref)))
+ (export "export" (func $1))
+ (func $0 (param $0 funcref) (param $1 i32) (param $2 f64) (result i64)
+ (nop)
+ (unreachable)
+ )
+ (func $1 (param $0 f32) (result funcref)
+ (ref.func $0)
+ )
+)
diff --git a/test/passes/dae_enable-tail-call.wast b/test/passes/dae_all-features.wast
index e70cde1bb..097c144cc 100644
--- a/test/passes/dae_enable-tail-call.wast
+++ b/test/passes/dae_all-features.wast
@@ -161,3 +161,14 @@
)
)
)
+(module
+ (func $0 (param $0 funcref) (param $1 i32) (param $2 f64) (result i64)
+ (nop)
+ (unreachable)
+ )
+ (func "export" (param $0 f32) (result funcref)
+ ;; a ref.func should prevent us from changing the type of a function, as it
+ ;; may escape
+ (ref.func $0)
+ )
+)