summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/emcc_O2_hello_world.fromasm29
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise29
-rw-r--r--test/emcc_hello_world.fromasm29
-rw-r--r--test/emcc_hello_world.fromasm.imprecise29
-rw-r--r--test/example/c-api-kitchen-sink.txt2
-rw-r--r--test/example/c-api-kitchen-sink.txt.txt1
-rw-r--r--test/memorygrowth.fromasm29
-rw-r--r--test/memorygrowth.fromasm.imprecise29
-rw-r--r--test/min.fromasm2
-rw-r--r--test/min.fromasm.imprecise2
-rw-r--r--test/passes/remove-unused-functions.txt34
-rw-r--r--test/passes/remove-unused-functions.wast49
-rw-r--r--test/passes/remove-unused-module-elements.txt87
-rw-r--r--test/passes/remove-unused-module-elements.wast96
-rw-r--r--test/unit.fromasm8
-rw-r--r--test/unit.fromasm.imprecise8
-rw-r--r--test/wasm-only.fromasm12
-rw-r--r--test/wasm-only.fromasm.imprecise12
-rw-r--r--test/wasm-only.fromasm.imprecise.no-opts12
-rw-r--r--test/wasm-only.fromasm.no-opts12
20 files changed, 223 insertions, 288 deletions
diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm
index 2a55e5b8a..4d3147862 100644
--- a/test/emcc_O2_hello_world.fromasm
+++ b/test/emcc_O2_hello_world.fromasm
@@ -8,10 +8,6 @@
(type $FUNCSIG$vii (func (param i32 i32)))
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
- (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
- (import "env" "ABORT" (global $ABORT$asm2wasm$import i32))
- (import "global" "NaN" (global $nan$asm2wasm$import f64))
- (import "global" "Infinity" (global $inf$asm2wasm$import f64))
(import "env" "abort" (func $abort (param i32)))
(import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32)))
(import "env" "_pthread_self" (func $_pthread_self (result i32)))
@@ -36,34 +32,9 @@
(data (i32.const 1024) "emcc_O2_hello_world.asm.js")
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
- (global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
- (global $ABORT (mut i32) (get_global $ABORT$asm2wasm$import))
(global $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
- (global $setjmpId (mut i32) (i32.const 0))
- (global $undef (mut i32) (i32.const 0))
- (global $nan (mut f64) (get_global $nan$asm2wasm$import))
- (global $inf (mut f64) (get_global $inf$asm2wasm$import))
- (global $tempInt (mut i32) (i32.const 0))
- (global $tempBigInt (mut i32) (i32.const 0))
- (global $tempBigIntP (mut i32) (i32.const 0))
- (global $tempBigIntS (mut i32) (i32.const 0))
- (global $tempBigIntR (mut f64) (f64.const 0))
- (global $tempBigIntI (mut i32) (i32.const 0))
- (global $tempBigIntD (mut i32) (i32.const 0))
- (global $tempValue (mut i32) (i32.const 0))
- (global $tempDouble (mut f64) (f64.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
- (global $tempRet1 (mut i32) (i32.const 0))
- (global $tempRet2 (mut i32) (i32.const 0))
- (global $tempRet3 (mut i32) (i32.const 0))
- (global $tempRet4 (mut i32) (i32.const 0))
- (global $tempRet5 (mut i32) (i32.const 0))
- (global $tempRet6 (mut i32) (i32.const 0))
- (global $tempRet7 (mut i32) (i32.const 0))
- (global $tempRet8 (mut i32) (i32.const 0))
- (global $tempRet9 (mut i32) (i32.const 0))
- (global $tempFloat (mut f64) (f64.const 0))
(export "_free" (func $_free))
(export "_main" (func $_main))
(export "_memset" (func $_memset))
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise
index 88b92fcef..8ab35a567 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise
+++ b/test/emcc_O2_hello_world.fromasm.imprecise
@@ -8,10 +8,6 @@
(type $FUNCSIG$vii (func (param i32 i32)))
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
- (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
- (import "env" "ABORT" (global $ABORT$asm2wasm$import i32))
- (import "global" "NaN" (global $nan$asm2wasm$import f64))
- (import "global" "Infinity" (global $inf$asm2wasm$import f64))
(import "env" "abort" (func $abort (param i32)))
(import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32)))
(import "env" "_pthread_self" (func $_pthread_self (result i32)))
@@ -34,34 +30,9 @@
(elem (get_global $tableBase) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
- (global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
- (global $ABORT (mut i32) (get_global $ABORT$asm2wasm$import))
(global $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
- (global $setjmpId (mut i32) (i32.const 0))
- (global $undef (mut i32) (i32.const 0))
- (global $nan (mut f64) (get_global $nan$asm2wasm$import))
- (global $inf (mut f64) (get_global $inf$asm2wasm$import))
- (global $tempInt (mut i32) (i32.const 0))
- (global $tempBigInt (mut i32) (i32.const 0))
- (global $tempBigIntP (mut i32) (i32.const 0))
- (global $tempBigIntS (mut i32) (i32.const 0))
- (global $tempBigIntR (mut f64) (f64.const 0))
- (global $tempBigIntI (mut i32) (i32.const 0))
- (global $tempBigIntD (mut i32) (i32.const 0))
- (global $tempValue (mut i32) (i32.const 0))
- (global $tempDouble (mut f64) (f64.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
- (global $tempRet1 (mut i32) (i32.const 0))
- (global $tempRet2 (mut i32) (i32.const 0))
- (global $tempRet3 (mut i32) (i32.const 0))
- (global $tempRet4 (mut i32) (i32.const 0))
- (global $tempRet5 (mut i32) (i32.const 0))
- (global $tempRet6 (mut i32) (i32.const 0))
- (global $tempRet7 (mut i32) (i32.const 0))
- (global $tempRet8 (mut i32) (i32.const 0))
- (global $tempRet9 (mut i32) (i32.const 0))
- (global $tempFloat (mut f64) (f64.const 0))
(export "_free" (func $_free))
(export "_main" (func $_main))
(export "_memset" (func $_memset))
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index 285bfc334..85d980069 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -10,10 +10,6 @@
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
(import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
- (import "env" "ABORT" (global $ABORT$asm2wasm$import i32))
- (import "env" "cttz_i8" (global $cttz_i8$asm2wasm$import i32))
- (import "global" "NaN" (global $nan$asm2wasm$import f64))
- (import "global" "Infinity" (global $inf$asm2wasm$import f64))
(import "env" "abort" (func $abort))
(import "env" "nullFunc_ii" (func $nullFunc_ii (param i32)))
(import "env" "nullFunc_iiii" (func $nullFunc_iiii (param i32)))
@@ -46,34 +42,9 @@
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
- (global $ABORT (mut i32) (get_global $ABORT$asm2wasm$import))
- (global $cttz_i8 (mut i32) (get_global $cttz_i8$asm2wasm$import))
(global $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
- (global $setjmpId (mut i32) (i32.const 0))
- (global $undef (mut i32) (i32.const 0))
- (global $nan (mut f64) (get_global $nan$asm2wasm$import))
- (global $inf (mut f64) (get_global $inf$asm2wasm$import))
- (global $tempInt (mut i32) (i32.const 0))
- (global $tempBigInt (mut i32) (i32.const 0))
- (global $tempBigIntP (mut i32) (i32.const 0))
- (global $tempBigIntS (mut i32) (i32.const 0))
- (global $tempBigIntR (mut f64) (f64.const 0))
- (global $tempBigIntI (mut i32) (i32.const 0))
- (global $tempBigIntD (mut i32) (i32.const 0))
- (global $tempValue (mut i32) (i32.const 0))
- (global $tempDouble (mut f64) (f64.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
- (global $tempRet1 (mut i32) (i32.const 0))
- (global $tempRet2 (mut i32) (i32.const 0))
- (global $tempRet3 (mut i32) (i32.const 0))
- (global $tempRet4 (mut i32) (i32.const 0))
- (global $tempRet5 (mut i32) (i32.const 0))
- (global $tempRet6 (mut i32) (i32.const 0))
- (global $tempRet7 (mut i32) (i32.const 0))
- (global $tempRet8 (mut i32) (i32.const 0))
- (global $tempRet9 (mut i32) (i32.const 0))
- (global $tempFloat (mut f64) (f64.const 0))
(export "_i64Subtract" (func $_i64Subtract))
(export "_free" (func $_free))
(export "_main" (func $_main))
diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise
index 806735e42..65bd295bc 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -9,10 +9,6 @@
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
(import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
- (import "env" "ABORT" (global $ABORT$asm2wasm$import i32))
- (import "env" "cttz_i8" (global $cttz_i8$asm2wasm$import i32))
- (import "global" "NaN" (global $nan$asm2wasm$import f64))
- (import "global" "Infinity" (global $inf$asm2wasm$import f64))
(import "env" "abort" (func $abort))
(import "env" "nullFunc_ii" (func $nullFunc_ii (param i32)))
(import "env" "nullFunc_iiii" (func $nullFunc_iiii (param i32)))
@@ -39,34 +35,9 @@
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
- (global $ABORT (mut i32) (get_global $ABORT$asm2wasm$import))
- (global $cttz_i8 (mut i32) (get_global $cttz_i8$asm2wasm$import))
(global $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
- (global $setjmpId (mut i32) (i32.const 0))
- (global $undef (mut i32) (i32.const 0))
- (global $nan (mut f64) (get_global $nan$asm2wasm$import))
- (global $inf (mut f64) (get_global $inf$asm2wasm$import))
- (global $tempInt (mut i32) (i32.const 0))
- (global $tempBigInt (mut i32) (i32.const 0))
- (global $tempBigIntP (mut i32) (i32.const 0))
- (global $tempBigIntS (mut i32) (i32.const 0))
- (global $tempBigIntR (mut f64) (f64.const 0))
- (global $tempBigIntI (mut i32) (i32.const 0))
- (global $tempBigIntD (mut i32) (i32.const 0))
- (global $tempValue (mut i32) (i32.const 0))
- (global $tempDouble (mut f64) (f64.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
- (global $tempRet1 (mut i32) (i32.const 0))
- (global $tempRet2 (mut i32) (i32.const 0))
- (global $tempRet3 (mut i32) (i32.const 0))
- (global $tempRet4 (mut i32) (i32.const 0))
- (global $tempRet5 (mut i32) (i32.const 0))
- (global $tempRet6 (mut i32) (i32.const 0))
- (global $tempRet7 (mut i32) (i32.const 0))
- (global $tempRet8 (mut i32) (i32.const 0))
- (global $tempRet9 (mut i32) (i32.const 0))
- (global $tempFloat (mut f64) (f64.const 0))
(export "_i64Subtract" (func $_i64Subtract))
(export "_free" (func $_free))
(export "_main" (func $_main))
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index 1de260b20..4eee5c0c0 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -1028,7 +1028,6 @@ optimized:
(type $v (func))
(type $vi (func (param i32)))
(type $i (func (result i32)))
- (import "module" "check" (func $check (param i32)))
(memory $0 0)
)
module loaded from binary form:
@@ -2886,7 +2885,6 @@ optimized:
(type $v (func))
(type $vi (func (param i32)))
(type $i (func (result i32)))
- (import "module" "check" (func $check (param i32)))
(memory $0 0)
)
BinaryenModuleDispose(the_module);
diff --git a/test/example/c-api-kitchen-sink.txt.txt b/test/example/c-api-kitchen-sink.txt.txt
index 16e4941d3..cbccff232 100644
--- a/test/example/c-api-kitchen-sink.txt.txt
+++ b/test/example/c-api-kitchen-sink.txt.txt
@@ -1021,6 +1021,5 @@
(type $v (func))
(type $vi (func (param i32)))
(type $i (func (result i32)))
- (import "module" "check" (func $check (param i32)))
(memory $0 0)
)
diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm
index e9098be75..cfe303d34 100644
--- a/test/memorygrowth.fromasm
+++ b/test/memorygrowth.fromasm
@@ -7,10 +7,6 @@
(type $FUNCSIG$vii (func (param i32 i32)))
(import "env" "STACKTOP" (global $r$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $s$asm2wasm$import i32))
- (import "env" "tempDoublePtr" (global $t$asm2wasm$import i32))
- (import "env" "ABORT" (global $u$asm2wasm$import i32))
- (import "global" "NaN" (global $z$asm2wasm$import f64))
- (import "global" "Infinity" (global $A$asm2wasm$import f64))
(import "env" "abort" (func $ja (param i32)))
(import "env" "_pthread_cleanup_pop" (func $oa (param i32)))
(import "env" "___lock" (func $pa (param i32)))
@@ -32,34 +28,9 @@
(data (get_global $memoryBase) "memorygrowth.asm.js")
(global $r (mut i32) (get_global $r$asm2wasm$import))
(global $s (mut i32) (get_global $s$asm2wasm$import))
- (global $t (mut i32) (get_global $t$asm2wasm$import))
- (global $u (mut i32) (get_global $u$asm2wasm$import))
(global $v (mut i32) (i32.const 0))
(global $w (mut i32) (i32.const 0))
- (global $x (mut i32) (i32.const 0))
- (global $y (mut i32) (i32.const 0))
- (global $z (mut f64) (get_global $z$asm2wasm$import))
- (global $A (mut f64) (get_global $A$asm2wasm$import))
- (global $B (mut i32) (i32.const 0))
- (global $C (mut i32) (i32.const 0))
- (global $D (mut i32) (i32.const 0))
- (global $E (mut i32) (i32.const 0))
- (global $F (mut f64) (f64.const 0))
- (global $G (mut i32) (i32.const 0))
- (global $H (mut i32) (i32.const 0))
- (global $I (mut i32) (i32.const 0))
- (global $J (mut f64) (f64.const 0))
(global $K (mut i32) (i32.const 0))
- (global $L (mut i32) (i32.const 0))
- (global $M (mut i32) (i32.const 0))
- (global $N (mut i32) (i32.const 0))
- (global $O (mut i32) (i32.const 0))
- (global $P (mut i32) (i32.const 0))
- (global $Q (mut i32) (i32.const 0))
- (global $R (mut i32) (i32.const 0))
- (global $S (mut i32) (i32.const 0))
- (global $T (mut i32) (i32.const 0))
- (global $za (mut f64) (f64.const 0))
(export "_free" (func $fb))
(export "_main" (func $Na))
(export "_pthread_self" (func $ib))
diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise
index 0cd953b5b..c1f308b20 100644
--- a/test/memorygrowth.fromasm.imprecise
+++ b/test/memorygrowth.fromasm.imprecise
@@ -7,10 +7,6 @@
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(import "env" "STACKTOP" (global $r$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $s$asm2wasm$import i32))
- (import "env" "tempDoublePtr" (global $t$asm2wasm$import i32))
- (import "env" "ABORT" (global $u$asm2wasm$import i32))
- (import "global" "NaN" (global $z$asm2wasm$import f64))
- (import "global" "Infinity" (global $A$asm2wasm$import f64))
(import "env" "abort" (func $ja (param i32)))
(import "env" "_pthread_cleanup_pop" (func $oa (param i32)))
(import "env" "___lock" (func $pa (param i32)))
@@ -30,34 +26,9 @@
(elem (get_global $tableBase) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(global $r (mut i32) (get_global $r$asm2wasm$import))
(global $s (mut i32) (get_global $s$asm2wasm$import))
- (global $t (mut i32) (get_global $t$asm2wasm$import))
- (global $u (mut i32) (get_global $u$asm2wasm$import))
(global $v (mut i32) (i32.const 0))
(global $w (mut i32) (i32.const 0))
- (global $x (mut i32) (i32.const 0))
- (global $y (mut i32) (i32.const 0))
- (global $z (mut f64) (get_global $z$asm2wasm$import))
- (global $A (mut f64) (get_global $A$asm2wasm$import))
- (global $B (mut i32) (i32.const 0))
- (global $C (mut i32) (i32.const 0))
- (global $D (mut i32) (i32.const 0))
- (global $E (mut i32) (i32.const 0))
- (global $F (mut f64) (f64.const 0))
- (global $G (mut i32) (i32.const 0))
- (global $H (mut i32) (i32.const 0))
- (global $I (mut i32) (i32.const 0))
- (global $J (mut f64) (f64.const 0))
(global $K (mut i32) (i32.const 0))
- (global $L (mut i32) (i32.const 0))
- (global $M (mut i32) (i32.const 0))
- (global $N (mut i32) (i32.const 0))
- (global $O (mut i32) (i32.const 0))
- (global $P (mut i32) (i32.const 0))
- (global $Q (mut i32) (i32.const 0))
- (global $R (mut i32) (i32.const 0))
- (global $S (mut i32) (i32.const 0))
- (global $T (mut i32) (i32.const 0))
- (global $za (mut f64) (f64.const 0))
(export "_free" (func $fb))
(export "_main" (func $Na))
(export "_pthread_self" (func $ib))
diff --git a/test/min.fromasm b/test/min.fromasm
index c54c786a6..76d071ef6 100644
--- a/test/min.fromasm
+++ b/test/min.fromasm
@@ -1,11 +1,9 @@
(module
- (import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32))
(import "env" "memory" (memory $0 256 256))
(import "env" "table" (table 0 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(data (get_global $memoryBase) "min.asm.js")
- (global $tDP (mut i32) (get_global $tDP$asm2wasm$import))
(global $M (mut i32) (i32.const 0))
(export "floats" (func $floats))
(export "getTempRet0" (func $ub))
diff --git a/test/min.fromasm.imprecise b/test/min.fromasm.imprecise
index d2a09dd4e..9b63300b5 100644
--- a/test/min.fromasm.imprecise
+++ b/test/min.fromasm.imprecise
@@ -1,10 +1,8 @@
(module
- (import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32))
(import "env" "memory" (memory $0 256 256))
(import "env" "table" (table 0 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (global $tDP (mut i32) (get_global $tDP$asm2wasm$import))
(global $M (mut i32) (i32.const 0))
(export "floats" (func $floats))
(export "getTempRet0" (func $ub))
diff --git a/test/passes/remove-unused-functions.txt b/test/passes/remove-unused-functions.txt
deleted file mode 100644
index 6e4a452b3..000000000
--- a/test/passes/remove-unused-functions.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-(module
- (type $0 (func))
- (table 1 1 anyfunc)
- (elem (i32.const 0) $called_indirect)
- (memory $0 0)
- (export "memory" (memory $0))
- (export "exported" (func $exported))
- (start $start)
- (func $start (type $0)
- (call $called0)
- )
- (func $called0 (type $0)
- (call $called1)
- )
- (func $called1 (type $0)
- (nop)
- )
- (func $called_indirect (type $0)
- (nop)
- )
- (func $exported (type $0)
- (call $called2)
- )
- (func $called2 (type $0)
- (call $called2)
- (call $called3)
- )
- (func $called3 (type $0)
- (call $called4)
- )
- (func $called4 (type $0)
- (call $called3)
- )
-)
diff --git a/test/passes/remove-unused-functions.wast b/test/passes/remove-unused-functions.wast
deleted file mode 100644
index c3d25d021..000000000
--- a/test/passes/remove-unused-functions.wast
+++ /dev/null
@@ -1,49 +0,0 @@
-(module
- (memory 0)
- (start $start)
- (type $0 (func))
- (export "memory" (memory $0))
- (export "exported" $exported)
- (table 1 1 anyfunc)
- (elem (i32.const 0) $called_indirect)
- (func $start (type $0)
- (call $called0)
- )
- (func $called0 (type $0)
- (call $called1)
- )
- (func $called1 (type $0)
- (nop)
- )
- (func $called_indirect (type $0)
- (nop)
- )
- (func $exported (type $0)
- (call $called2)
- )
- (func $called2 (type $0)
- (call $called2)
- (call $called3)
- )
- (func $called3 (type $0)
- (call $called4)
- )
- (func $called4 (type $0)
- (call $called3)
- )
- (func $remove0 (type $0)
- (call $remove1)
- )
- (func $remove1 (type $0)
- (nop)
- )
- (func $remove2 (type $0)
- (call $remove2)
- )
- (func $remove3 (type $0)
- (call $remove4)
- )
- (func $remove4 (type $0)
- (call $remove3)
- )
-)
diff --git a/test/passes/remove-unused-module-elements.txt b/test/passes/remove-unused-module-elements.txt
new file mode 100644
index 000000000..8b8fd3601
--- /dev/null
+++ b/test/passes/remove-unused-module-elements.txt
@@ -0,0 +1,87 @@
+(module
+ (type $0 (func))
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $called_indirect)
+ (memory $0 0)
+ (export "memory" (memory $0))
+ (export "exported" (func $exported))
+ (start $start)
+ (func $start (type $0)
+ (call $called0)
+ )
+ (func $called0 (type $0)
+ (call $called1)
+ )
+ (func $called1 (type $0)
+ (nop)
+ )
+ (func $called_indirect (type $0)
+ (nop)
+ )
+ (func $exported (type $0)
+ (call $called2)
+ )
+ (func $called2 (type $0)
+ (call $called2)
+ (call $called3)
+ )
+ (func $called3 (type $0)
+ (call $called4)
+ )
+ (func $called4 (type $0)
+ (call $called3)
+ )
+)
+(module
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+)
+(module
+ (type $0 (func))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (elem (get_global $tableBase) $waka)
+ (data (get_global $memoryBase) "hello, world!")
+ (func $waka (type $0)
+ (nop)
+ )
+)
+(module
+ (type $FUNCSIG$ii (func (param i32) (result i32)))
+ (type $1 (func (result i32)))
+ (type $2 (func))
+ (import "env" "imported" (global $imported i32))
+ (import "env" "_puts" (func $_puts (param i32) (result i32)))
+ (memory $0 0)
+ (global $int (mut i32) (get_global $imported))
+ (global $set (mut i32) (i32.const 100))
+ (global $exp_glob i32 (i32.const 600))
+ (export "one" (func $one))
+ (export "three" (func $three))
+ (export "exp_glob" (global $exp_glob))
+ (start $starter)
+ (func $one (type $1) (result i32)
+ (call $two)
+ )
+ (func $two (type $1) (result i32)
+ (get_global $int)
+ )
+ (func $three (type $2)
+ (call $four)
+ )
+ (func $four (type $2)
+ (set_global $set
+ (i32.const 200)
+ )
+ (drop
+ (call $_puts
+ (i32.const 300)
+ )
+ )
+ )
+ (func $starter (type $2)
+ (nop)
+ )
+)
diff --git a/test/passes/remove-unused-module-elements.wast b/test/passes/remove-unused-module-elements.wast
new file mode 100644
index 000000000..eb071ee66
--- /dev/null
+++ b/test/passes/remove-unused-module-elements.wast
@@ -0,0 +1,96 @@
+(module
+ (memory 0)
+ (start $start)
+ (type $0 (func))
+ (export "memory" (memory $0))
+ (export "exported" $exported)
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $called_indirect)
+ (func $start (type $0)
+ (call $called0)
+ )
+ (func $called0 (type $0)
+ (call $called1)
+ )
+ (func $called1 (type $0)
+ (nop)
+ )
+ (func $called_indirect (type $0)
+ (nop)
+ )
+ (func $exported (type $0)
+ (call $called2)
+ )
+ (func $called2 (type $0)
+ (call $called2)
+ (call $called3)
+ )
+ (func $called3 (type $0)
+ (call $called4)
+ )
+ (func $called4 (type $0)
+ (call $called3)
+ )
+ (func $remove0 (type $0)
+ (call $remove1)
+ )
+ (func $remove1 (type $0)
+ (nop)
+ )
+ (func $remove2 (type $0)
+ (call $remove2)
+ )
+ (func $remove3 (type $0)
+ (call $remove4)
+ )
+ (func $remove4 (type $0)
+ (call $remove3)
+ )
+)
+(module ;; leave the table and memory alone
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+)
+(module
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase i32)) ;; used in init
+ (import "env" "tableBase" (global $tableBase i32)) ;; used in init
+ (data (get_global $memoryBase) "hello, world!")
+ (elem (get_global $tableBase) $waka)
+ (func $waka) ;; used in table
+)
+(module ;; one is exported, and one->two->int global, whose init->imported
+ (import "env" "imported" (global $imported i32))
+ (import "env" "forgetme" (global $forgetme i32))
+ (import "env" "_puts" (func $_puts (param i32) (result i32)))
+ (import "env" "forget_puts" (func $forget_puts (param i32) (result i32)))
+ (global $int (mut i32) (get_global $imported))
+ (global $set (mut i32) (i32.const 100))
+ (global $forget_global (mut i32) (i32.const 500))
+ (global $exp_glob i32 (i32.const 600))
+ (export "one" (func $one))
+ (export "three" (func $three))
+ (export "exp_glob" (global $exp_glob))
+ (start $starter)
+ (func $one (result i32)
+ (call $two)
+ )
+ (func $two (result i32)
+ (get_global $int)
+ )
+ (func $three
+ (call $four)
+ )
+ (func $four
+ (set_global $set (i32.const 200))
+ (drop (call $_puts (i32.const 300)))
+ )
+ (func $forget_implemented
+ (nop)
+ )
+ (func $starter
+ (nop)
+ )
+)
+
diff --git a/test/unit.fromasm b/test/unit.fromasm
index 04ea35b7f..fcddb0b4b 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -7,11 +7,7 @@
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$dd (func (param f64) (result f64)))
(type $FUNCSIG$i (func (result i32)))
- (import "global" "NaN" (global $t$asm2wasm$import f64))
- (import "global" "Infinity" (global $u$asm2wasm$import f64))
- (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
(import "env" "gb" (global $n$asm2wasm$import i32))
- (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "setTempRet0" (func $setTempRet0 (param i32) (result i32)))
(import "env" "abort" (func $abort (param f64) (result f64)))
(import "env" "print" (func $print (param i32)))
@@ -26,13 +22,9 @@
(import "env" "tableBase" (global $tableBase i32))
(elem (get_global $tableBase) $big_negative $big_negative $big_negative $big_negative $w $w $importedDoubles $w $fr $cneg $fr $fr $fr $fr $fr $fr $vi $vi $vi $vi $vi $vi $vi $vi)
(data (get_global $memoryBase) "unit.asm.js")
- (global $t (mut f64) (get_global $t$asm2wasm$import))
- (global $u (mut f64) (get_global $u$asm2wasm$import))
(global $Int (mut i32) (i32.const 0))
(global $Double (mut f64) (f64.const 0))
- (global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
(global $n (mut i32) (get_global $n$asm2wasm$import))
- (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(export "big_negative" (func $big_negative))
(export "pick" (func $big_negative))
(export "doubleCompares" (func $doubleCompares))
diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise
index f5a96144f..94f34c03d 100644
--- a/test/unit.fromasm.imprecise
+++ b/test/unit.fromasm.imprecise
@@ -5,11 +5,7 @@
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$dd (func (param f64) (result f64)))
(type $FUNCSIG$i (func (result i32)))
- (import "global" "NaN" (global $t$asm2wasm$import f64))
- (import "global" "Infinity" (global $u$asm2wasm$import f64))
- (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
(import "env" "gb" (global $n$asm2wasm$import i32))
- (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "setTempRet0" (func $setTempRet0 (param i32) (result i32)))
(import "env" "abort" (func $abort (param f64) (result f64)))
(import "env" "print" (func $print (param i32)))
@@ -21,13 +17,9 @@
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(elem (get_global $tableBase) $big_negative $big_negative $big_negative $big_negative $w $w $importedDoubles $w $fr $cneg $fr $fr $fr $fr $fr $fr $vi $vi $vi $vi $vi $vi $vi $vi)
- (global $t (mut f64) (get_global $t$asm2wasm$import))
- (global $u (mut f64) (get_global $u$asm2wasm$import))
(global $Int (mut i32) (i32.const 0))
(global $Double (mut f64) (f64.const 0))
- (global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
(global $n (mut i32) (get_global $n$asm2wasm$import))
- (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(export "big_negative" (func $big_negative))
(export "pick" (func $big_negative))
(export "doubleCompares" (func $doubleCompares))
diff --git a/test/wasm-only.fromasm b/test/wasm-only.fromasm
index adcc66137..1c5030527 100644
--- a/test/wasm-only.fromasm
+++ b/test/wasm-only.fromasm
@@ -12,6 +12,7 @@
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(data (get_global $memoryBase) "wasm-only.asm.js")
+ (global $tempRet0 (mut i32) (i32.const 0))
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$result))
@@ -397,7 +398,14 @@
(set_local $0
(call $result)
)
- (unreachable)
+ (set_global $tempRet0
+ (i32.wrap/i64
+ (i64.shr_u
+ (get_local $0)
+ (i64.const 32)
+ )
+ )
+ )
(i32.wrap/i64
(get_local $0)
)
@@ -424,7 +432,7 @@
)
(i64.shl
(i64.extend_u/i32
- (unreachable)
+ (get_global $tempRet0)
)
(i64.const 32)
)
diff --git a/test/wasm-only.fromasm.imprecise b/test/wasm-only.fromasm.imprecise
index def563598..4b129cdbe 100644
--- a/test/wasm-only.fromasm.imprecise
+++ b/test/wasm-only.fromasm.imprecise
@@ -11,6 +11,7 @@
(import "env" "table" (table 0 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
+ (global $tempRet0 (mut i32) (i32.const 0))
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$result))
@@ -325,7 +326,14 @@
(set_local $0
(call $result)
)
- (unreachable)
+ (set_global $tempRet0
+ (i32.wrap/i64
+ (i64.shr_u
+ (get_local $0)
+ (i64.const 32)
+ )
+ )
+ )
(i32.wrap/i64
(get_local $0)
)
@@ -352,7 +360,7 @@
)
(i64.shl
(i64.extend_u/i32
- (unreachable)
+ (get_global $tempRet0)
)
(i64.const 32)
)
diff --git a/test/wasm-only.fromasm.imprecise.no-opts b/test/wasm-only.fromasm.imprecise.no-opts
index 1e818877c..9830e9b2c 100644
--- a/test/wasm-only.fromasm.imprecise.no-opts
+++ b/test/wasm-only.fromasm.imprecise.no-opts
@@ -11,6 +11,7 @@
(import "env" "table" (table 0 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
+ (global $tempRet0 (mut i32) (i32.const 0))
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$illegalResult))
@@ -775,7 +776,14 @@
(set_local $0
(call $illegalResult)
)
- (unreachable)
+ (set_global $tempRet0
+ (i32.wrap/i64
+ (i64.shr_u
+ (get_local $0)
+ (i64.const 32)
+ )
+ )
+ )
(i32.wrap/i64
(get_local $0)
)
@@ -802,7 +810,7 @@
)
(i64.shl
(i64.extend_u/i32
- (unreachable)
+ (get_global $tempRet0)
)
(i64.const 32)
)
diff --git a/test/wasm-only.fromasm.no-opts b/test/wasm-only.fromasm.no-opts
index 1c3a0bf5c..9ecc9a1df 100644
--- a/test/wasm-only.fromasm.no-opts
+++ b/test/wasm-only.fromasm.no-opts
@@ -11,6 +11,7 @@
(import "env" "table" (table 0 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
+ (global $tempRet0 (mut i32) (i32.const 0))
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$illegalResult))
@@ -823,7 +824,14 @@
(set_local $0
(call $illegalResult)
)
- (unreachable)
+ (set_global $tempRet0
+ (i32.wrap/i64
+ (i64.shr_u
+ (get_local $0)
+ (i64.const 32)
+ )
+ )
+ )
(i32.wrap/i64
(get_local $0)
)
@@ -850,7 +858,7 @@
)
(i64.shl
(i64.extend_u/i32
- (unreachable)
+ (get_global $tempRet0)
)
(i64.const 32)
)