diff options
-rw-r--r-- | src/tools/wasm-ctor-eval.cpp | 4 | ||||
-rw-r--r-- | test/ctor-eval/bad-indirect-call2.wast.out | 7 | ||||
-rw-r--r-- | test/ctor-eval/basics-flatten.wast.out | 26 | ||||
-rw-r--r-- | test/ctor-eval/basics.wast.out | 26 | ||||
-rw-r--r-- | test/ctor-eval/imported-min.wast.out | 15 | ||||
-rw-r--r-- | test/ctor-eval/imported.wast.out | 15 | ||||
-rw-r--r-- | test/ctor-eval/imported2.wast.out | 11 | ||||
-rw-r--r-- | test/ctor-eval/imported3.wast.out | 2 | ||||
-rw-r--r-- | test/ctor-eval/indirect-call3.wast.out | 9 | ||||
-rw-r--r-- | test/ctor-eval/just_some.wast.out | 8 | ||||
-rw-r--r-- | test/ctor-eval/unsafe_store.wast.out | 7 | ||||
-rw-r--r-- | test/ctor-eval/unsafe_store2.wast.out | 7 | ||||
-rw-r--r-- | test/ctor-eval/unsafe_store3.wast.out | 7 |
13 files changed, 18 insertions, 126 deletions
diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index b71a0356a..dee342255 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -345,9 +345,12 @@ void evalCtors(Module& wasm, std::vector<std::string> ctors) { } std::cerr << " ...success on " << ctor << ".\n"; // success, the entire function was evalled! + // we can nop the function (which may be used elsewhere) + // and remove the export auto* exp = wasm.getExport(ctor); auto* func = wasm.getFunction(exp->value); func->body = wasm.allocator.alloc<Nop>(); + wasm.removeExport(exp->name); } } catch (FailToEvalException& fail) { // that's it, we failed to even create the instance @@ -426,6 +429,7 @@ int main(int argc, const char* argv[]) { passRunner.add("dce"); passRunner.add("merge-blocks"); passRunner.add("vacuum"); + passRunner.add("remove-unused-module-elements"); passRunner.run(); } diff --git a/test/ctor-eval/bad-indirect-call2.wast.out b/test/ctor-eval/bad-indirect-call2.wast.out index b6a50c2f5..5efde23ed 100644 --- a/test/ctor-eval/bad-indirect-call2.wast.out +++ b/test/ctor-eval/bad-indirect-call2.wast.out @@ -1,5 +1,4 @@ (module - (type $v (func)) (type $FUNCSIG$v (func)) (import "env" "_abort" (func $_abort)) (table 2 2 anyfunc) @@ -7,8 +6,8 @@ (memory $0 256 256) (data (i32.const 10) "waka waka waka waka waka") (export "test1" (func $test1)) - (func $test1 (; 1 ;) (type $v) - (call_indirect (type $v) + (func $test1 (; 1 ;) (type $FUNCSIG$v) + (call_indirect (type $FUNCSIG$v) (i32.const 0) ) (i32.store8 @@ -16,7 +15,7 @@ (i32.const 120) ) ) - (func $call-indirect (; 2 ;) (type $v) + (func $call-indirect (; 2 ;) (type $FUNCSIG$v) (i32.store8 (i32.const 40) (i32.const 67) diff --git a/test/ctor-eval/basics-flatten.wast.out b/test/ctor-eval/basics-flatten.wast.out index b3b937c59..4273c256a 100644 --- a/test/ctor-eval/basics-flatten.wast.out +++ b/test/ctor-eval/basics-flatten.wast.out @@ -1,32 +1,8 @@ (module (type $v (func)) - (table 1 1 anyfunc) - (elem (i32.const 0) $call-indirect) (memory $0 256 256) (data (i32.const 10) "nas\00\00\00aka\00yzkx waka wakm\00\00\00\00\00\00C") - (export "test1" (func $test1)) - (export "test2" (func $test2)) - (export "test3" (func $test3)) - (func $test1 (; 0 ;) (type $v) - (nop) - ) - (func $test2 (; 1 ;) (type $v) - (nop) - ) - (func $test3 (; 2 ;) (type $v) - (nop) - ) - (func $safe-to-call (; 3 ;) (type $v) - (i32.store8 - (i32.const 10) - (i32.const 110) - ) - (i32.store8 - (i32.const 33) - (i32.const 109) - ) - ) - (func $call-indirect (; 4 ;) (type $v) + (func $call-indirect (; 0 ;) (type $v) (i32.store8 (i32.const 40) (i32.const 67) diff --git a/test/ctor-eval/basics.wast.out b/test/ctor-eval/basics.wast.out index 3179f7b36..185e556ec 100644 --- a/test/ctor-eval/basics.wast.out +++ b/test/ctor-eval/basics.wast.out @@ -1,32 +1,8 @@ (module (type $v (func)) - (table 1 1 anyfunc) - (elem (i32.const 0) $call-indirect) (memory $0 256 256) (data (i32.const 10) "nas\00\00\00aka yzkx waka wakm\00\00\00\00\00\00C") - (export "test1" (func $test1)) - (export "test2" (func $test2)) - (export "test3" (func $test3)) - (func $test1 (; 0 ;) (type $v) - (nop) - ) - (func $test2 (; 1 ;) (type $v) - (nop) - ) - (func $test3 (; 2 ;) (type $v) - (nop) - ) - (func $safe-to-call (; 3 ;) (type $v) - (i32.store8 - (i32.const 10) - (i32.const 110) - ) - (i32.store8 - (i32.const 33) - (i32.const 109) - ) - ) - (func $call-indirect (; 4 ;) (type $v) + (func $call-indirect (; 0 ;) (type $v) (i32.store8 (i32.const 40) (i32.const 67) diff --git a/test/ctor-eval/imported-min.wast.out b/test/ctor-eval/imported-min.wast.out index dd0f88841..3871caf2f 100644 --- a/test/ctor-eval/imported-min.wast.out +++ b/test/ctor-eval/imported-min.wast.out @@ -1,22 +1,11 @@ (module (type $0 (func)) - (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) - (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) (import "env" "tempDoublePtr" (global $tempDoublePtr i32)) - (global $mine (mut i32) (i32.const 1)) - (global $global0 (mut i32) (get_global $STACKTOP$asm2wasm$import)) - (global $global1 (mut i32) (get_global $STACK_MAX$asm2wasm$import)) - (global $do-not-use (mut i32) (get_global $tempDoublePtr)) (memory $0 256 256) (data (i32.const 10) "wasa waka waka waka waka") - (export "test1" (func $test1)) (export "test2" (func $test2)) (export "test3" (func $test3)) - (func $test1 (; 0 ;) (type $0) - (local $temp i32) - (nop) - ) - (func $test2 (; 1 ;) (type $0) + (func $test2 (; 0 ;) (type $0) (set_global $tempDoublePtr (i32.const 1) ) @@ -25,7 +14,7 @@ (i32.const 115) ) ) - (func $test3 (; 2 ;) (type $0) + (func $test3 (; 1 ;) (type $0) (i32.store8 (i32.const 14) (i32.const 115) diff --git a/test/ctor-eval/imported.wast.out b/test/ctor-eval/imported.wast.out index 6a7557e88..3871caf2f 100644 --- a/test/ctor-eval/imported.wast.out +++ b/test/ctor-eval/imported.wast.out @@ -1,22 +1,11 @@ (module (type $0 (func)) - (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) - (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) (import "env" "tempDoublePtr" (global $tempDoublePtr i32)) - (global $mine (mut i32) (i32.const 1)) - (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) - (global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import)) - (global $do-not-use (mut i32) (get_global $tempDoublePtr)) (memory $0 256 256) (data (i32.const 10) "wasa waka waka waka waka") - (export "test1" (func $test1)) (export "test2" (func $test2)) (export "test3" (func $test3)) - (func $test1 (; 0 ;) (type $0) - (local $temp i32) - (nop) - ) - (func $test2 (; 1 ;) (type $0) + (func $test2 (; 0 ;) (type $0) (set_global $tempDoublePtr (i32.const 1) ) @@ -25,7 +14,7 @@ (i32.const 115) ) ) - (func $test3 (; 2 ;) (type $0) + (func $test3 (; 1 ;) (type $0) (i32.store8 (i32.const 14) (i32.const 115) diff --git a/test/ctor-eval/imported2.wast.out b/test/ctor-eval/imported2.wast.out index add5a1e99..e86317071 100644 --- a/test/ctor-eval/imported2.wast.out +++ b/test/ctor-eval/imported2.wast.out @@ -1,18 +1,11 @@ (module (type $0 (func)) - (import "env" "STACKTOP" (global $STACKTOP i32)) - (import "env" "STACK_MAX" (global $STACK_MAX i32)) - (import "env" "tempDoublePtr" (global $tempDoublePtr i32)) (global $mine (mut i32) (i32.const 1)) (memory $0 256 256) (data (i32.const 10) "wasa waka waka waka waka") - (export "test1" (func $test1)) (export "test2" (func $test2)) (export "test3" (func $test3)) - (func $test1 (; 0 ;) (type $0) - (nop) - ) - (func $test2 (; 1 ;) (type $0) + (func $test2 (; 0 ;) (type $0) (set_global $mine (i32.const 2) ) @@ -21,7 +14,7 @@ (i32.const 115) ) ) - (func $test3 (; 2 ;) (type $0) + (func $test3 (; 1 ;) (type $0) (i32.store8 (i32.const 14) (i32.const 115) diff --git a/test/ctor-eval/imported3.wast.out b/test/ctor-eval/imported3.wast.out index b7e9dc5a3..0cbf32cea 100644 --- a/test/ctor-eval/imported3.wast.out +++ b/test/ctor-eval/imported3.wast.out @@ -1,7 +1,5 @@ (module (type $0 (func)) - (import "env" "tempDoublePtr" (global $tempDoublePtr i32)) - (global $mine (mut i32) (get_global $tempDoublePtr)) (memory $0 256 256) (data (i32.const 10) "waka waka waka waka waka") (export "test1" (func $test1)) diff --git a/test/ctor-eval/indirect-call3.wast.out b/test/ctor-eval/indirect-call3.wast.out index a4b2ac337..27351bcce 100644 --- a/test/ctor-eval/indirect-call3.wast.out +++ b/test/ctor-eval/indirect-call3.wast.out @@ -1,17 +1,10 @@ (module - (type $v (func)) (type $FUNCSIG$v (func)) (import "env" "tableBase" (global $tableBase i32)) (import "env" "_abort" (func $_abort)) - (table 2 2 anyfunc) - (elem (get_global $tableBase) $_abort $call-indirect) (memory $0 256 256) (data (i32.const 10) "waka waka xaka waka waka\00\00\00\00\00\00C") - (export "test1" (func $test1)) - (func $test1 (; 1 ;) (type $v) - (nop) - ) - (func $call-indirect (; 2 ;) (type $v) + (func $call-indirect (; 1 ;) (type $FUNCSIG$v) (i32.store8 (i32.const 40) (i32.const 67) diff --git a/test/ctor-eval/just_some.wast.out b/test/ctor-eval/just_some.wast.out index c44e6a9df..b7a1aa2be 100644 --- a/test/ctor-eval/just_some.wast.out +++ b/test/ctor-eval/just_some.wast.out @@ -2,16 +2,12 @@ (type $0 (func)) (memory $0 256 256) (data (i32.const 10) "wasa waka waka waka waka") - (export "test1" (func $test1)) (export "test2" (func $test2)) (export "test3" (func $test3)) - (func $test1 (; 0 ;) (type $0) - (nop) - ) - (func $test2 (; 1 ;) (type $0) + (func $test2 (; 0 ;) (type $0) (unreachable) ) - (func $test3 (; 2 ;) (type $0) + (func $test3 (; 1 ;) (type $0) (i32.store8 (i32.const 13) (i32.const 113) diff --git a/test/ctor-eval/unsafe_store.wast.out b/test/ctor-eval/unsafe_store.wast.out index 36f3b74bd..e51bd298d 100644 --- a/test/ctor-eval/unsafe_store.wast.out +++ b/test/ctor-eval/unsafe_store.wast.out @@ -1,11 +1,4 @@ (module - (type $0 (func)) - (memory $0 256 256) - (data (i32.const 9) "mwaka waka waka waka waka") - (export "test1" (func $test1)) (export "test2" (func $test2)) (export "test3" (func $test3)) - (func $test1 (; 0 ;) (type $0) - (nop) - ) ) diff --git a/test/ctor-eval/unsafe_store2.wast.out b/test/ctor-eval/unsafe_store2.wast.out index a0d34e8b4..e51bd298d 100644 --- a/test/ctor-eval/unsafe_store2.wast.out +++ b/test/ctor-eval/unsafe_store2.wast.out @@ -1,11 +1,4 @@ (module - (type $0 (func)) - (memory $0 256 256) - (data (i32.const 10) "waka waka waka waka wakam") - (export "test1" (func $test1)) (export "test2" (func $test2)) (export "test3" (func $test3)) - (func $test1 (; 0 ;) (type $0) - (nop) - ) ) diff --git a/test/ctor-eval/unsafe_store3.wast.out b/test/ctor-eval/unsafe_store3.wast.out index 189f830e7..e51bd298d 100644 --- a/test/ctor-eval/unsafe_store3.wast.out +++ b/test/ctor-eval/unsafe_store3.wast.out @@ -1,11 +1,4 @@ (module - (type $0 (func)) - (memory $0 256 256) - (data (i32.const 10) "waka waka waka waka wakm") - (export "test1" (func $test1)) (export "test2" (func $test2)) (export "test3" (func $test3)) - (func $test1 (; 0 ;) (type $0) - (nop) - ) ) |