diff options
Diffstat (limited to 'test/lit/passes')
-rw-r--r-- | test/lit/passes/generate-dyncalls_all-features.wast | 3 | ||||
-rw-r--r-- | test/lit/passes/gufa.wast | 23 | ||||
-rw-r--r-- | test/lit/passes/inlining-optimizing_optimize-level=3.wast | 52 | ||||
-rw-r--r-- | test/lit/passes/jspi-args.wast | 8 | ||||
-rw-r--r-- | test/lit/passes/jspi-table.wast | 3 | ||||
-rw-r--r-- | test/lit/passes/jspi.wast | 32 | ||||
-rw-r--r-- | test/lit/passes/legalize-js-interface-exported-helpers.wast | 9 | ||||
-rw-r--r-- | test/lit/passes/legalize-js-interface-minimally.wast | 6 | ||||
-rw-r--r-- | test/lit/passes/legalize-js-interface_all-features.wast | 21 | ||||
-rw-r--r-- | test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast | 4 | ||||
-rw-r--r-- | test/lit/passes/remove-unused-module-elements-refs.wast | 40 | ||||
-rw-r--r-- | test/lit/passes/remove-unused-module-elements_all-features.wast | 53 |
12 files changed, 154 insertions, 100 deletions
diff --git a/test/lit/passes/generate-dyncalls_all-features.wast b/test/lit/passes/generate-dyncalls_all-features.wast index 34c387b08..99611727b 100644 --- a/test/lit/passes/generate-dyncalls_all-features.wast +++ b/test/lit/passes/generate-dyncalls_all-features.wast @@ -73,8 +73,9 @@ ;; CHECK: (type $3 (func (param i32 i32))) ;; CHECK: (import "env" "table" (table $timport$0 1 1 funcref)) - (import "env" "invoke_vii" (func $invoke_vii (param i32 i32 i32))) + ;; CHECK: (import "env" "invoke_vii" (func $invoke_vii (type $0) (param i32 i32 i32))) + (import "env" "invoke_vii" (func $invoke_vii (param i32 i32 i32))) (import "env" "table" (table 1 1 funcref)) (elem (i32.const 0) $f) ;; CHECK: (elem $0 (i32.const 0) $f) diff --git a/test/lit/passes/gufa.wast b/test/lit/passes/gufa.wast index 58166cd46..b97e620ab 100644 --- a/test/lit/passes/gufa.wast +++ b/test/lit/passes/gufa.wast @@ -583,6 +583,8 @@ (ref.func $reffed) ) + (export "table" (table 0)) + ;; CHECK: (type $1 (func)) ;; CHECK: (table $0 10 funcref) @@ -590,7 +592,6 @@ ;; CHECK: (elem $0 (i32.const 0) $reffed) ;; CHECK: (export "table" (table $0)) - (export "table" (table 0)) ;; CHECK: (func $reffed (type $i) (param $x i32) ;; CHECK-NEXT: (drop @@ -924,6 +925,12 @@ ;; CHECK: (type $A (func (param i32))) (type $A (func (param i32))) + (import "binaryen-intrinsics" "call.without.effects" + (func $call-without-effects (param i32 funcref))) + + (import "other" "import" + (func $other-import (param funcref))) + ;; CHECK: (type $1 (func (param i32 funcref))) ;; CHECK: (type $2 (func (param funcref))) @@ -931,12 +938,8 @@ ;; CHECK: (type $3 (func)) ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param i32 funcref))) - (import "binaryen-intrinsics" "call.without.effects" - (func $call-without-effects (param i32 funcref))) ;; CHECK: (import "other" "import" (func $other-import (type $2) (param funcref))) - (import "other" "import" - (func $other-import (param funcref))) ;; CHECK: (elem declare func $target-drop $target-keep) @@ -994,6 +997,12 @@ ;; CHECK: (type $A (func (param i32))) (type $A (func (param i32))) + (import "binaryen-intrinsics" "call.without.effects" + (func $call-without-effects (param i32 funcref))) + + (import "other" "import" + (func $other-import (param funcref))) + ;; CHECK: (type $1 (func (param i32 funcref))) ;; CHECK: (type $2 (func (param funcref))) @@ -1001,12 +1010,8 @@ ;; CHECK: (type $3 (func (param (ref null $A)))) ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param i32 funcref))) - (import "binaryen-intrinsics" "call.without.effects" - (func $call-without-effects (param i32 funcref))) ;; CHECK: (import "other" "import" (func $other-import (type $2) (param funcref))) - (import "other" "import" - (func $other-import (param funcref))) ;; CHECK: (elem declare func $target-keep $target-keep-2) diff --git a/test/lit/passes/inlining-optimizing_optimize-level=3.wast b/test/lit/passes/inlining-optimizing_optimize-level=3.wast index dfdbed533..a0e320bd6 100644 --- a/test/lit/passes/inlining-optimizing_optimize-level=3.wast +++ b/test/lit/passes/inlining-optimizing_optimize-level=3.wast @@ -33,54 +33,58 @@ ;; CHECK: (type $11 (func (param i32 i32 i32 i32 i32))) ;; CHECK: (import "env" "memory" (memory $0 256 256)) - (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) + ;; CHECK: (import "env" "table" (table $timport$0 18 18 funcref)) - (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) + ;; CHECK: (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) - (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32)) + (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) ;; CHECK: (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) - (import "env" "abort" (func $abort)) + (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) ;; CHECK: (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32)) - (import "env" "nullFunc_ii" (func $nullFunc_ii (param i32))) + (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32)) ;; CHECK: (import "env" "memoryBase" (global $memoryBase i32)) - (import "env" "nullFunc_iiii" (func $nullFunc_iiii (param i32))) + ;; CHECK: (import "env" "tableBase" (global $tableBase i32)) - (import "env" "nullFunc_vi" (func $nullFunc_vi (param i32))) + ;; CHECK: (import "env" "abort" (func $abort)) - (import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32))) + (import "env" "abort" (func $abort)) ;; CHECK: (import "env" "nullFunc_ii" (func $nullFunc_ii (param i32))) - (import "env" "___lock" (func $___lock (param i32))) + (import "env" "nullFunc_ii" (func $nullFunc_ii (param i32))) ;; CHECK: (import "env" "nullFunc_iiii" (func $nullFunc_iiii (param i32))) - (import "env" "_pthread_self" (func $_pthread_self (result i32))) + (import "env" "nullFunc_iiii" (func $nullFunc_iiii (param i32))) ;; CHECK: (import "env" "nullFunc_vi" (func $nullFunc_vi (param i32))) - (import "env" "_abort" (func $_abort)) + (import "env" "nullFunc_vi" (func $nullFunc_vi (param i32))) ;; CHECK: (import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32))) - (import "env" "___syscall6" (func $___syscall6 (param i32 i32) (result i32))) + (import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32))) ;; CHECK: (import "env" "___lock" (func $___lock (param i32))) - (import "env" "_sbrk" (func $_sbrk (param i32) (result i32))) + (import "env" "___lock" (func $___lock (param i32))) ;; CHECK: (import "env" "_pthread_self" (func $_pthread_self (result i32))) - (import "env" "_time" (func $_time (param i32) (result i32))) + (import "env" "_pthread_self" (func $_pthread_self (result i32))) ;; CHECK: (import "env" "_abort" (func $_abort)) - (import "env" "_emscripten_memcpy_big" (func $_emscripten_memcpy_big (param i32 i32 i32) (result i32))) + (import "env" "_abort" (func $_abort)) ;; CHECK: (import "env" "___syscall6" (func $___syscall6 (param i32 i32) (result i32))) - (import "env" "___syscall54" (func $___syscall54 (param i32 i32) (result i32))) + (import "env" "___syscall6" (func $___syscall6 (param i32 i32) (result i32))) ;; CHECK: (import "env" "_sbrk" (func $_sbrk (param i32) (result i32))) - (import "env" "___unlock" (func $___unlock (param i32))) + (import "env" "_sbrk" (func $_sbrk (param i32) (result i32))) ;; CHECK: (import "env" "_time" (func $_time (param i32) (result i32))) - (import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32))) + (import "env" "_time" (func $_time (param i32) (result i32))) ;; CHECK: (import "env" "_emscripten_memcpy_big" (func $_emscripten_memcpy_big (param i32 i32 i32) (result i32))) - (import "env" "_pthread_cleanup_push" (func $_pthread_cleanup_push (param i32 i32))) + (import "env" "_emscripten_memcpy_big" (func $_emscripten_memcpy_big (param i32 i32 i32) (result i32))) ;; CHECK: (import "env" "___syscall54" (func $___syscall54 (param i32 i32) (result i32))) - (import "env" "_sysconf" (func $_sysconf (param i32) (result i32))) + (import "env" "___syscall54" (func $___syscall54 (param i32 i32) (result i32))) ;; CHECK: (import "env" "___unlock" (func $___unlock (param i32))) - (import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32))) + (import "env" "___unlock" (func $___unlock (param i32))) ;; CHECK: (import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32))) - (import "env" "memory" (memory $0 256 256)) + (import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32))) ;; CHECK: (import "env" "_pthread_cleanup_push" (func $_pthread_cleanup_push (param i32 i32))) - (import "env" "table" (table 18 18 funcref)) + (import "env" "_pthread_cleanup_push" (func $_pthread_cleanup_push (param i32 i32))) ;; CHECK: (import "env" "_sysconf" (func $_sysconf (param i32) (result i32))) - (import "env" "memoryBase" (global $memoryBase i32)) + (import "env" "_sysconf" (func $_sysconf (param i32) (result i32))) ;; CHECK: (import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32))) + (import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32))) + (import "env" "memory" (memory $0 256 256)) + (import "env" "table" (table 18 18 funcref)) + (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) ;; CHECK: (global $STACKTOP (mut i32) (global.get $STACKTOP$asm2wasm$import)) (global $STACKTOP (mut i32) (global.get $STACKTOP$asm2wasm$import)) diff --git a/test/lit/passes/jspi-args.wast b/test/lit/passes/jspi-args.wast index 1a23c1716..8229e34e9 100644 --- a/test/lit/passes/jspi-args.wast +++ b/test/lit/passes/jspi-args.wast @@ -3,18 +3,20 @@ (module ;; sleep_async should have a wrapper function built. + (import "js" "sleep_async" (func $sleep_async (param f64) (result i32))) ;; CHECK: (type $0 (func (param f64) (result i32))) ;; CHECK: (type $1 (func (param externref f64) (result i32))) ;; CHECK: (import "js" "sleep_sync" (func $sleep_sync (type $0) (param f64) (result i32))) - (import "js" "sleep_async" (func $sleep_async (param f64) (result i32))) - ;; CHECK: (import "js" "sleep_async" (func $import$sleep_async (type $1) (param externref f64) (result i32))) (import "js" "sleep_sync" (func $sleep_sync (param f64) (result i32))) + (export "update_state_async" (func $update_state_async)) + ;; CHECK: (import "js" "sleep_async" (func $import$sleep_async (type $1) (param externref f64) (result i32))) + ;; CHECK: (global $suspender (mut externref) (ref.null noextern)) ;; CHECK: (export "update_state_async" (func $export$update_state_async)) - (export "update_state_async" (func $update_state_async)) + ;; CHECK: (export "update_state_sync" (func $update_state_sync)) (export "update_state_sync" (func $update_state_sync)) ;; This function calls an async sleep so a wrapper should be created for it. diff --git a/test/lit/passes/jspi-table.wast b/test/lit/passes/jspi-table.wast index 526b0a4b7..c702357c0 100644 --- a/test/lit/passes/jspi-table.wast +++ b/test/lit/passes/jspi-table.wast @@ -12,10 +12,11 @@ ;; CHECK: (table $0 1 1 funcref) (table $0 1 1 funcref) (elem (i32.const 1) func $update_state) + (export "update_state" (func $update_state)) + ;; CHECK: (elem $0 (i32.const 1) $export$update_state) ;; CHECK: (export "update_state" (func $export$update_state)) - (export "update_state" (func $update_state)) ;; CHECK: (func $update_state (type $0) (param $param f64) (result i32) ;; CHECK-NEXT: (i32.const 42) diff --git a/test/lit/passes/jspi.wast b/test/lit/passes/jspi.wast index 780a54ccb..12396cc6d 100644 --- a/test/lit/passes/jspi.wast +++ b/test/lit/passes/jspi.wast @@ -4,6 +4,19 @@ (module + (import "js" "compute_delta" (func $compute_delta (param f64) (result i32))) + (import "js" "import_and_export" (func $import_and_export (param i32) (result i32))) + (import "js" "import_void_return" (func $import_void_return (param i32))) + (export "update_state_void" (func $update_state_void)) + (export "update_state" (func $update_state)) + ;; Test duplicating an export. + (export "update_state_again" (func $update_state)) + ;; Test that a name collision on the parameters is handled. + (export "update_state_param_collision" (func $update_state_param_collision)) + ;; Test function that is imported and exported. + (export "import_and_export" (func $import_and_export)) + + ;; CHECK: (type $0 (func (param externref f64) (result i32))) ;; CHECK: (type $1 (func (param f64) (result i32))) @@ -19,27 +32,22 @@ ;; CHECK: (type $6 (func (param externref i32))) ;; CHECK: (import "js" "compute_delta" (func $import$compute_delta (type $0) (param externref f64) (result i32))) - (import "js" "compute_delta" (func $compute_delta (param f64) (result i32))) + ;; CHECK: (import "js" "import_and_export" (func $import$import_and_export (type $2) (param externref i32) (result i32))) - (import "js" "import_and_export" (func $import_and_export (param i32) (result i32))) + ;; CHECK: (import "js" "import_void_return" (func $import$import_void_return (type $6) (param externref i32))) - (import "js" "import_void_return" (func $import_void_return (param i32))) + ;; CHECK: (global $suspender (mut externref) (ref.null noextern)) ;; CHECK: (export "update_state_void" (func $export$update_state_void)) - (export "update_state_void" (func $update_state_void)) + ;; CHECK: (export "update_state" (func $export$update_state)) - (export "update_state" (func $update_state)) - ;; Test duplicating an export. + ;; CHECK: (export "update_state_again" (func $export$update_state)) - (export "update_state_again" (func $update_state)) - ;; Test that a name collision on the parameters is handled. + ;; CHECK: (export "update_state_param_collision" (func $export$update_state_param_collision)) - (export "update_state_param_collision" (func $update_state_param_collision)) - ;; Test function that is imported and exported. - ;; CHECK: (export "import_and_export" (func $export$import_and_export)) - (export "import_and_export" (func $import_and_export)) + ;; CHECK: (export "import_and_export" (func $export$import_and_export)) ;; CHECK: (func $update_state (type $1) (param $param f64) (result i32) ;; CHECK-NEXT: (call $compute_delta diff --git a/test/lit/passes/legalize-js-interface-exported-helpers.wast b/test/lit/passes/legalize-js-interface-exported-helpers.wast index 35271ee84..707cbe5c9 100644 --- a/test/lit/passes/legalize-js-interface-exported-helpers.wast +++ b/test/lit/passes/legalize-js-interface-exported-helpers.wast @@ -6,6 +6,10 @@ ;; RUN: wasm-opt %s --legalize-js-interface --pass-arg=legalize-js-interface-exported-helpers -S -o - | filecheck %s (module + (export "get_i64" (func $get_i64)) + (import "env" "imported" (func $imported (result i64))) + (export "__set_temp_ret" (func $__set_temp_ret)) + (export "__get_temp_ret" (func $__get_temp_ret)) ;; CHECK: (type $0 (func (result i32))) ;; CHECK: (type $1 (func (result i64))) @@ -15,10 +19,7 @@ ;; CHECK: (import "env" "imported" (func $legalimport$imported (result i32))) ;; CHECK: (export "get_i64" (func $legalstub$get_i64)) - (export "get_i64" (func $get_i64)) - (import "env" "imported" (func $imported (result i64))) - (export "__set_temp_ret" (func $__set_temp_ret)) - (export "__get_temp_ret" (func $__get_temp_ret)) + ;; CHECK: (func $get_i64 (result i64) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $legalfunc$imported) diff --git a/test/lit/passes/legalize-js-interface-minimally.wast b/test/lit/passes/legalize-js-interface-minimally.wast index 76bed505c..664b024b3 100644 --- a/test/lit/passes/legalize-js-interface-minimally.wast +++ b/test/lit/passes/legalize-js-interface-minimally.wast @@ -16,14 +16,16 @@ ;; CHECK: (import "env" "imported" (func $imported (result i64))) (import "env" "imported" (func $imported (result i64))) - ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (param i32))) (import "env" "invoke_vj" (func $invoke_vj (param i64))) + ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (param i32))) + ;; CHECK: (import "env" "invoke_vj" (func $legalimport$invoke_vj (param i32 i32))) ;; CHECK: (export "func" (func $func)) (export "func" (func $func)) - ;; CHECK: (export "dynCall_foo" (func $legalstub$dyn)) (export "dynCall_foo" (func $dyn)) + ;; CHECK: (export "dynCall_foo" (func $legalstub$dyn)) + ;; CHECK: (func $func (result i64) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $imported) diff --git a/test/lit/passes/legalize-js-interface_all-features.wast b/test/lit/passes/legalize-js-interface_all-features.wast index 6afd2bc20..611a58da7 100644 --- a/test/lit/passes/legalize-js-interface_all-features.wast +++ b/test/lit/passes/legalize-js-interface_all-features.wast @@ -4,6 +4,10 @@ ;; RUN: foreach %s %t wasm-opt --legalize-js-interface --all-features -S -o - | filecheck %s (module + (import "env" "imported" (func $imported (result i64))) + (import "env" "other" (func $other (param i32) (param i64) (param i64))) + (import "env" "ref-func-arg" (func $ref-func-arg (result i64))) + (export "func" (func $func)) ;; CHECK: (type $0 (func (result i32))) ;; CHECK: (type $1 (func (result i64))) @@ -17,11 +21,11 @@ ;; CHECK: (type $5 (func (param i32 i64 i64))) ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (type $4) (param i32))) - (import "env" "imported" (func $imported (result i64))) + ;; CHECK: (import "env" "getTempRet0" (func $getTempRet0 (type $0) (result i32))) - (import "env" "other" (func $other (param i32) (param i64) (param i64))) + ;; CHECK: (import "env" "imported" (func $legalimport$imported (type $0) (result i32))) - (import "env" "ref-func-arg" (func $ref-func-arg (result i64))) + ;; CHECK: (import "env" "other" (func $legalimport$other (type $2) (param i32 i32 i32 i32 i32))) ;; CHECK: (import "env" "ref-func-arg" (func $legalimport$ref-func-arg (type $0) (result i32))) @@ -29,15 +33,18 @@ ;; CHECK: (elem declare func $legalfunc$ref-func-arg) ;; CHECK: (export "func" (func $legalstub$func)) - (export "func" (func $func)) + ;; CHECK: (export "ref-func-test" (func $ref-func-test)) (export "ref-func-test" (func $ref-func-test)) - ;; CHECK: (export "imported" (func $legalstub$imported)) (export "imported" (func $imported)) - ;; CHECK: (export "imported_again" (func $legalstub$imported)) (export "imported_again" (func $imported)) - ;; CHECK: (export "other" (func $legalstub$other)) (export "other" (func $other)) + ;; CHECK: (export "imported" (func $legalstub$imported)) + + ;; CHECK: (export "imported_again" (func $legalstub$imported)) + + ;; CHECK: (export "other" (func $legalstub$other)) + ;; CHECK: (func $func (type $1) (result i64) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $legalfunc$imported) diff --git a/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast b/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast index ba9db7ee5..f56db7982 100644 --- a/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast +++ b/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast @@ -13,9 +13,9 @@ ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (param i32))) ;; CHECK: (export "func" (func $legalstub$func)) - (export "func" (func $func)) - ;; CHECK: (export "orig$func" (func $func)) + ;; CHECK: (export "orig$func" (func $func)) + (export "func" (func $func)) ;; CHECK: (func $func (result i64) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/remove-unused-module-elements-refs.wast b/test/lit/passes/remove-unused-module-elements-refs.wast index 00ea9767f..44c87fefc 100644 --- a/test/lit/passes/remove-unused-module-elements-refs.wast +++ b/test/lit/passes/remove-unused-module-elements-refs.wast @@ -469,20 +469,18 @@ ;; OPEN_WORLD: (type $A (func)) (type $A (func)) - ;; CHECK: (type $1 (func (param funcref))) - - ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) - ;; OPEN_WORLD: (type $1 (func (param funcref))) - - ;; OPEN_WORLD: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (param funcref))) - ;; CHECK: (import "other" "import" (func $other-import (type $1) (param funcref))) - ;; OPEN_WORLD: (import "other" "import" (func $other-import (type $1) (param funcref))) (import "other" "import" (func $other-import (param funcref))) + ;; CHECK: (type $1 (func (param funcref))) + + ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) + + ;; CHECK: (import "other" "import" (func $other-import (type $1) (param funcref))) + ;; CHECK: (elem declare func $target-drop $target-keep) ;; CHECK: (export "foo" (func $foo)) @@ -495,6 +493,12 @@ ;; CHECK-NEXT: (ref.func $target-drop) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) + ;; OPEN_WORLD: (type $1 (func (param funcref))) + + ;; OPEN_WORLD: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) + + ;; OPEN_WORLD: (import "other" "import" (func $other-import (type $1) (param funcref))) + ;; OPEN_WORLD: (elem declare func $target-drop $target-keep) ;; OPEN_WORLD: (export "foo" (func $foo)) @@ -546,20 +550,18 @@ ;; OPEN_WORLD: (type $A (func)) (type $A (func)) - ;; CHECK: (type $1 (func (param funcref))) - - ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) - ;; OPEN_WORLD: (type $1 (func (param funcref))) - - ;; OPEN_WORLD: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (param funcref))) - ;; CHECK: (import "other" "import" (func $other-import (type $1) (param funcref))) - ;; OPEN_WORLD: (import "other" "import" (func $other-import (type $1) (param funcref))) (import "other" "import" (func $other-import (param funcref))) + ;; CHECK: (type $1 (func (param funcref))) + + ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) + + ;; CHECK: (import "other" "import" (func $other-import (type $1) (param funcref))) + ;; CHECK: (elem declare func $target-keep $target-keep-2) ;; CHECK: (export "foo" (func $foo)) @@ -576,6 +578,12 @@ ;; CHECK-NEXT: (ref.func $target-keep-2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) + ;; OPEN_WORLD: (type $1 (func (param funcref))) + + ;; OPEN_WORLD: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) + + ;; OPEN_WORLD: (import "other" "import" (func $other-import (type $1) (param funcref))) + ;; OPEN_WORLD: (elem declare func $target-keep $target-keep-2) ;; OPEN_WORLD: (export "foo" (func $foo)) diff --git a/test/lit/passes/remove-unused-module-elements_all-features.wast b/test/lit/passes/remove-unused-module-elements_all-features.wast index 385433189..15a843064 100644 --- a/test/lit/passes/remove-unused-module-elements_all-features.wast +++ b/test/lit/passes/remove-unused-module-elements_all-features.wast @@ -175,11 +175,11 @@ (elem (table $1) (offset (i32.const 1)) func) ) (module ;; remove the first table and memory, but not the second one + (import "env" "memory" (memory $0 256)) + (import "env" "table" (table 0 funcref)) ;; CHECK: (type $0 (func)) ;; CHECK: (import "env" "table2" (table $1 1 1 funcref)) - (import "env" "memory" (memory $0 256)) - (import "env" "table" (table 0 funcref)) (import "env" "table2" (table $1 1 1 funcref)) (elem (table $1) (offset (i32.const 0)) func) (elem (table $1) (offset (i32.const 0)) func $f) @@ -203,22 +203,25 @@ (module ;; but not when exported ;; CHECK: (import "env" "memory" (memory $0 256)) (import "env" "memory" (memory $0 256)) - ;; CHECK: (import "env" "table" (table $timport$0 1 funcref)) (import "env" "table" (table 1 funcref)) - ;; CHECK: (export "mem" (memory $0)) (export "mem" (memory 0)) - ;; CHECK: (export "tab" (table $timport$0)) (export "tab" (table 0)) ) +;; CHECK: (import "env" "table" (table $timport$0 1 funcref)) + +;; CHECK: (export "mem" (memory $0)) + +;; CHECK: (export "tab" (table $timport$0)) (module ;; and not when there are segments ;; CHECK: (type $0 (func)) ;; CHECK: (import "env" "memory" (memory $0 256)) (import "env" "memory" (memory $0 256)) - ;; CHECK: (import "env" "table" (table $timport$0 1 funcref)) (import "env" "table" (table 1 funcref)) (data (i32.const 1) "hello, world!") (elem (i32.const 0) $waka) + ;; CHECK: (import "env" "table" (table $timport$0 1 funcref)) + ;; CHECK: (data $0 (i32.const 1) "hello, world!") ;; CHECK: (elem $0 (i32.const 0) $waka) @@ -233,10 +236,12 @@ (type $0 (func)) ;; CHECK: (import "env" "memory" (memory $0 256)) (import "env" "memory" (memory $0 256)) - ;; CHECK: (import "env" "table" (table $timport$0 0 funcref)) (import "env" "table" (table 0 funcref)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (import "env" "table" (table $timport$0 0 funcref)) + + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.load @@ -257,8 +262,9 @@ ;; CHECK: (memory $0 (shared 23 256)) (memory $0 (shared 23 256)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.const 0) @@ -274,8 +280,9 @@ ;; CHECK: (memory $0 (shared 23 256)) (memory $0 (shared 23 256)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) (result i32) ;; CHECK-NEXT: (i32.atomic.rmw.add ;; CHECK-NEXT: (i32.const 0) @@ -291,8 +298,9 @@ ;; CHECK: (memory $0 (shared 23 256)) (memory $0 (shared 23 256)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) (result i32) ;; CHECK-NEXT: (i32.atomic.rmw8.cmpxchg_u ;; CHECK-NEXT: (i32.const 0) @@ -309,8 +317,9 @@ ;; CHECK: (memory $0 (shared 23 256)) (memory $0 (shared 23 256)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local $1 i64) @@ -339,8 +348,9 @@ ;; CHECK: (memory $0 (shared 23 256)) (memory $0 (shared 23 256)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) (result i32) ;; CHECK-NEXT: (memory.atomic.notify ;; CHECK-NEXT: (i32.const 0) @@ -354,12 +364,13 @@ (module ;; atomic.fence and data.drop do not use a memory, so should not keep the memory alive. (memory $0 (shared 1 1)) (data "") + (export "fake-user" $user) ;; CHECK: (type $0 (func)) ;; CHECK: (data $0 "") ;; CHECK: (export "fake-user" (func $user)) - (export "fake-user" $user) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (atomic.fence) ;; CHECK-NEXT: (data.drop $0) @@ -378,8 +389,9 @@ (memory $1 23 256) (memory $unused 1 1) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (memory.grow $0 @@ -402,8 +414,9 @@ ;; CHECK: (memory $0 23 256) (memory $0 23 256) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) (result i32) ;; CHECK-NEXT: (memory.size) ;; CHECK-NEXT: ) @@ -419,8 +432,9 @@ ;; CHECK: (memory $1 1 1) (memory $1 1 1) (memory $unused 1 1) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (memory.copy $0 $1 ;; CHECK-NEXT: (i32.const 0) @@ -441,8 +455,9 @@ ;; CHECK: (import "env" "memory" (memory $0 256)) (import "env" "memory" (memory $0 256)) - ;; CHECK: (import "env" "table" (table $timport$0 0 funcref)) (import "env" "table" (table 0 funcref)) + ;; CHECK: (import "env" "table" (table $timport$0 0 funcref)) + ;; CHECK: (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "memoryBase" (global $memoryBase i32)) ;; used in init ;; CHECK: (import "env" "tableBase" (global $tableBase i32)) @@ -467,8 +482,8 @@ ;; CHECK: (import "env" "imported" (global $imported i32)) (import "env" "imported" (global $imported i32)) - ;; CHECK: (import "env" "_puts" (func $_puts (type $2) (param i32) (result i32))) (import "env" "forgetme" (global $forgetme i32)) + ;; CHECK: (import "env" "_puts" (func $_puts (type $2) (param i32) (result i32))) (import "env" "_puts" (func $_puts (param i32) (result i32))) (import "env" "forget_puts" (func $forget_puts (param i32) (result i32))) ;; CHECK: (global $int (mut i32) (global.get $imported)) |