summaryrefslogtreecommitdiff
path: root/test/passes
diff options
context:
space:
mode:
Diffstat (limited to 'test/passes')
-rw-r--r--test/passes/asyncify_enable-multivalue.txt408
-rw-r--r--test/passes/asyncify_mod-asyncify-always-and-only-unwind.txt74
-rw-r--r--test/passes/asyncify_mod-asyncify-never-unwind.txt76
-rw-r--r--test/passes/asyncify_pass-arg=asyncify-imports@env.import,env.import2.txt252
-rw-r--r--test/passes/dce_all-features.txt243
-rw-r--r--test/passes/dce_all-features.wast57
-rw-r--r--test/passes/dce_vacuum.bin.txt98
-rw-r--r--test/passes/dce_vacuum_remove-unused-names.bin.txt94
-rw-r--r--test/passes/dce_vacuum_remove-unused-names.txt (renamed from test/passes/dce_vacuum.txt)0
-rw-r--r--test/passes/dce_vacuum_remove-unused-names.wasm (renamed from test/passes/dce_vacuum.wasm)bin260 -> 260 bytes
-rw-r--r--test/passes/dce_vacuum_remove-unused-names.wast (renamed from test/passes/dce_vacuum.wast)0
-rw-r--r--test/passes/interesting-pass-mix.txt19
12 files changed, 748 insertions, 573 deletions
diff --git a/test/passes/asyncify_enable-multivalue.txt b/test/passes/asyncify_enable-multivalue.txt
index 08d0d7bf9..7d92b0c97 100644
--- a/test/passes/asyncify_enable-multivalue.txt
+++ b/test/passes/asyncify_enable-multivalue.txt
@@ -491,55 +491,57 @@
)
)
(block
- (if
- (if (result i32)
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $6)
- (i32.const 0)
- )
- )
- (block
- (local.set $7
- (call $import2)
- )
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__asyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__asyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $6)
(i32.const 0)
)
- (local.set $1
- (local.get $7)
+ )
+ (block
+ (local.set $7
+ (call $import2)
+ )
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 1)
+ )
+ (br $__asyncify_unwind
+ (i32.const 0)
+ )
+ (local.set $1
+ (local.get $7)
+ )
)
)
)
- )
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (block
- (local.set $temp
- (local.get $1)
- )
- (local.set $2
- (local.get $temp)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
)
- (return
- (local.get $2)
+ (block
+ (local.set $temp
+ (local.get $1)
+ )
+ (local.set $2
+ (local.get $temp)
+ )
+ (return
+ (local.get $2)
+ )
)
)
+ (nop)
+ (nop)
)
- (nop)
- (nop)
)
(unreachable)
)
@@ -814,84 +816,86 @@
)
)
(block
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (loop $l
- (local.set $3
- (local.get $y)
- )
- (local.set $4
- (i32.add
- (local.get $3)
- (i32.const 1)
- )
- )
- (local.set $x
- (local.get $4)
- )
- (local.set $5
- (local.get $x)
- )
- (local.set $6
- (i32.div_s
- (local.get $5)
- (i32.const 3)
- )
- )
- (local.set $y
- (local.get $6)
- )
- (local.set $7
- (local.get $y)
- )
- (br_if $l
- (local.get $7)
- )
- )
- )
- (if
- (if (result i32)
+ (block
+ (if
(i32.eq
(global.get $__asyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $12)
- (i32.const 0)
+ (loop $l
+ (local.set $3
+ (local.get $y)
+ )
+ (local.set $4
+ (i32.add
+ (local.get $3)
+ (i32.const 1)
+ )
+ )
+ (local.set $x
+ (local.get $4)
+ )
+ (local.set $5
+ (local.get $x)
+ )
+ (local.set $6
+ (i32.div_s
+ (local.get $5)
+ (i32.const 3)
+ )
+ )
+ (local.set $y
+ (local.get $6)
+ )
+ (local.set $7
+ (local.get $y)
+ )
+ (br_if $l
+ (local.get $7)
+ )
)
)
- (block
- (call $import)
- (if
+ (if
+ (if (result i32)
(i32.eq
(global.get $__asyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__asyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $12)
(i32.const 0)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 1)
+ )
+ (br $__asyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
- )
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (block
- (local.set $8
- (local.get $y)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
)
- (return
- (local.get $8)
+ (block
+ (local.set $8
+ (local.get $y)
+ )
+ (return
+ (local.get $8)
+ )
)
)
+ (nop)
)
- (nop)
)
(unreachable)
)
@@ -1291,90 +1295,92 @@
)
(block
(block
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (local.set $1
- (local.get $x)
- )
- )
(block
(if
(i32.eq
(global.get $__asyncify_state)
(i32.const 0)
)
- (local.set $4
- (local.get $1)
+ (local.set $1
+ (local.get $x)
)
)
- (if
- (i32.or
- (local.get $4)
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 2)
- )
- )
+ (block
(if
(i32.eq
(global.get $__asyncify_state)
(i32.const 0)
)
- (return
- (i32.const 1)
- )
- )
- )
- (if
- (i32.or
- (i32.eqz
- (local.get $4)
- )
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 2)
+ (local.set $4
+ (local.get $1)
)
)
(if
- (if (result i32)
+ (i32.or
+ (local.get $4)
(i32.eq
(global.get $__asyncify_state)
- (i32.const 0)
+ (i32.const 2)
)
- (i32.const 1)
+ )
+ (if
(i32.eq
- (local.get $6)
+ (global.get $__asyncify_state)
(i32.const 0)
)
+ (return
+ (i32.const 1)
+ )
)
- (block
- (call $import3
+ )
+ (if
+ (i32.or
+ (i32.eqz
+ (local.get $4)
+ )
+ (i32.eq
+ (global.get $__asyncify_state)
(i32.const 2)
)
- (if
+ )
+ (if
+ (if (result i32)
(i32.eq
(global.get $__asyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__asyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $6)
(i32.const 0)
)
)
+ (block
+ (call $import3
+ (i32.const 2)
+ )
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 1)
+ )
+ (br $__asyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
)
)
)
- )
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (return
- (i32.const 3)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
+ )
+ (return
+ (i32.const 3)
+ )
)
)
)
@@ -1470,90 +1476,92 @@
)
(block
(block
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (local.set $1
- (local.get $x)
- )
- )
(block
(if
(i32.eq
(global.get $__asyncify_state)
(i32.const 0)
)
- (local.set $4
- (local.get $1)
+ (local.set $1
+ (local.get $x)
)
)
- (if
- (i32.or
- (local.get $4)
+ (block
+ (if
(i32.eq
(global.get $__asyncify_state)
- (i32.const 2)
+ (i32.const 0)
+ )
+ (local.set $4
+ (local.get $1)
)
)
(if
- (if (result i32)
+ (i32.or
+ (local.get $4)
(i32.eq
(global.get $__asyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $6)
- (i32.const 0)
+ (i32.const 2)
)
)
- (block
- (call $import3
- (i32.const 1)
- )
- (if
+ (if
+ (if (result i32)
(i32.eq
(global.get $__asyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__asyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $6)
(i32.const 0)
)
)
- )
- )
- )
- (if
- (i32.or
- (i32.eqz
- (local.get $4)
- )
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 2)
+ (block
+ (call $import3
+ (i32.const 1)
+ )
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 1)
+ )
+ (br $__asyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
)
(if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
+ (i32.or
+ (i32.eqz
+ (local.get $4)
+ )
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 2)
+ )
)
- (return
- (i32.const 2)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
+ )
+ (return
+ (i32.const 2)
+ )
)
)
)
)
- )
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (return
- (i32.const 3)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
+ )
+ (return
+ (i32.const 3)
+ )
)
)
)
diff --git a/test/passes/asyncify_mod-asyncify-always-and-only-unwind.txt b/test/passes/asyncify_mod-asyncify-always-and-only-unwind.txt
index 62c3ba33f..ecf0a41c8 100644
--- a/test/passes/asyncify_mod-asyncify-always-and-only-unwind.txt
+++ b/test/passes/asyncify_mod-asyncify-always-and-only-unwind.txt
@@ -152,52 +152,54 @@
)
)
(block
- (if
- (if (result i32)
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $6)
- (i32.const 0)
- )
- )
- (block
- (local.set $7
- (call $import2)
- )
- (if
+ (block
+ (if
+ (if (result i32)
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
+ )
(i32.const 1)
- (br $__asyncify_unwind
+ (i32.eq
+ (local.get $6)
(i32.const 0)
)
- (local.set $1
- (local.get $7)
+ )
+ (block
+ (local.set $7
+ (call $import2)
+ )
+ (if
+ (i32.const 1)
+ (br $__asyncify_unwind
+ (i32.const 0)
+ )
+ (local.set $1
+ (local.get $7)
+ )
)
)
)
- )
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (block
- (local.set $temp
- (local.get $1)
- )
- (local.set $2
- (local.get $temp)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
)
- (return
- (local.get $2)
+ (block
+ (local.set $temp
+ (local.get $1)
+ )
+ (local.set $2
+ (local.get $temp)
+ )
+ (return
+ (local.get $2)
+ )
)
)
+ (nop)
+ (nop)
)
- (nop)
- (nop)
)
(unreachable)
)
diff --git a/test/passes/asyncify_mod-asyncify-never-unwind.txt b/test/passes/asyncify_mod-asyncify-never-unwind.txt
index eaf2794cf..2177c5220 100644
--- a/test/passes/asyncify_mod-asyncify-never-unwind.txt
+++ b/test/passes/asyncify_mod-asyncify-never-unwind.txt
@@ -164,52 +164,54 @@
)
)
(block
- (if
- (if (result i32)
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $6)
- (i32.const 0)
- )
- )
- (block
- (local.set $7
- (call $import2)
- )
- (if
- (i32.const 0)
- (br $__asyncify_unwind
+ (block
+ (if
+ (if (result i32)
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
+ )
+ (i32.const 1)
+ (i32.eq
+ (local.get $6)
(i32.const 0)
)
- (local.set $1
- (local.get $7)
+ )
+ (block
+ (local.set $7
+ (call $import2)
+ )
+ (if
+ (i32.const 0)
+ (br $__asyncify_unwind
+ (i32.const 0)
+ )
+ (local.set $1
+ (local.get $7)
+ )
)
)
)
- )
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (block
- (local.set $temp
- (local.get $1)
- )
- (local.set $2
- (local.get $temp)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
)
- (return
- (local.get $2)
+ (block
+ (local.set $temp
+ (local.get $1)
+ )
+ (local.set $2
+ (local.get $temp)
+ )
+ (return
+ (local.get $2)
+ )
)
)
+ (nop)
+ (nop)
)
- (nop)
- (nop)
)
(unreachable)
)
diff --git a/test/passes/asyncify_pass-arg=asyncify-imports@env.import,env.import2.txt b/test/passes/asyncify_pass-arg=asyncify-imports@env.import,env.import2.txt
index defef94ed..2a8c0061a 100644
--- a/test/passes/asyncify_pass-arg=asyncify-imports@env.import,env.import2.txt
+++ b/test/passes/asyncify_pass-arg=asyncify-imports@env.import,env.import2.txt
@@ -488,55 +488,57 @@
)
)
(block
- (if
- (if (result i32)
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $6)
- (i32.const 0)
- )
- )
- (block
- (local.set $7
- (call $import2)
- )
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__asyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__asyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $6)
(i32.const 0)
)
- (local.set $1
- (local.get $7)
+ )
+ (block
+ (local.set $7
+ (call $import2)
+ )
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 1)
+ )
+ (br $__asyncify_unwind
+ (i32.const 0)
+ )
+ (local.set $1
+ (local.get $7)
+ )
)
)
)
- )
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (block
- (local.set $temp
- (local.get $1)
- )
- (local.set $2
- (local.get $temp)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
)
- (return
- (local.get $2)
+ (block
+ (local.set $temp
+ (local.get $1)
+ )
+ (local.set $2
+ (local.get $temp)
+ )
+ (return
+ (local.get $2)
+ )
)
)
+ (nop)
+ (nop)
)
- (nop)
- (nop)
)
(unreachable)
)
@@ -810,84 +812,86 @@
)
)
(block
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (loop $l
- (local.set $2
- (local.get $y)
- )
- (local.set $3
- (i32.add
- (local.get $2)
- (i32.const 1)
- )
- )
- (local.set $x
- (local.get $3)
- )
- (local.set $4
- (local.get $x)
- )
- (local.set $5
- (i32.div_s
- (local.get $4)
- (i32.const 3)
- )
- )
- (local.set $y
- (local.get $5)
- )
- (local.set $6
- (local.get $y)
- )
- (br_if $l
- (local.get $6)
- )
- )
- )
- (if
- (if (result i32)
+ (block
+ (if
(i32.eq
(global.get $__asyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $11)
- (i32.const 0)
+ (loop $l
+ (local.set $2
+ (local.get $y)
+ )
+ (local.set $3
+ (i32.add
+ (local.get $2)
+ (i32.const 1)
+ )
+ )
+ (local.set $x
+ (local.get $3)
+ )
+ (local.set $4
+ (local.get $x)
+ )
+ (local.set $5
+ (i32.div_s
+ (local.get $4)
+ (i32.const 3)
+ )
+ )
+ (local.set $y
+ (local.get $5)
+ )
+ (local.set $6
+ (local.get $y)
+ )
+ (br_if $l
+ (local.get $6)
+ )
)
)
- (block
- (call $import)
- (if
+ (if
+ (if (result i32)
(i32.eq
(global.get $__asyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__asyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $11)
(i32.const 0)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 1)
+ )
+ (br $__asyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
- )
- (if
- (i32.eq
- (global.get $__asyncify_state)
- (i32.const 0)
- )
- (block
- (local.set $7
- (local.get $y)
+ (if
+ (i32.eq
+ (global.get $__asyncify_state)
+ (i32.const 0)
)
- (return
- (local.get $7)
+ (block
+ (local.set $7
+ (local.get $y)
+ )
+ (return
+ (local.get $7)
+ )
)
)
+ (nop)
)
- (nop)
)
(unreachable)
)
@@ -1062,21 +1066,23 @@
(local $2 i32)
(local $3 i32)
(block
- (local.set $1
- (local.get $x)
- )
- (if
- (local.get $1)
- (return
- (i32.const 1)
+ (block
+ (local.set $1
+ (local.get $x)
)
- (call $import3
- (i32.const 2)
+ (if
+ (local.get $1)
+ (return
+ (i32.const 1)
+ )
+ (call $import3
+ (i32.const 2)
+ )
)
)
- )
- (return
- (i32.const 3)
+ (return
+ (i32.const 3)
+ )
)
)
(func $calls-import2-if-else-oneside2 (param $x i32) (result i32)
@@ -1084,21 +1090,23 @@
(local $2 i32)
(local $3 i32)
(block
- (local.set $1
- (local.get $x)
- )
- (if
- (local.get $1)
- (call $import3
- (i32.const 1)
+ (block
+ (local.set $1
+ (local.get $x)
)
- (return
- (i32.const 2)
+ (if
+ (local.get $1)
+ (call $import3
+ (i32.const 1)
+ )
+ (return
+ (i32.const 2)
+ )
)
)
- )
- (return
- (i32.const 3)
+ (return
+ (i32.const 3)
+ )
)
)
(func $calls-loop (param $x i32)
diff --git a/test/passes/dce_all-features.txt b/test/passes/dce_all-features.txt
index 4b76b2f12..4088d5a34 100644
--- a/test/passes/dce_all-features.txt
+++ b/test/passes/dce_all-features.txt
@@ -24,7 +24,9 @@
)
(if
(i32.const 0)
- (return)
+ (block $out3
+ (return)
+ )
)
(block $out4
(br_table $out4 $out4 $out4 $out4
@@ -41,10 +43,12 @@
)
(if
(i32.const 0)
- (if
- (i32.const 0)
- (unreachable)
- (unreachable)
+ (block $block4
+ (if
+ (i32.const 0)
+ (unreachable)
+ (unreachable)
+ )
)
)
(if
@@ -69,13 +73,15 @@
)
(if
(i32.const 0)
- (block $out18
- (block $in19
- (br_if $in19
- (i32.const 1)
+ (block $block11
+ (block $out18
+ (block $in19
+ (br_if $in19
+ (i32.const 1)
+ )
)
+ (unreachable)
)
- (unreachable)
)
)
(block $out20
@@ -96,13 +102,15 @@
)
(if
(i32.const 0)
- (block $out25
- (block $in26
- (br_table $in26 $in26
- (i32.const 1)
+ (block $block13
+ (block $out25
+ (block $in26
+ (br_table $in26 $in26
+ (i32.const 1)
+ )
)
+ (unreachable)
)
- (unreachable)
)
)
(if
@@ -122,7 +130,7 @@
(unreachable)
)
(block $out29
- (block
+ (loop $in30
(br_if $out29
(i32.const 1)
)
@@ -131,11 +139,13 @@
)
(if
(i32.const 0)
- (loop $in32
- (br_if $in32
- (i32.const 1)
+ (block $block20
+ (loop $in32
+ (br_if $in32
+ (i32.const 1)
+ )
+ (unreachable)
)
- (unreachable)
)
)
(if
@@ -273,8 +283,12 @@
)
)
(func $typed-block-none-then-unreachable (result i32)
- (return
- (i32.const 0)
+ (block $top-typed
+ (block $switch$0
+ (return
+ (i32.const 0)
+ )
+ )
)
)
(func $typed-block-remove-br-changes-type (param $$$0 i32) (result i32)
@@ -317,15 +331,19 @@
)
)
(func $unreachable-block-ends-switch (result i32)
- (block $label$3
- (nop)
- (unreachable)
+ (block $label$0
+ (block $label$3
+ (nop)
+ (unreachable)
+ )
)
)
(func $unreachable-block-ends-br_if (result i32)
- (block $label$2
- (nop)
- (unreachable)
+ (block $label$0
+ (block $label$2
+ (nop)
+ (unreachable)
+ )
)
)
(func $unreachable-brs-3 (result i32)
@@ -339,11 +357,15 @@
(drop
(i32.const 1)
)
- (block
- (drop
- (i32.const 4104)
+ (block $label$0
+ (block $label$1
+ (block
+ (drop
+ (i32.const 4104)
+ )
+ (unreachable)
+ )
)
- (unreachable)
)
)
(func $call-unreach (param $var$0 i64) (param $var$1 i64) (result i64)
@@ -355,32 +377,36 @@
(block $label$0 (result i64)
(local.get $var$1)
)
- (block
- (drop
- (i64.sub
- (local.get $var$0)
- (i64.const 1)
- )
- )
+ (block $label$1
(block
(drop
- (block $block (result i64)
- (local.set $2
- (local.get $var$0)
+ (i64.sub
+ (local.get $var$0)
+ (i64.const 1)
+ )
+ )
+ (block
+ (drop
+ (block $block (result i64)
+ (local.set $2
+ (local.get $var$0)
+ )
+ (nop)
+ (local.get $2)
)
- (nop)
- (local.get $2)
)
+ (unreachable)
)
- (unreachable)
)
)
)
)
(func $br-gone-means-block-type-changes-then-refinalize-at-end-is-too-late (param $var$0 i32) (result i32)
- (block $block
- (nop)
- (unreachable)
+ (block $label$0
+ (block $block
+ (nop)
+ (unreachable)
+ )
)
)
(func $br-with-unreachable-value-should-not-give-a-block-a-value (param $var$0 i32) (result i32)
@@ -397,25 +423,31 @@
)
)
(func $replace-br-value-of-i32-with-unreachable (result i32)
- (block $label$1
- (nop)
- (unreachable)
+ (block $label$0
+ (block $label$1
+ (nop)
+ (unreachable)
+ )
)
)
(func $shorten-block-requires-sync-refinalize (param $var$0 i32) (param $var$1 i32)
(unreachable)
)
(func $block-with-type-but-is-unreachable (param $var$0 i32) (result i32)
- (block $block
- (nop)
- (unreachable)
+ (block $label$0
+ (block $block
+ (nop)
+ (unreachable)
+ )
)
)
(func $if-with-type-but-is-unreachable (param $var$0 i32) (result i32)
- (if
- (local.get $var$0)
- (unreachable)
- (unreachable)
+ (block $label$0
+ (if
+ (local.get $var$0)
+ (unreachable)
+ (unreachable)
+ )
)
)
(func $unreachable-loop
@@ -423,8 +455,10 @@
)
(func $br-block-from-unary (result i32)
(block $label$6 (result i32)
- (br $label$6
- (i32.const 8)
+ (block $label$7
+ (br $label$6
+ (i32.const 8)
+ )
)
)
)
@@ -444,19 +478,23 @@
)
)
(func $replace-with-unreachable-affects-parent (param $var$0 f32) (param $var$1 i64)
- (drop
- (i64.const 0)
- )
- (if
- (block $block (result i32)
- (call $replace-with-unreachable-affects-parent
- (f32.const 1)
- (i64.const -15917430362925035)
+ (block $top
+ (block
+ (drop
+ (i64.const 0)
+ )
+ (if
+ (block $block (result i32)
+ (call $replace-with-unreachable-affects-parent
+ (f32.const 1)
+ (i64.const -15917430362925035)
+ )
+ (i32.const 1)
+ )
+ (unreachable)
+ (unreachable)
)
- (i32.const 1)
)
- (unreachable)
- (unreachable)
)
)
(func $replace-block-changes-later-when-if-goes
@@ -503,6 +541,7 @@
)
(module
(type $none_=>_none (func))
+ (type $none_=>_i32 (func (result i32)))
(event $e (attr 0) (param))
(func $foo
(nop)
@@ -542,12 +581,68 @@
)
)
(func $throw
- (throw $e
+ (block $label$0
+ (block $label$1
+ (throw $e
+ )
+ )
)
)
(func $rethrow
- (rethrow
- (ref.null exn)
+ (block $label$0
+ (block $label$1
+ (rethrow
+ (ref.null exn)
+ )
+ )
+ )
+ )
+ (func $unnecessary-concrete-block (result i32)
+ (block $foo
+ (nop)
+ (unreachable)
+ )
+ )
+ (func $necessary-concrete-block (result i32)
+ (block $foo (result i32)
+ (br $foo
+ (i32.const 1)
+ )
+ )
+ )
+ (func $unnecessary-concrete-if (result i32)
+ (if
+ (i32.const 0)
+ (return
+ (i32.const 1)
+ )
+ (unreachable)
+ )
+ )
+ (func $unnecessary-concrete-try (result i32)
+ (try
+ (do
+ (unreachable)
+ )
+ (catch
+ (unreachable)
+ )
+ )
+ )
+ (func $note-loss-of-if-children
+ (block $label$1
+ (block $label$2
+ (nop)
+ (unreachable)
+ )
+ )
+ )
+ (func $note-loss-of-non-control-flow-children
+ (block $out
+ (block $block
+ (nop)
+ (unreachable)
+ )
)
)
)
diff --git a/test/passes/dce_all-features.wast b/test/passes/dce_all-features.wast
index bf0c188d0..9ebcccb60 100644
--- a/test/passes/dce_all-features.wast
+++ b/test/passes/dce_all-features.wast
@@ -810,4 +810,61 @@
)
)
)
+
+ (func $unnecessary-concrete-block (result i32)
+ (block $foo (result i32) ;; unnecessary type
+ (nop)
+ (unreachable)
+ )
+ )
+ (func $necessary-concrete-block (result i32)
+ (block $foo (result i32)
+ (br $foo (i32.const 1))
+ (unreachable)
+ )
+ )
+ (func $unnecessary-concrete-if (result i32)
+ (if (result i32) ;; unnecessary type
+ (i32.const 0)
+ (return (i32.const 1))
+ (unreachable)
+ )
+ )
+ (func $unnecessary-concrete-try (result i32)
+ (try (result i32)
+ (do
+ (unreachable)
+ )
+ (catch
+ (unreachable)
+ )
+ )
+ )
+ (func $note-loss-of-if-children
+ (block $label$1
+ (if ;; begins unreachable - type never changes - but after the condition
+ ;; becomes unreachable, it will lose the children, which means no more
+ ;; br to the outer block, changing that type.
+ (block $label$2 (result i32)
+ (nop)
+ (unreachable)
+ )
+ (unreachable)
+ (br $label$1)
+ )
+ )
+ )
+ (func $note-loss-of-non-control-flow-children
+ (block $out
+ (drop
+ (i32.add
+ (block (result i32)
+ (nop)
+ (unreachable)
+ )
+ (br $out) ;; when this is removed as dead, the block becomes unreachable
+ )
+ )
+ )
+ )
)
diff --git a/test/passes/dce_vacuum.bin.txt b/test/passes/dce_vacuum.bin.txt
deleted file mode 100644
index cee1143d3..000000000
--- a/test/passes/dce_vacuum.bin.txt
+++ /dev/null
@@ -1,98 +0,0 @@
-(module
- (type $f32_f32_=>_f32 (func (param f32 f32) (result f32)))
- (type $f64_f64_=>_f64 (func (param f64 f64) (result f64)))
- (export "f32.compute_radix" (func $0))
- (export "f64.compute_radix" (func $1))
- (func $0 (param $0 f32) (param $1 f32) (result f32)
- (block $label$1
- (loop $label$2
- (br_if $label$2
- (f32.eq
- (f32.add
- (f32.sub
- (f32.add
- (local.tee $0
- (f32.add
- (local.get $0)
- (local.get $0)
- )
- )
- (f32.const 1)
- )
- (local.get $0)
- )
- (f32.const -1)
- )
- (f32.const 0)
- )
- )
- )
- (block
- (drop
- (call $0
- (f32.add
- (local.get $0)
- (local.tee $1
- (f32.add
- (local.get $1)
- (f32.const 1)
- )
- )
- )
- (local.get $0)
- )
- )
- (unreachable)
- )
- )
- )
- (func $1 (param $0 f64) (param $1 f64) (result f64)
- (block $label$1 (result f64)
- (loop $label$2
- (br_if $label$2
- (f64.eq
- (f64.add
- (f64.sub
- (f64.add
- (local.tee $0
- (f64.add
- (local.get $0)
- (local.get $0)
- )
- )
- (f64.const 1)
- )
- (local.get $0)
- )
- (f64.const -1)
- )
- (f64.const 0)
- )
- )
- )
- (loop $label$3
- (br_if $label$3
- (f64.ne
- (f64.sub
- (f64.sub
- (f64.add
- (local.get $0)
- (local.tee $1
- (f64.add
- (local.get $1)
- (f64.const 1)
- )
- )
- )
- (local.get $0)
- )
- (local.get $1)
- )
- (f64.const 0)
- )
- )
- )
- (local.get $1)
- )
- )
-)
diff --git a/test/passes/dce_vacuum_remove-unused-names.bin.txt b/test/passes/dce_vacuum_remove-unused-names.bin.txt
new file mode 100644
index 000000000..26e2c565a
--- /dev/null
+++ b/test/passes/dce_vacuum_remove-unused-names.bin.txt
@@ -0,0 +1,94 @@
+(module
+ (type $f32_f32_=>_f32 (func (param f32 f32) (result f32)))
+ (type $f64_f64_=>_f64 (func (param f64 f64) (result f64)))
+ (export "f32.compute_radix" (func $0))
+ (export "f64.compute_radix" (func $1))
+ (func $0 (param $0 f32) (param $1 f32) (result f32)
+ (loop $label$2
+ (br_if $label$2
+ (f32.eq
+ (f32.add
+ (f32.sub
+ (f32.add
+ (local.tee $0
+ (f32.add
+ (local.get $0)
+ (local.get $0)
+ )
+ )
+ (f32.const 1)
+ )
+ (local.get $0)
+ )
+ (f32.const -1)
+ )
+ (f32.const 0)
+ )
+ )
+ )
+ (block
+ (drop
+ (call $0
+ (f32.add
+ (local.get $0)
+ (local.tee $1
+ (f32.add
+ (local.get $1)
+ (f32.const 1)
+ )
+ )
+ )
+ (local.get $0)
+ )
+ )
+ (unreachable)
+ )
+ )
+ (func $1 (param $0 f64) (param $1 f64) (result f64)
+ (loop $label$2
+ (br_if $label$2
+ (f64.eq
+ (f64.add
+ (f64.sub
+ (f64.add
+ (local.tee $0
+ (f64.add
+ (local.get $0)
+ (local.get $0)
+ )
+ )
+ (f64.const 1)
+ )
+ (local.get $0)
+ )
+ (f64.const -1)
+ )
+ (f64.const 0)
+ )
+ )
+ )
+ (loop $label$3
+ (br_if $label$3
+ (f64.ne
+ (f64.sub
+ (f64.sub
+ (f64.add
+ (local.get $0)
+ (local.tee $1
+ (f64.add
+ (local.get $1)
+ (f64.const 1)
+ )
+ )
+ )
+ (local.get $0)
+ )
+ (local.get $1)
+ )
+ (f64.const 0)
+ )
+ )
+ )
+ (local.get $1)
+ )
+)
diff --git a/test/passes/dce_vacuum.txt b/test/passes/dce_vacuum_remove-unused-names.txt
index 2c4466058..2c4466058 100644
--- a/test/passes/dce_vacuum.txt
+++ b/test/passes/dce_vacuum_remove-unused-names.txt
diff --git a/test/passes/dce_vacuum.wasm b/test/passes/dce_vacuum_remove-unused-names.wasm
index 5fa1892bd..5fa1892bd 100644
--- a/test/passes/dce_vacuum.wasm
+++ b/test/passes/dce_vacuum_remove-unused-names.wasm
Binary files differ
diff --git a/test/passes/dce_vacuum.wast b/test/passes/dce_vacuum_remove-unused-names.wast
index 47f4affbd..47f4affbd 100644
--- a/test/passes/dce_vacuum.wast
+++ b/test/passes/dce_vacuum_remove-unused-names.wast
diff --git a/test/passes/interesting-pass-mix.txt b/test/passes/interesting-pass-mix.txt
index 0fbbc809c..c37414599 100644
--- a/test/passes/interesting-pass-mix.txt
+++ b/test/passes/interesting-pass-mix.txt
@@ -41,14 +41,16 @@
)
(loop $shape$4$continue
(call $trivial)
- (br_if $shape$4$continue
+ (if
(local.get $0)
+ (br $shape$4$continue)
)
)
(loop $shape$6$continue
(call $trivial)
- (br_if $shape$6$continue
+ (if
(local.get $0)
+ (br $shape$6$continue)
)
)
)
@@ -119,8 +121,9 @@
(call $before-and-after
(i32.const 9)
)
- (br_if $shape$4$continue
+ (if
(local.get $0)
+ (br $shape$4$continue)
)
)
(call $before-and-after
@@ -187,9 +190,12 @@
)
(block $block$7$break
(block $switch$3$default
- (br_table $block$7$break $block$7$break $block$7$break $switch$3$default
- (local.get $0)
+ (block $switch$3$case$7
+ (br_table $switch$3$case$7 $switch$3$case$7 $switch$3$case$7 $switch$3$default
+ (local.get $0)
+ )
)
+ (br $block$7$break)
)
(call $switch
(i32.const 2)
@@ -212,8 +218,9 @@
(call $if-br-wat
(i32.const 1)
)
- (br_if $block$2$break
+ (if
(local.get $0)
+ (br $block$2$break)
)
)
(call $if-br-wat