summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-07-16 09:59:42 -0700
committerGitHub <noreply@github.com>2021-07-16 09:59:42 -0700
commit5600a54526d3ed3d4501dc4db800de423a1c3b8d (patch)
tree0cc9c2001c4285a18e53b79a7c8b1be2c12fc54a
parent27831cba47722c10a8a6f412d56665a4e7074540 (diff)
downloadbinaryen-5600a54526d3ed3d4501dc4db800de423a1c3b8d.tar.gz
binaryen-5600a54526d3ed3d4501dc4db800de423a1c3b8d.tar.bz2
binaryen-5600a54526d3ed3d4501dc4db800de423a1c3b8d.zip
Port test/passes/da* to lit (#3991)
-rw-r--r--test/lit/passes/dae-optimizing.wast108
-rw-r--r--test/lit/passes/dae_all-features.wast540
-rw-r--r--test/passes/dae-optimizing.txt43
-rw-r--r--test/passes/dae-optimizing.wast60
-rw-r--r--test/passes/dae_all-features.txt324
-rw-r--r--test/passes/dae_all-features.wast206
6 files changed, 648 insertions, 633 deletions
diff --git a/test/lit/passes/dae-optimizing.wast b/test/lit/passes/dae-optimizing.wast
new file mode 100644
index 000000000..6b9e610d9
--- /dev/null
+++ b/test/lit/passes/dae-optimizing.wast
@@ -0,0 +1,108 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+;; NOTE: This test was ported using port_test.py and could be cleaned up.
+
+;; RUN: foreach %s %t wasm-opt --dae-optimizing -S -o - | filecheck %s
+
+(module
+ (type $0 (func (param f32) (result f32)))
+ (type $1 (func (param f64 f32 f32 f64 f32 i64 f64) (result i32)))
+ ;; CHECK: (type $none_=>_i32 (func (result i32)))
+
+ ;; CHECK: (type $none_=>_f32 (func (result f32)))
+
+ ;; CHECK: (type $2 (func (param f64 f32 f32 f64 f32 i32 i32 f64) (result i32)))
+ (type $2 (func (param f64 f32 f32 f64 f32 i32 i32 f64) (result i32)))
+ ;; CHECK: (global $global$0 (mut i32) (i32.const 10))
+ (global $global$0 (mut i32) (i32.const 10))
+ ;; CHECK: (func $0 (result i32)
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (local $1 i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (if (result f32)
+ ;; CHECK-NEXT: (local.tee $0
+ ;; CHECK-NEXT: (i32.const 33554432)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (loop $label$2 (result f32)
+ ;; CHECK-NEXT: (if
+ ;; CHECK-NEXT: (global.get $global$0)
+ ;; CHECK-NEXT: (return
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.set $1
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (br_if $label$2
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (f32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const -11)
+ ;; CHECK-NEXT: )
+ (func $0 (; 0 ;) (type $1) (param $0 f64) (param $1 f32) (param $2 f32) (param $3 f64) (param $4 f32) (param $5 i64) (param $6 f64) (result i32)
+ (local $7 i32)
+ (local $8 i32)
+ (if
+ (local.tee $7
+ (i32.const 33554432)
+ )
+ (drop
+ (loop $label$2 (result f32)
+ (if
+ (global.get $global$0)
+ (return
+ (local.get $7)
+ )
+ )
+ (local.set $8
+ (block $label$4 (result i32)
+ (drop
+ (local.tee $7
+ (local.get $8)
+ )
+ )
+ (i32.const 0)
+ )
+ )
+ (br_if $label$2
+ (local.get $7)
+ )
+ (f32.const 1)
+ )
+ )
+ (drop
+ (call $1
+ (f32.const 1)
+ )
+ )
+ )
+ (i32.const -11)
+ )
+ ;; CHECK: (func $1 (result f32)
+ ;; CHECK-NEXT: (f32.const 0)
+ ;; CHECK-NEXT: )
+ (func $1 (; 1 ;) (type $0) (param $0 f32) (result f32)
+ (f32.const 0)
+ )
+ ;; CHECK: (func $2 (param $0 f64) (param $1 f32) (param $2 f32) (param $3 f64) (param $4 f32) (param $5 i32) (param $6 i32) (param $7 f64) (result i32)
+ ;; CHECK-NEXT: (call $0)
+ ;; CHECK-NEXT: )
+ (func $2 (; 2 ;) (type $2) (param $0 f64) (param $1 f32) (param $2 f32) (param $3 f64) (param $4 f32) (param $5 i32) (param $6 i32) (param $7 f64) (result i32)
+ (call $0
+ (f64.const 1)
+ (f32.const 1)
+ (f32.const 1)
+ (f64.const 1)
+ (f32.const 1)
+ (i64.const 1)
+ (f64.const 1)
+ )
+ )
+)
+
diff --git a/test/lit/passes/dae_all-features.wast b/test/lit/passes/dae_all-features.wast
new file mode 100644
index 000000000..42a47eb68
--- /dev/null
+++ b/test/lit/passes/dae_all-features.wast
@@ -0,0 +1,540 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+;; NOTE: This test was ported using port_test.py and could be cleaned up.
+
+;; RUN: foreach %s %t wasm-opt --dae --all-features -S -o - | filecheck %s
+
+(module
+ ;; CHECK: (type $none_=>_none (func))
+
+ ;; CHECK: (type $i32_=>_none (func (param i32)))
+
+ ;; CHECK: (type $none_=>_i32 (func (result i32)))
+
+ ;; CHECK: (type $f64_=>_none (func (param f64)))
+
+ ;; CHECK: (table $0 2 2 funcref)
+
+ ;; CHECK: (elem (i32.const 0) $a9 $c8)
+
+ ;; CHECK: (export "a8" (func $a8))
+ (export "a8" (func $a8))
+ (table 2 2 funcref)
+ (elem (i32.const 0) $a9 $c8)
+ ;; CHECK: (func $a
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $a (param $x i32))
+ ;; CHECK: (func $b
+ ;; CHECK-NEXT: (call $a)
+ ;; CHECK-NEXT: )
+ (func $b
+ (call $a (i32.const 1)) ;; best case scenario
+ )
+ ;; CHECK: (func $a1
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (i32.const 2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ (func $a1 (param $x i32)
+ (unreachable)
+ )
+ ;; CHECK: (func $b1
+ ;; CHECK-NEXT: (call $a1)
+ ;; CHECK-NEXT: )
+ (func $b1
+ (call $a1 (i32.const 2)) ;; same value in both, so works
+ )
+ ;; CHECK: (func $b11
+ ;; CHECK-NEXT: (call $a1)
+ ;; CHECK-NEXT: )
+ (func $b11
+ (call $a1 (i32.const 2))
+ )
+ ;; CHECK: (func $a2 (param $x i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $a2 (param $x i32)
+ (drop (local.get $x))
+ )
+ ;; CHECK: (func $b2
+ ;; CHECK-NEXT: (call $a2
+ ;; CHECK-NEXT: (i32.const 3)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $b2
+ (call $a2 (i32.const 3)) ;; different value!
+ )
+ ;; CHECK: (func $b22
+ ;; CHECK-NEXT: (call $a2
+ ;; CHECK-NEXT: (i32.const 4)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $b22
+ (call $a2 (i32.const 4))
+ )
+ ;; CHECK: (func $a3
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (i32.const -1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $a3 (param $x i32)
+ (drop (i32.const -1)) ;; diff value, but at least unused, so no need to send
+ )
+ ;; CHECK: (func $b3
+ ;; CHECK-NEXT: (call $a3)
+ ;; CHECK-NEXT: )
+ (func $b3
+ (call $a3 (i32.const 3))
+ )
+ ;; CHECK: (func $b33
+ ;; CHECK-NEXT: (call $a3)
+ ;; CHECK-NEXT: )
+ (func $b33
+ (call $a3 (i32.const 4))
+ )
+ ;; CHECK: (func $a4 (param $x i32)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $a4 (param $x i32) ;; diff value, but with effects
+ )
+ ;; CHECK: (func $b4
+ ;; CHECK-NEXT: (call $a4
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $b4
+ (call $a4 (unreachable))
+ )
+ ;; CHECK: (func $b43
+ ;; CHECK-NEXT: (call $a4
+ ;; CHECK-NEXT: (i32.const 4)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $b43
+ (call $a4 (i32.const 4))
+ )
+ ;; CHECK: (func $a5
+ ;; CHECK-NEXT: (local $0 f64)
+ ;; CHECK-NEXT: (local $1 i32)
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (f64.const 3.14159)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (local.set $1
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $a5 (param $x i32) (param $y f64) ;; optimize two
+ (drop (local.get $x))
+ (drop (local.get $y))
+ )
+ ;; CHECK: (func $b5
+ ;; CHECK-NEXT: (call $a5)
+ ;; CHECK-NEXT: )
+ (func $b5
+ (call $a5 (i32.const 1) (f64.const 3.14159))
+ )
+ ;; CHECK: (func $a6 (param $0 i32)
+ ;; CHECK-NEXT: (local $1 f64)
+ ;; CHECK-NEXT: (local.set $1
+ ;; CHECK-NEXT: (f64.const 3.14159)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $a6 (param $x i32) (param $y f64) ;; optimize just one
+ (drop (local.get $x))
+ (drop (local.get $y))
+ )
+ ;; CHECK: (func $b6
+ ;; CHECK-NEXT: (call $a6
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $b6
+ (call $a6 (unreachable) (f64.const 3.14159))
+ )
+ ;; CHECK: (func $a7 (param $0 f64)
+ ;; CHECK-NEXT: (local $1 i32)
+ ;; CHECK-NEXT: (local.set $1
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $a7 (param $x i32) (param $y f64) ;; optimize just the other one
+ (drop (local.get $x))
+ (drop (local.get $y))
+ )
+ ;; CHECK: (func $b7
+ ;; CHECK-NEXT: (call $a7
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $b7
+ (call $a7 (i32.const 1) (unreachable))
+ )
+ ;; CHECK: (func $a8 (param $x i32)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $a8 (param $x i32)) ;; exported, do not optimize
+ ;; CHECK: (func $b8
+ ;; CHECK-NEXT: (call $a8
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $b8
+ (call $a8 (i32.const 1))
+ )
+ ;; CHECK: (func $a9 (param $x i32)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $a9 (param $x i32)) ;; tabled, do not optimize
+ ;; CHECK: (func $b9
+ ;; CHECK-NEXT: (call $a9
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $b9
+ (call $a9 (i32.const 1))
+ )
+ ;; CHECK: (func $a10
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (call $a10)
+ ;; CHECK-NEXT: (call $a10)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $a10 (param $x i32) ;; recursion
+ (call $a10 (i32.const 1))
+ (call $a10 (i32.const 1))
+ )
+ ;; CHECK: (func $a11
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (call $a11)
+ ;; CHECK-NEXT: (call $a11)
+ ;; CHECK-NEXT: )
+ (func $a11 (param $x i32) ;; partially successful recursion
+ (call $a11 (i32.const 1))
+ (call $a11 (i32.const 2))
+ )
+ ;; CHECK: (func $a12 (param $x i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $a12
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $a12
+ ;; CHECK-NEXT: (i32.const 2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $a12 (param $x i32) ;; unsuccessful recursion
+ (drop (local.get $x))
+ (call $a12 (i32.const 1))
+ (call $a12 (i32.const 2))
+ )
+ ;; return values
+ ;; CHECK: (func $c1
+ ;; CHECK-NEXT: (local $x i32)
+ ;; CHECK-NEXT: (call $c2)
+ ;; CHECK-NEXT: (call $c3)
+ ;; CHECK-NEXT: (call $c3)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $c4)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.set $x
+ ;; CHECK-NEXT: (call $c4)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $c5
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $c6)
+ ;; CHECK-NEXT: (call $c7)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $c8)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $c1
+ (local $x i32)
+ (drop (call $c2))
+ (drop (call $c3))
+ (drop (call $c3))
+ (drop (call $c4))
+ (local.set $x (call $c4))
+ (drop (call $c5 (unreachable)))
+ (drop (call $c6))
+ (drop (call $c7))
+ (drop (call $c8))
+ )
+ ;; CHECK: (func $c2
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $c2 (result i32)
+ (i32.const 1)
+ )
+ ;; CHECK: (func $c3
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (i32.const 2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $c3 (result i32)
+ (i32.const 2)
+ )
+ ;; CHECK: (func $c4 (result i32)
+ ;; CHECK-NEXT: (i32.const 3)
+ ;; CHECK-NEXT: )
+ (func $c4 (result i32)
+ (i32.const 3)
+ )
+ ;; CHECK: (func $c5 (param $x i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $c5 (param $x i32) (result i32)
+ (local.get $x)
+ )
+ ;; CHECK: (func $c6
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ (func $c6 (result i32)
+ (unreachable)
+ )
+ ;; CHECK: (func $c7
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (i32.const 4)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (return)
+ ;; CHECK-NEXT: )
+ (func $c7 (result i32)
+ (return (i32.const 4))
+ )
+ ;; CHECK: (func $c8 (result i32)
+ ;; CHECK-NEXT: (i32.const 5)
+ ;; CHECK-NEXT: )
+ (func $c8 (result i32)
+ (i32.const 5)
+ )
+)
+(module ;; both operations at once: remove params and return value
+ (func "a"
+ (drop
+ (call $b
+ (i32.const 1)
+ )
+ )
+ )
+ ;; CHECK: (type $none_=>_none (func))
+
+ ;; CHECK: (export "a" (func $0))
+
+ ;; CHECK: (func $0
+ ;; CHECK-NEXT: (call $b)
+ ;; CHECK-NEXT: )
+
+ ;; CHECK: (func $b
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block (result i32)
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $b (param $x i32) (result i32)
+ (local.get $x)
+ )
+)
+(module ;; tail calls inhibit dropped result removal
+ ;; CHECK: (type $i32_=>_i32 (func (param i32) (result i32)))
+
+ ;; CHECK: (type $none_=>_i32 (func (result i32)))
+
+ ;; CHECK: (func $foo (param $x i32) (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (return_call $bar)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 42)
+ ;; CHECK-NEXT: )
+ (func $foo (param $x i32) (result i32)
+ (drop
+ (return_call $bar
+ (i32.const 0)
+ )
+ )
+ (i32.const 42)
+ )
+ ;; CHECK: (func $bar (result i32)
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 7)
+ ;; CHECK-NEXT: )
+ (func $bar (param $x i32) (result i32)
+ (i32.const 7)
+ )
+)
+(module ;; indirect tail calls inhibit dropped result removal
+ ;; CHECK: (type $T (func (result i32)))
+ (type $T (func (result i32)))
+ (table 1 1 funcref)
+ ;; CHECK: (type $none_=>_none (func))
+
+ ;; CHECK: (table $0 1 1 funcref)
+
+ ;; CHECK: (func $foo (result i32)
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (i32.const 42)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (return_call_indirect $0 (type $T)
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $foo (param $x i32) (result i32)
+ (drop
+ (return_call_indirect (type $T)
+ (i32.const 0)
+ )
+ )
+ )
+ ;; CHECK: (func $bar
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $foo)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $bar
+ (drop
+ (call $foo
+ (i32.const 42)
+ )
+ )
+ )
+)
+(module
+ ;; CHECK: (type $funcref_i32_f64_=>_i64 (func (param funcref i32 f64) (result i64)))
+
+ ;; CHECK: (type $f32_=>_funcref (func (param f32) (result funcref)))
+
+ ;; CHECK: (elem declare func $0)
+
+ ;; CHECK: (export "export" (func $1))
+
+ ;; CHECK: (func $0 (param $0 funcref) (param $1 i32) (param $2 f64) (result i64)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ (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)
+ )
+)
+;; CHECK: (func $1 (param $0 f32) (result funcref)
+;; CHECK-NEXT: (ref.func $0)
+;; CHECK-NEXT: )
+(module
+ ;; CHECK: (type $none_=>_none (func))
+
+ ;; CHECK: (type $i64 (func (param i64)))
+ (type $i64 (func (param i64)))
+ ;; CHECK: (global $global$0 (ref $i64) (ref.func $0))
+ (global $global$0 (ref $i64) (ref.func $0))
+ ;; CHECK: (export "even" (func $1))
+ (export "even" (func $1))
+ ;; the argument to this function cannot be removed due to the ref.func of it
+ ;; in a global
+ ;; CHECK: (func $0 (param $0 i64)
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ (func $0 (param $0 i64)
+ (unreachable)
+ )
+ ;; CHECK: (func $1
+ ;; CHECK-NEXT: (call_ref
+ ;; CHECK-NEXT: (i64.const 0)
+ ;; CHECK-NEXT: (global.get $global$0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $1
+ (call_ref
+ (i64.const 0)
+ (global.get $global$0)
+ )
+ )
+ ;; CHECK: (func $2
+ ;; CHECK-NEXT: (call $0
+ ;; CHECK-NEXT: (i64.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $2
+ (call $0
+ (i64.const 0)
+ )
+ )
+)
+(module
+ ;; a removable non-nullable parameter
+ ;; CHECK: (type $none_=>_none (func))
+
+ ;; CHECK: (func $0
+ ;; CHECK-NEXT: (local $0 (ref null i31))
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $0 (param $x i31ref)
+ (nop)
+ )
+ ;; CHECK: (func $1
+ ;; CHECK-NEXT: (call $0)
+ ;; CHECK-NEXT: )
+ (func $1
+ (call $0
+ (i31.new (i32.const 0))
+ )
+ )
+)
diff --git a/test/passes/dae-optimizing.txt b/test/passes/dae-optimizing.txt
deleted file mode 100644
index 58969301c..000000000
--- a/test/passes/dae-optimizing.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-(module
- (type $none_=>_i32 (func (result i32)))
- (type $none_=>_f32 (func (result f32)))
- (type $2 (func (param f64 f32 f32 f64 f32 i32 i32 f64) (result i32)))
- (global $global$0 (mut i32) (i32.const 10))
- (func $0 (result i32)
- (local $0 i32)
- (local $1 i32)
- (drop
- (if (result f32)
- (local.tee $0
- (i32.const 33554432)
- )
- (loop $label$2 (result f32)
- (if
- (global.get $global$0)
- (return
- (local.get $0)
- )
- )
- (local.set $0
- (local.get $1)
- )
- (local.set $1
- (i32.const 0)
- )
- (br_if $label$2
- (local.get $0)
- )
- (f32.const 1)
- )
- (call $1)
- )
- )
- (i32.const -11)
- )
- (func $1 (result f32)
- (f32.const 0)
- )
- (func $2 (param $0 f64) (param $1 f32) (param $2 f32) (param $3 f64) (param $4 f32) (param $5 i32) (param $6 i32) (param $7 f64) (result i32)
- (call $0)
- )
-)
diff --git a/test/passes/dae-optimizing.wast b/test/passes/dae-optimizing.wast
deleted file mode 100644
index 5d51cf29d..000000000
--- a/test/passes/dae-optimizing.wast
+++ /dev/null
@@ -1,60 +0,0 @@
-(module
- (type $0 (func (param f32) (result f32)))
- (type $1 (func (param f64 f32 f32 f64 f32 i64 f64) (result i32)))
- (type $2 (func (param f64 f32 f32 f64 f32 i32 i32 f64) (result i32)))
- (global $global$0 (mut i32) (i32.const 10))
- (func $0 (; 0 ;) (type $1) (param $0 f64) (param $1 f32) (param $2 f32) (param $3 f64) (param $4 f32) (param $5 i64) (param $6 f64) (result i32)
- (local $7 i32)
- (local $8 i32)
- (if
- (local.tee $7
- (i32.const 33554432)
- )
- (drop
- (loop $label$2 (result f32)
- (if
- (global.get $global$0)
- (return
- (local.get $7)
- )
- )
- (local.set $8
- (block $label$4 (result i32)
- (drop
- (local.tee $7
- (local.get $8)
- )
- )
- (i32.const 0)
- )
- )
- (br_if $label$2
- (local.get $7)
- )
- (f32.const 1)
- )
- )
- (drop
- (call $1
- (f32.const 1)
- )
- )
- )
- (i32.const -11)
- )
- (func $1 (; 1 ;) (type $0) (param $0 f32) (result f32)
- (f32.const 0)
- )
- (func $2 (; 2 ;) (type $2) (param $0 f64) (param $1 f32) (param $2 f32) (param $3 f64) (param $4 f32) (param $5 i32) (param $6 i32) (param $7 f64) (result i32)
- (call $0
- (f64.const 1)
- (f32.const 1)
- (f32.const 1)
- (f64.const 1)
- (f32.const 1)
- (i64.const 1)
- (f64.const 1)
- )
- )
-)
-
diff --git a/test/passes/dae_all-features.txt b/test/passes/dae_all-features.txt
deleted file mode 100644
index 0f5618b99..000000000
--- a/test/passes/dae_all-features.txt
+++ /dev/null
@@ -1,324 +0,0 @@
-(module
- (type $none_=>_none (func))
- (type $i32_=>_none (func (param i32)))
- (type $none_=>_i32 (func (result i32)))
- (type $f64_=>_none (func (param f64)))
- (table $0 2 2 funcref)
- (elem (i32.const 0) $a9 $c8)
- (export "a8" (func $a8))
- (func $a
- (local $0 i32)
- (local.set $0
- (i32.const 1)
- )
- (nop)
- )
- (func $b
- (call $a)
- )
- (func $a1
- (local $0 i32)
- (local.set $0
- (i32.const 2)
- )
- (unreachable)
- )
- (func $b1
- (call $a1)
- )
- (func $b11
- (call $a1)
- )
- (func $a2 (param $x i32)
- (drop
- (local.get $x)
- )
- )
- (func $b2
- (call $a2
- (i32.const 3)
- )
- )
- (func $b22
- (call $a2
- (i32.const 4)
- )
- )
- (func $a3
- (local $0 i32)
- (drop
- (i32.const -1)
- )
- )
- (func $b3
- (call $a3)
- )
- (func $b33
- (call $a3)
- )
- (func $a4 (param $x i32)
- (nop)
- )
- (func $b4
- (call $a4
- (unreachable)
- )
- )
- (func $b43
- (call $a4
- (i32.const 4)
- )
- )
- (func $a5
- (local $0 f64)
- (local $1 i32)
- (local.set $0
- (f64.const 3.14159)
- )
- (block
- (local.set $1
- (i32.const 1)
- )
- (block
- (drop
- (local.get $1)
- )
- (drop
- (local.get $0)
- )
- )
- )
- )
- (func $b5
- (call $a5)
- )
- (func $a6 (param $0 i32)
- (local $1 f64)
- (local.set $1
- (f64.const 3.14159)
- )
- (block
- (drop
- (local.get $0)
- )
- (drop
- (local.get $1)
- )
- )
- )
- (func $b6
- (call $a6
- (unreachable)
- )
- )
- (func $a7 (param $0 f64)
- (local $1 i32)
- (local.set $1
- (i32.const 1)
- )
- (block
- (drop
- (local.get $1)
- )
- (drop
- (local.get $0)
- )
- )
- )
- (func $b7
- (call $a7
- (unreachable)
- )
- )
- (func $a8 (param $x i32)
- (nop)
- )
- (func $b8
- (call $a8
- (i32.const 1)
- )
- )
- (func $a9 (param $x i32)
- (nop)
- )
- (func $b9
- (call $a9
- (i32.const 1)
- )
- )
- (func $a10
- (local $0 i32)
- (local.set $0
- (i32.const 1)
- )
- (block
- (call $a10)
- (call $a10)
- )
- )
- (func $a11
- (local $0 i32)
- (call $a11)
- (call $a11)
- )
- (func $a12 (param $x i32)
- (drop
- (local.get $x)
- )
- (call $a12
- (i32.const 1)
- )
- (call $a12
- (i32.const 2)
- )
- )
- (func $c1
- (local $x i32)
- (call $c2)
- (call $c3)
- (call $c3)
- (drop
- (call $c4)
- )
- (local.set $x
- (call $c4)
- )
- (call $c5
- (unreachable)
- )
- (call $c6)
- (call $c7)
- (drop
- (call $c8)
- )
- )
- (func $c2
- (drop
- (i32.const 1)
- )
- )
- (func $c3
- (drop
- (i32.const 2)
- )
- )
- (func $c4 (result i32)
- (i32.const 3)
- )
- (func $c5 (param $x i32)
- (drop
- (local.get $x)
- )
- )
- (func $c6
- (unreachable)
- )
- (func $c7
- (drop
- (i32.const 4)
- )
- (return)
- )
- (func $c8 (result i32)
- (i32.const 5)
- )
-)
-(module
- (type $none_=>_none (func))
- (export "a" (func $0))
- (func $0
- (call $b)
- )
- (func $b
- (local $0 i32)
- (drop
- (block (result i32)
- (local.set $0
- (i32.const 1)
- )
- (local.get $0)
- )
- )
- )
-)
-(module
- (type $i32_=>_i32 (func (param i32) (result i32)))
- (type $none_=>_i32 (func (result i32)))
- (func $foo (param $x i32) (result i32)
- (drop
- (return_call $bar)
- )
- (i32.const 42)
- )
- (func $bar (result i32)
- (local $0 i32)
- (local.set $0
- (i32.const 0)
- )
- (i32.const 7)
- )
-)
-(module
- (type $T (func (result i32)))
- (type $none_=>_none (func))
- (table $0 1 1 funcref)
- (func $foo (result i32)
- (local $0 i32)
- (local.set $0
- (i32.const 42)
- )
- (drop
- (return_call_indirect $0 (type $T)
- (i32.const 0)
- )
- )
- )
- (func $bar
- (drop
- (call $foo)
- )
- )
-)
-(module
- (type $funcref_i32_f64_=>_i64 (func (param funcref i32 f64) (result i64)))
- (type $f32_=>_funcref (func (param f32) (result funcref)))
- (elem declare func $0)
- (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)
- )
-)
-(module
- (type $none_=>_none (func))
- (type $i64 (func (param i64)))
- (global $global$0 (ref $i64) (ref.func $0))
- (export "even" (func $1))
- (func $0 (param $0 i64)
- (unreachable)
- )
- (func $1
- (call_ref
- (i64.const 0)
- (global.get $global$0)
- )
- )
- (func $2
- (call $0
- (i64.const 0)
- )
- )
-)
-(module
- (type $none_=>_none (func))
- (func $0
- (local $0 (ref null i31))
- (nop)
- )
- (func $1
- (call $0)
- )
-)
diff --git a/test/passes/dae_all-features.wast b/test/passes/dae_all-features.wast
deleted file mode 100644
index 67244cc23..000000000
--- a/test/passes/dae_all-features.wast
+++ /dev/null
@@ -1,206 +0,0 @@
-(module
- (export "a8" (func $a8))
- (table 2 2 funcref)
- (elem (i32.const 0) $a9 $c8)
- (func $a (param $x i32))
- (func $b
- (call $a (i32.const 1)) ;; best case scenario
- )
- (func $a1 (param $x i32)
- (unreachable)
- )
- (func $b1
- (call $a1 (i32.const 2)) ;; same value in both, so works
- )
- (func $b11
- (call $a1 (i32.const 2))
- )
- (func $a2 (param $x i32)
- (drop (local.get $x))
- )
- (func $b2
- (call $a2 (i32.const 3)) ;; different value!
- )
- (func $b22
- (call $a2 (i32.const 4))
- )
- (func $a3 (param $x i32)
- (drop (i32.const -1)) ;; diff value, but at least unused, so no need to send
- )
- (func $b3
- (call $a3 (i32.const 3))
- )
- (func $b33
- (call $a3 (i32.const 4))
- )
- (func $a4 (param $x i32) ;; diff value, but with effects
- )
- (func $b4
- (call $a4 (unreachable))
- )
- (func $b43
- (call $a4 (i32.const 4))
- )
- (func $a5 (param $x i32) (param $y f64) ;; optimize two
- (drop (local.get $x))
- (drop (local.get $y))
- )
- (func $b5
- (call $a5 (i32.const 1) (f64.const 3.14159))
- )
- (func $a6 (param $x i32) (param $y f64) ;; optimize just one
- (drop (local.get $x))
- (drop (local.get $y))
- )
- (func $b6
- (call $a6 (unreachable) (f64.const 3.14159))
- )
- (func $a7 (param $x i32) (param $y f64) ;; optimize just the other one
- (drop (local.get $x))
- (drop (local.get $y))
- )
- (func $b7
- (call $a7 (i32.const 1) (unreachable))
- )
- (func $a8 (param $x i32)) ;; exported, do not optimize
- (func $b8
- (call $a8 (i32.const 1))
- )
- (func $a9 (param $x i32)) ;; tabled, do not optimize
- (func $b9
- (call $a9 (i32.const 1))
- )
- (func $a10 (param $x i32) ;; recursion
- (call $a10 (i32.const 1))
- (call $a10 (i32.const 1))
- )
- (func $a11 (param $x i32) ;; partially successful recursion
- (call $a11 (i32.const 1))
- (call $a11 (i32.const 2))
- )
- (func $a12 (param $x i32) ;; unsuccessful recursion
- (drop (local.get $x))
- (call $a12 (i32.const 1))
- (call $a12 (i32.const 2))
- )
- ;; return values
- (func $c1
- (local $x i32)
- (drop (call $c2))
- (drop (call $c3))
- (drop (call $c3))
- (drop (call $c4))
- (local.set $x (call $c4))
- (drop (call $c5 (unreachable)))
- (drop (call $c6))
- (drop (call $c7))
- (drop (call $c8))
- )
- (func $c2 (result i32)
- (i32.const 1)
- )
- (func $c3 (result i32)
- (i32.const 2)
- )
- (func $c4 (result i32)
- (i32.const 3)
- )
- (func $c5 (param $x i32) (result i32)
- (local.get $x)
- )
- (func $c6 (result i32)
- (unreachable)
- )
- (func $c7 (result i32)
- (return (i32.const 4))
- )
- (func $c8 (result i32)
- (i32.const 5)
- )
-)
-(module ;; both operations at once: remove params and return value
- (func "a"
- (drop
- (call $b
- (i32.const 1)
- )
- )
- )
- (func $b (param $x i32) (result i32)
- (local.get $x)
- )
-)
-(module ;; tail calls inhibit dropped result removal
- (func $foo (param $x i32) (result i32)
- (drop
- (return_call $bar
- (i32.const 0)
- )
- )
- (i32.const 42)
- )
- (func $bar (param $x i32) (result i32)
- (i32.const 7)
- )
-)
-(module ;; indirect tail calls inhibit dropped result removal
- (type $T (func (result i32)))
- (table 1 1 funcref)
- (func $foo (param $x i32) (result i32)
- (drop
- (return_call_indirect (type $T)
- (i32.const 0)
- )
- )
- )
- (func $bar
- (drop
- (call $foo
- (i32.const 42)
- )
- )
- )
-)
-(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)
- )
-)
-(module
- (type $i64 (func (param i64)))
- (global $global$0 (ref $i64) (ref.func $0))
- (export "even" (func $1))
- ;; the argument to this function cannot be removed due to the ref.func of it
- ;; in a global
- (func $0 (param $0 i64)
- (unreachable)
- )
- (func $1
- (call_ref
- (i64.const 0)
- (global.get $global$0)
- )
- )
- (func $2
- (call $0
- (i64.const 0)
- )
- )
-)
-(module
- ;; a removable non-nullable parameter
- (func $0 (param $x i31ref)
- (nop)
- )
- (func $1
- (call $0
- (i31.new (i32.const 0))
- )
- )
-)