diff options
Diffstat (limited to 'test/passes')
-rw-r--r-- | test/passes/remove-unused-functions.txt | 34 | ||||
-rw-r--r-- | test/passes/remove-unused-functions.wast | 49 | ||||
-rw-r--r-- | test/passes/remove-unused-module-elements.txt | 87 | ||||
-rw-r--r-- | test/passes/remove-unused-module-elements.wast | 96 |
4 files changed, 183 insertions, 83 deletions
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) + ) +) + |