diff --git a/scripts/update_lit_checks.py b/scripts/update_lit_checks.py index ef1dc6aaef9..79af92ab986 100755 --- a/scripts/update_lit_checks.py +++ b/scripts/update_lit_checks.py @@ -39,7 +39,11 @@ ALL_ITEMS = '|'.join(['type', 'import', 'global', 'memory', 'data', 'table', 'elem', 'tag', 'export', 'start', 'func']) -ITEM_NAME = r'\$?[^\s()]*|"[^\s()]*"' + +# Regular names as well as the "declare" in (elem declare ... to get declarative +# segments included in the output. +ITEM_NAME = r'\$[^\s()]*|"[^\s()]*"|declare' + # FIXME: This does not handle nested string contents. For example, # (data (i32.const 10) "hello(") # will look unterminated, due to the '(' inside the string. As a result, the @@ -152,9 +156,9 @@ def parse_output_fuzz_exec(text): for line in text.split('\n'): func = FUZZ_EXEC_FUNC.match(line) if func: - # Add quotes around the name because that is how it will be parsed + # Add a '$' prefix to the name because that is how it will be parsed # in the input. - name = f'"{func.group("name")}"' + name = '$' + func.group("name") items.append((('func', name), [line])) elif line.startswith('[host limit'): # Skip mentions of host limits that we hit. This can happen even diff --git a/src/passes/Heap2Local.cpp b/src/passes/Heap2Local.cpp index 0f569374b2d..fcf0d88863b 100644 --- a/src/passes/Heap2Local.cpp +++ b/src/passes/Heap2Local.cpp @@ -38,7 +38,7 @@ // // (import "env" "import" (func $import (param i32) (result i32))) // -// (func "example" +// (func $example // (local $ref (ref null $boxed-int)) // // ;; Allocate a boxed integer of 42 and save the reference to it. diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 71181566d5e..5ea62c9f21d 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -51,40 +51,6 @@ bool isFullForced() { return false; } -std::ostream& printName(Name name, std::ostream& o) { - assert(name && "Cannot print an empty name"); - // We need to quote names if they have tricky chars. - // TODO: This is not spec-compliant since the spec does not support quoted - // identifiers and has a limited set of valid idchars. We need a more robust - // escaping scheme here. Reusing `printEscapedString` is not sufficient, - // either. - if (name.str.find_first_of("()") == std::string_view::npos) { - o << '$' << name.str; - } else { - o << "\"$" << name.str << '"'; - } - return o; -} - -std::ostream& printMemoryName(Name name, std::ostream& o, Module* wasm) { - if (!wasm || wasm->memories.size() > 1) { - o << ' '; - printName(name, o); - } - return o; -} - -std::ostream& printLocal(Index index, Function* func, std::ostream& o) { - Name name; - if (func) { - name = func->getLocalNameOrDefault(index); - } - if (!name) { - name = Name::fromInt(index); - } - return printName(name, o); -} - std::ostream& printEscapedString(std::ostream& os, std::string_view str) { os << '"'; for (unsigned char c : str) { @@ -119,6 +85,56 @@ std::ostream& printEscapedString(std::ostream& os, std::string_view str) { return os << '"'; } +// TODO: Use unicode rather than char. +bool isIDChar(char c) { + if ('0' <= c && c <= '9') { + return true; + } + if ('A' <= c && c <= 'Z') { + return true; + } + if ('a' <= c && c <= 'z') { + return true; + } + static std::array otherIDChars = { + {'!', '#', '$', '%', '&', '\'', '*', '+', '-', '.', '/', ':', + '<', '=', '>', '?', '@', '\\', '^', '_', '`', '|', '~'}}; + return std::find(otherIDChars.begin(), otherIDChars.end(), c) != + otherIDChars.end(); +} + +std::ostream& printName(Name name, std::ostream& o) { + assert(name && "Cannot print an empty name"); + // We need to quote names if they have tricky chars. + // TODO: This is not spec-compliant since the spec does not yet support quoted + // identifiers and has a limited set of valid idchars. + o << '$'; + if (std::all_of(name.str.begin(), name.str.end(), isIDChar)) { + return o << name.str; + } else { + return printEscapedString(o, name.str); + } +} + +std::ostream& printMemoryName(Name name, std::ostream& o, Module* wasm) { + if (!wasm || wasm->memories.size() > 1) { + o << ' '; + printName(name, o); + } + return o; +} + +std::ostream& printLocal(Index index, Function* func, std::ostream& o) { + Name name; + if (func) { + name = func->getLocalNameOrDefault(index); + } + if (!name) { + name = Name::fromInt(index); + } + return printName(name, o); +} + // Print a name from the type section, if available. Otherwise print the type // normally. void printTypeOrName(Type type, std::ostream& o, Module* wasm) { @@ -3266,7 +3282,8 @@ void PrintSExpression::visitModule(Module* curr) { printMedium(o, "(elem"); o << " declare func"; for (auto name : elemDeclareNames) { - o << " $" << name; + o << ' '; + printName(name, o); } o << ')' << maybeNewLine; } diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 49cf1ccfc71..42785e40eba 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1073,11 +1073,7 @@ size_t SExpressionWasmBuilder::parseFunctionNames(Element& s, Name& exportName) { size_t i = 1; while (i < s.size() && i < 3 && s[i]->isStr()) { - if (s[i]->quoted()) { - // an export name - exportName = s[i]->str(); - i++; - } else if (s[i]->dollared()) { + if (s[i]->dollared()) { name = s[i]->str(); i++; } else { diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 168bc00733f..8c6138413a9 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -143,14 +143,14 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (data $0 (i32.const 10) "hello, world") (data $1 "I am passive") (table $t0 1 funcref) - (elem $e0 (i32.const 0) "$kitchen()sinker") + (elem $e0 (i32.const 0) $"kitchen()sinker") (tag $a-tag (param i32)) (export "mem" (memory $0)) - (export "kitchen_sinker" (func "$kitchen()sinker")) + (export "kitchen_sinker" (func $"kitchen()sinker")) (export "a-global-exp" (global $a-global)) (export "a-tag-exp" (tag $a-tag)) (start $starter) - (func "$kitchen()sinker" (type $0) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) + (func $"kitchen()sinker" (type $0) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) (local $4 i32) (block $the-body (result i32) (block $the-nothing @@ -1979,7 +1979,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (drop (i32.eqz - (call "$kitchen()sinker" + (call $"kitchen()sinker" (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -2057,7 +2057,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (return (i32.const 1337) ) - (return_call "$kitchen()sinker" + (return_call $"kitchen()sinker" (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -2082,13 +2082,13 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (drop (ref.is_null - (ref.func "$kitchen()sinker") + (ref.func $"kitchen()sinker") ) ) (drop (select (result funcref) (ref.null nofunc) - (ref.func "$kitchen()sinker") + (ref.func $"kitchen()sinker") (i32.const 1) ) ) @@ -2247,14 +2247,14 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (data $0 (i32.const 10) "hello, world") (data $1 "I am passive") (table $t0 1 funcref) - (elem $e0 (i32.const 0) "$kitchen()sinker") + (elem $e0 (i32.const 0) $"kitchen()sinker") (tag $a-tag (param i32)) (export "mem" (memory $0)) - (export "kitchen_sinker" (func "$kitchen()sinker")) + (export "kitchen_sinker" (func $"kitchen()sinker")) (export "a-global-exp" (global $a-global)) (export "a-tag-exp" (tag $a-tag)) (start $starter) - (func "$kitchen()sinker" (type $0) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) + (func $"kitchen()sinker" (type $0) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) (local $4 i32) (block $the-body (result i32) (block $the-nothing @@ -4083,7 +4083,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (drop (i32.eqz - (call "$kitchen()sinker" + (call $"kitchen()sinker" (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -4161,7 +4161,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (return (i32.const 1337) ) - (return_call "$kitchen()sinker" + (return_call $"kitchen()sinker" (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -4186,13 +4186,13 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (drop (ref.is_null - (ref.func "$kitchen()sinker") + (ref.func $"kitchen()sinker") ) ) (drop (select (result funcref) (ref.null nofunc) - (ref.func "$kitchen()sinker") + (ref.func $"kitchen()sinker") (i32.const 1) ) ) diff --git a/test/ctor-eval/gc-2.wast b/test/ctor-eval/gc-2.wast index 731f704681e..561ac617623 100644 --- a/test/ctor-eval/gc-2.wast +++ b/test/ctor-eval/gc-2.wast @@ -29,13 +29,13 @@ ) ) - (func "test1" + (func $test (export "test1") (global.set $global2 (global.get $global3) ) ) - (func "keepalive" (result i32) + (func $keepalive (export "keepalive") (result i32) (select (struct.get $struct 0 (ref.cast (ref $struct) diff --git a/test/ctor-eval/gc-2.wast.out b/test/ctor-eval/gc-2.wast.out index cec7f943057..4d80f764e36 100644 --- a/test/ctor-eval/gc-2.wast.out +++ b/test/ctor-eval/gc-2.wast.out @@ -10,8 +10,8 @@ (i32.const 1337) )) (global $global1 (ref any) (global.get $ctor-eval$global)) - (export "keepalive" (func $1)) - (func $1 (type $1) (result i32) + (export "keepalive" (func $keepalive)) + (func $keepalive (type $1) (result i32) (select (struct.get $struct 0 (ref.cast (ref $struct) diff --git a/test/ctor-eval/gc-array.wast b/test/ctor-eval/gc-array.wast index 0ad3d031479..2ecb92d5ed3 100644 --- a/test/ctor-eval/gc-array.wast +++ b/test/ctor-eval/gc-array.wast @@ -21,7 +21,7 @@ ) ) - (func "test1" + (func $test1 (export "test1") (array.set $array (global.get $global2) (i32.const 1) @@ -29,7 +29,7 @@ ) ) - (func "keepalive" (result i32) + (func $keepalive (export "keepalive") (result i32) (i32.add (array.get $array (global.get $global1) @@ -42,4 +42,3 @@ ) ) ) - diff --git a/test/ctor-eval/gc-array.wast.out b/test/ctor-eval/gc-array.wast.out index eadedfc4833..ed21823b8c7 100644 --- a/test/ctor-eval/gc-array.wast.out +++ b/test/ctor-eval/gc-array.wast.out @@ -11,8 +11,8 @@ (i32.const 42) (i32.const 1337) )) - (export "keepalive" (func $1)) - (func $1 (type $1) (result i32) + (export "keepalive" (func $keepalive)) + (func $keepalive (type $1) (result i32) (i32.add (array.get $array (global.get $global1) diff --git a/test/ctor-eval/gc.wast b/test/ctor-eval/gc.wast index 46ce6b49a2c..00c593121a5 100644 --- a/test/ctor-eval/gc.wast +++ b/test/ctor-eval/gc.wast @@ -21,7 +21,7 @@ ;; so a new (immutable) global will appear, and we will read from it. (global $global2 (mut (ref null $struct)) (ref.null $struct)) - (func "test1" + (func $test1 (export "test1") ;; The locals will be optimized into a single non-nullable one by the ;; optimizer. (local $temp1 (ref null $struct)) @@ -51,7 +51,7 @@ (call $import (local.get $temp2)) ) - (func "keepalive" (result i32) + (func $keepalive (export "keepalive") (result i32) (i32.add (struct.get $struct 0 (global.get $global1) diff --git a/test/ctor-eval/gc.wast.out b/test/ctor-eval/gc.wast.out index 8999d475690..ae3e21a180e 100644 --- a/test/ctor-eval/gc.wast.out +++ b/test/ctor-eval/gc.wast.out @@ -14,9 +14,9 @@ (global $ctor-eval$global_4 (ref $struct) (struct.new $struct (i32.const 99) )) - (export "test1" (func $0_3)) - (export "keepalive" (func $1)) - (func $1 (type $2) (result i32) + (export "test1" (func $test1_3)) + (export "keepalive" (func $keepalive)) + (func $keepalive (type $2) (result i32) (i32.add (struct.get $struct 0 (global.get $global1) @@ -26,7 +26,7 @@ ) ) ) - (func $0_3 (type $3) + (func $test1_3 (type $3) (local $0 (ref $struct)) (local.set $0 (global.get $ctor-eval$global_4) diff --git a/test/ctor-eval/ignore-external-input-gc.wast b/test/ctor-eval/ignore-external-input-gc.wast index 16558336c2d..67fcb30e851 100644 --- a/test/ctor-eval/ignore-external-input-gc.wast +++ b/test/ctor-eval/ignore-external-input-gc.wast @@ -2,7 +2,7 @@ (global $global1 (mut i32) (i32.const 10)) (global $global2 (mut i32) (i32.const 20)) - (func "test1" (param $any (ref null any)) + (func $test1 (export "test1") (param $any (ref null any)) ;; This is ok to call: when ignoring external input we assume 0 for the ;; parameters, and this parameter is nullable. (drop @@ -13,7 +13,7 @@ ) ) - (func "test2" (param $any (ref any)) + (func $test2 (export "test2") (param $any (ref any)) ;; This is *not* ok to call: when ignoring external input we assume 0 for ;; the parameters, and this parameter is not nullable. (drop @@ -24,7 +24,7 @@ ) ) - (func "keepalive" (result i32) + (func $keepalive (export "keepalive") (result i32) (i32.add (global.get $global1) (global.get $global2) diff --git a/test/ctor-eval/ignore-external-input-gc.wast.out b/test/ctor-eval/ignore-external-input-gc.wast.out index 9b10b808b7d..571c8198796 100644 --- a/test/ctor-eval/ignore-external-input-gc.wast.out +++ b/test/ctor-eval/ignore-external-input-gc.wast.out @@ -3,14 +3,14 @@ (type $1 (func (result i32))) (global $global1 (mut i32) (i32.const 11)) (global $global2 (mut i32) (i32.const 20)) - (export "test2" (func $1)) - (export "keepalive" (func $2)) - (func $1 (type $0) (param $any (ref any)) + (export "test2" (func $test2)) + (export "keepalive" (func $keepalive)) + (func $test2 (type $0) (param $any (ref any)) (global.set $global2 (i32.const 22) ) ) - (func $2 (type $1) (result i32) + (func $keepalive (type $1) (result i32) (i32.add (global.get $global1) (global.get $global2) diff --git a/test/ctor-eval/ignore-external-input.wast b/test/ctor-eval/ignore-external-input.wast index 56201160577..d581c7e04e7 100644 --- a/test/ctor-eval/ignore-external-input.wast +++ b/test/ctor-eval/ignore-external-input.wast @@ -10,7 +10,7 @@ (memory 256 256) (data (i32.const 0) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") ;; the final 4 'a's will remain - (func "test1" + (func $test1 (export "test1") ;; This is ok to call: when ignoring external input we assume there is no ;; environment to read. (i32.store @@ -29,7 +29,7 @@ ) ) - (func "test2" + (func $test2 (export "test2") ;; This is also ok to call: when ignoring external input we assume there are ;; not args passed to main. (i32.store @@ -48,7 +48,7 @@ ) ) - (func "test2b" (param $x i32) + (func $test2b (export "test2b") (param $x i32) ;; This is also ok to call: when ignoring external input we assume the ;; args are zeros. (i32.store @@ -57,7 +57,7 @@ ) ) - (func "test3" + (func $test3 (export "test3") ;; This is *not* ok to call, and we will *not* reach the final store after ;; this call. This function will not be evalled and will remain in the ;; output. diff --git a/test/ctor-eval/ignore-external-input.wast.out b/test/ctor-eval/ignore-external-input.wast.out index 43de6066590..a557ec99e29 100644 --- a/test/ctor-eval/ignore-external-input.wast.out +++ b/test/ctor-eval/ignore-external-input.wast.out @@ -4,8 +4,8 @@ (import "wasi_snapshot_preview1" "something_else" (func $wasi_something_else (type $0) (result i32))) (memory $0 256 256) (data $0 (i32.const 28) "aaaa") - (export "test3" (func $3)) - (func $3 (type $1) + (export "test3" (func $test3)) + (func $test3 (type $1) (drop (call $wasi_something_else) ) diff --git a/test/ctor-eval/imported-global-2.wast b/test/ctor-eval/imported-global-2.wast index e10dc70802c..0662fb76056 100644 --- a/test/ctor-eval/imported-global-2.wast +++ b/test/ctor-eval/imported-global-2.wast @@ -4,7 +4,7 @@ ;; imports must not be used (import "env" "imported" (global $imported i32)) - (func "test1" (result i32) + (func $test1 (export "test1") (result i32) (local $temp i32) ;; this errors, and we never get to evalling the store after it @@ -20,7 +20,7 @@ (local.get $temp) ) - (func "keepalive" (result i32) + (func $keepalive (export "keepalive") (result i32) (drop (i32.load (i32.const 13) diff --git a/test/ctor-eval/imported-global-2.wast.out b/test/ctor-eval/imported-global-2.wast.out index 0347b4970c3..bc276175e2a 100644 --- a/test/ctor-eval/imported-global-2.wast.out +++ b/test/ctor-eval/imported-global-2.wast.out @@ -2,9 +2,9 @@ (type $0 (func (result i32))) (import "env" "imported" (global $imported i32)) (memory $0 256 256) - (export "test1" (func $0)) - (export "keepalive" (func $1)) - (func $0 (type $0) (result i32) + (export "test1" (func $test1)) + (export "keepalive" (func $keepalive)) + (func $test1 (type $0) (result i32) (local $temp i32) (local.set $temp (global.get $imported) @@ -15,7 +15,7 @@ ) (local.get $temp) ) - (func $1 (type $0) (result i32) + (func $keepalive (type $0) (result i32) (drop (i32.load (i32.const 13) diff --git a/test/ctor-eval/memory-init.wast b/test/ctor-eval/memory-init.wast index b910aa2f3c1..bef35c7e0ff 100644 --- a/test/ctor-eval/memory-init.wast +++ b/test/ctor-eval/memory-init.wast @@ -2,7 +2,7 @@ (memory $0 1) (data (i32.const 0) "__________") (data (i32.const 20) "__________") - (func "test1" + (func $test1 (export "test1") ;; A store that can be evalled. (i32.store8 (i32.const 4) @@ -19,4 +19,3 @@ ) ) ) - diff --git a/test/ctor-eval/memory-init.wast.out b/test/ctor-eval/memory-init.wast.out index 59c4b691def..3726b5ef240 100644 --- a/test/ctor-eval/memory-init.wast.out +++ b/test/ctor-eval/memory-init.wast.out @@ -3,8 +3,8 @@ (memory $0 1) (data $0 (i32.const 0) "__________") (data $1 (i32.const 20) "__________") - (export "test1" (func $0)) - (func $0 (type $0) + (export "test1" (func $test1)) + (func $test1 (type $0) (i32.store8 (i32.const 4) (i32.const 100) diff --git a/test/ctor-eval/params.wast b/test/ctor-eval/params.wast index cb346bb3b38..196a2ebae1a 100644 --- a/test/ctor-eval/params.wast +++ b/test/ctor-eval/params.wast @@ -1,5 +1,5 @@ (module - (func "test1" (param $x i32) + (func $test1 (export "test1") (param $x i32) ;; The presence of params stops us from evalling this function, at least ;; not with --ignore-external-input (see ignore-external-input.wast) (nop) diff --git a/test/ctor-eval/params.wast.out b/test/ctor-eval/params.wast.out index 1352c0187a1..5af29aab5e6 100644 --- a/test/ctor-eval/params.wast.out +++ b/test/ctor-eval/params.wast.out @@ -1,7 +1,7 @@ (module (type $0 (func (param i32))) - (export "test1" (func $0)) - (func $0 (type $0) (param $x i32) + (export "test1" (func $test1)) + (func $test1 (type $0) (param $x i32) (nop) ) ) diff --git a/test/ctor-eval/results.wast b/test/ctor-eval/results.wast index bbc48db3cdc..bfefa2756c2 100644 --- a/test/ctor-eval/results.wast +++ b/test/ctor-eval/results.wast @@ -63,7 +63,7 @@ (i32.const 100) ) - (func "keepalive" (result i32) + (func $keepalive (export "keepalive") (result i32) ;; Keep everything alive to see the changes. ;; These should call the original $test1, not the one that is nopped out diff --git a/test/ctor-eval/results.wast.out b/test/ctor-eval/results.wast.out index 358320e081d..5f750a1a8ce 100644 --- a/test/ctor-eval/results.wast.out +++ b/test/ctor-eval/results.wast.out @@ -10,7 +10,7 @@ (export "test1" (func $test1_7)) (export "test3" (func $test3_8)) (export "test5" (func $test5_9)) - (export "keepalive" (func $5)) + (export "keepalive" (func $keepalive)) (func $test1 (type $1) (global.set $global1 (i32.const 11) @@ -40,7 +40,7 @@ (call $import) (i32.const 100) ) - (func $5 (type $0) (result i32) + (func $keepalive (type $0) (result i32) (call $test1) (call $test2) (drop diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index 1554a418419..8955921b85b 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -59,7 +59,7 @@ BinaryenFeatureAll: 131071 ) (table.set $0 (i32.const 0) - (ref.func "$kitchen()sinker") + (ref.func $"kitchen()sinker") ) (table.get $0 (i32.const 0) @@ -93,13 +93,13 @@ BinaryenFeatureAll: 131071 (data $1 "I am passive") (table $tab 0 100 funcref) (table $0 1 1 funcref) - (elem $0 (table $0) (i32.const 0) func "$kitchen()sinker") - (elem $passive func "$kitchen()sinker") + (elem $0 (table $0) (i32.const 0) func $"kitchen()sinker") + (elem $passive func $"kitchen()sinker") (tag $a-tag (param i32)) (export "mem" (memory $0)) - (export "kitchen_sinker" (func "$kitchen()sinker")) + (export "kitchen_sinker" (func $"kitchen()sinker")) (start $starter) - (func "$kitchen()sinker" (type $2) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) + (func $"kitchen()sinker" (type $2) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) (local $4 i32) (local $5 externref) (block $the-body (result i32) @@ -2014,7 +2014,7 @@ BinaryenFeatureAll: 131071 ) (drop (i32.eqz - (call "$kitchen()sinker" + (call $"kitchen()sinker" (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -2092,7 +2092,7 @@ BinaryenFeatureAll: 131071 (return (i32.const 1337) ) - (return_call "$kitchen()sinker" + (return_call $"kitchen()sinker" (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -2112,13 +2112,13 @@ BinaryenFeatureAll: 131071 ) (drop (ref.is_null - (ref.func "$kitchen()sinker") + (ref.func $"kitchen()sinker") ) ) (drop (select (result funcref) (ref.null nofunc) - (ref.func "$kitchen()sinker") + (ref.func $"kitchen()sinker") (i32.const 1) ) ) diff --git a/test/lit/basic/complexTextNames.wast b/test/lit/basic/complexTextNames.wast index 4605f0165f1..88240e038d8 100644 --- a/test/lit/basic/complexTextNames.wast +++ b/test/lit/basic/complexTextNames.wast @@ -12,34 +12,27 @@ (module ;; CHECK-TEXT: (type $0 (func)) - ;; CHECK-TEXT: (export "$zoo (.bar)" (func $1)) - ;; CHECK-TEXT: (func $foo\20\28.bar\29 (type $0) ;; CHECK-TEXT-NEXT: (nop) ;; CHECK-TEXT-NEXT: ) ;; CHECK-BIN: (type $0 (func)) - ;; CHECK-BIN: (export "$zoo (.bar)" (func $1)) - ;; CHECK-BIN: (func $foo\20\28.bar\29 (type $0) ;; CHECK-BIN-NEXT: (nop) ;; CHECK-BIN-NEXT: ) (func $foo\20\28.bar\29) - (func "$zoo (.bar)" (call $foo\20\28.bar\29)) + ;; CHECK-TEXT: (func $"zoo (.bar)" (type $0) + ;; CHECK-TEXT-NEXT: (call $foo\20\28.bar\29) + ;; CHECK-TEXT-NEXT: ) + (func $"zoo (.bar)" (call $foo\20\28.bar\29)) ) -;; CHECK-TEXT: (func $1 (type $0) -;; CHECK-TEXT-NEXT: (call $foo\20\28.bar\29) -;; CHECK-TEXT-NEXT: ) - -;; CHECK-BIN: (func $1 (type $0) +;; CHECK-BIN: (func $zoo\20\28.bar\29 (type $0) ;; CHECK-BIN-NEXT: (call $foo\20\28.bar\29) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NODEBUG: (type $0 (func)) -;; CHECK-BIN-NODEBUG: (export "$zoo (.bar)" (func $1)) - ;; CHECK-BIN-NODEBUG: (func $0 (type $0) ;; CHECK-BIN-NODEBUG-NEXT: (nop) ;; CHECK-BIN-NODEBUG-NEXT: ) diff --git a/test/lit/basic/newsyntax.wast b/test/lit/basic/newsyntax.wast index 0811ec07e8d..204bed3ab08 100644 --- a/test/lit/basic/newsyntax.wast +++ b/test/lit/basic/newsyntax.wast @@ -27,43 +27,41 @@ ;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 9 9 funcref)) (import "env" "table" (table 9 9 funcref)) - (func "call_indirect" + ;; CHECK-TEXT: (export "call_indirect" (func $call_indirect)) + + ;; CHECK-TEXT: (func $call_indirect (type $0) + ;; CHECK-TEXT-NEXT: (drop + ;; CHECK-TEXT-NEXT: (call_indirect $timport$0 (type $1) + ;; CHECK-TEXT-NEXT: (i32.const 10) + ;; CHECK-TEXT-NEXT: (f64.const 20) + ;; CHECK-TEXT-NEXT: (i32.const 30) + ;; CHECK-TEXT-NEXT: ) + ;; CHECK-TEXT-NEXT: ) + ;; CHECK-TEXT-NEXT: (call_indirect $timport$0 (type $0) + ;; CHECK-TEXT-NEXT: (i32.const 1) + ;; CHECK-TEXT-NEXT: ) + ;; CHECK-TEXT-NEXT: ) + ;; CHECK-BIN: (export "call_indirect" (func $call_indirect)) + + ;; CHECK-BIN: (func $call_indirect (type $0) + ;; CHECK-BIN-NEXT: (drop + ;; CHECK-BIN-NEXT: (call_indirect $timport$0 (type $1) + ;; CHECK-BIN-NEXT: (i32.const 10) + ;; CHECK-BIN-NEXT: (f64.const 20) + ;; CHECK-BIN-NEXT: (i32.const 30) + ;; CHECK-BIN-NEXT: ) + ;; CHECK-BIN-NEXT: ) + ;; CHECK-BIN-NEXT: (call_indirect $timport$0 (type $0) + ;; CHECK-BIN-NEXT: (i32.const 1) + ;; CHECK-BIN-NEXT: ) + ;; CHECK-BIN-NEXT: ) + (func $call_indirect (export "call_indirect") (drop (call_indirect (param i32) (param f64) (result i32) (i32.const 10) (f64.const 20) (i32.const 30)) ) (call_indirect (i32.const 1)) ) ) -;; CHECK-TEXT: (export "call_indirect" (func $0)) - -;; CHECK-TEXT: (func $0 (type $0) -;; CHECK-TEXT-NEXT: (drop -;; CHECK-TEXT-NEXT: (call_indirect $timport$0 (type $1) -;; CHECK-TEXT-NEXT: (i32.const 10) -;; CHECK-TEXT-NEXT: (f64.const 20) -;; CHECK-TEXT-NEXT: (i32.const 30) -;; CHECK-TEXT-NEXT: ) -;; CHECK-TEXT-NEXT: ) -;; CHECK-TEXT-NEXT: (call_indirect $timport$0 (type $0) -;; CHECK-TEXT-NEXT: (i32.const 1) -;; CHECK-TEXT-NEXT: ) -;; CHECK-TEXT-NEXT: ) - -;; CHECK-BIN: (export "call_indirect" (func $0)) - -;; CHECK-BIN: (func $0 (type $0) -;; CHECK-BIN-NEXT: (drop -;; CHECK-BIN-NEXT: (call_indirect $timport$0 (type $1) -;; CHECK-BIN-NEXT: (i32.const 10) -;; CHECK-BIN-NEXT: (f64.const 20) -;; CHECK-BIN-NEXT: (i32.const 30) -;; CHECK-BIN-NEXT: ) -;; CHECK-BIN-NEXT: ) -;; CHECK-BIN-NEXT: (call_indirect $timport$0 (type $0) -;; CHECK-BIN-NEXT: (i32.const 1) -;; CHECK-BIN-NEXT: ) -;; CHECK-BIN-NEXT: ) - ;; CHECK-BIN-NODEBUG: (export "call_indirect" (func $0)) ;; CHECK-BIN-NODEBUG: (func $0 (type $0) diff --git a/test/lit/ctor-eval/array_new_data.wast b/test/lit/ctor-eval/array_new_data.wast index 248b71ba438..a185c171f0c 100644 --- a/test/lit/ctor-eval/array_new_data.wast +++ b/test/lit/ctor-eval/array_new_data.wast @@ -14,7 +14,17 @@ ;; CHECK: (data $1 (i32.const 0) "") (data $1 (i32.const 0) "") - (func "test" + ;; CHECK: (export "test" (func $test)) + + ;; CHECK: (func $test (type $0) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (array.new_data $[i8] $1 + ;; CHECK-NEXT: (i32.const 16) + ;; CHECK-NEXT: (i32.const 8) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $test (export "test") ;; An array.new_data cannot be evalled since ctor-eval flattens memory segments ;; atm. In fact the module would not validate as we refer to segment 1 here ;; but after flattening only segment 0 exists. @@ -26,13 +36,3 @@ ) ) ) -;; CHECK: (export "test" (func $0)) - -;; CHECK: (func $0 (type $0) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (array.new_data $[i8] $1 -;; CHECK-NEXT: (i32.const 16) -;; CHECK-NEXT: (i32.const 8) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) diff --git a/test/lit/ctor-eval/data_drop.wast b/test/lit/ctor-eval/data_drop.wast index c1bfd487ca1..5833cf4a007 100644 --- a/test/lit/ctor-eval/data_drop.wast +++ b/test/lit/ctor-eval/data_drop.wast @@ -9,7 +9,20 @@ (data (i32.const 0) "__________") (data (i32.const 20) "__________") - (func "test" + ;; CHECK: (data $0 (i32.const 0) "__________") + + ;; CHECK: (data $1 (i32.const 20) "__________") + + ;; CHECK: (export "test" (func $test)) + + ;; CHECK: (func $test (type $0) + ;; CHECK-NEXT: (i32.store8 + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: (i32.const 100) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (data.drop $1) + ;; CHECK-NEXT: ) + (func $test (export "test") ;; A store that can be evalled, but we do not do so because of the ;; instruction after us. (i32.store8 @@ -23,16 +36,3 @@ (data.drop 1) ) ) -;; CHECK: (data $0 (i32.const 0) "__________") - -;; CHECK: (data $1 (i32.const 20) "__________") - -;; CHECK: (export "test" (func $0)) - -;; CHECK: (func $0 (type $0) -;; CHECK-NEXT: (i32.store8 -;; CHECK-NEXT: (i32.const 4) -;; CHECK-NEXT: (i32.const 100) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (data.drop $1) -;; CHECK-NEXT: ) diff --git a/test/lit/ctor-eval/high_memory.wast b/test/lit/ctor-eval/high_memory.wast index 86e3827f47e..b7a9f60eb47 100644 --- a/test/lit/ctor-eval/high_memory.wast +++ b/test/lit/ctor-eval/high_memory.wast @@ -7,7 +7,7 @@ ;; CHECK: (memory $0 1616) (memory $0 1616) ;; 101 MB - (func "test1" + (func $test1 (export "test1") ;; This write will be evalled into a data segment and removed. (i32.store8 (i32.const 0x63fffff) ;; 100 MB - 1 @@ -15,7 +15,19 @@ ) ) - (func "test2" + ;; CHECK: (data $0 (i32.const 104857599) "*") + + ;; CHECK: (export "test1" (func $test1_2)) + + ;; CHECK: (export "test2" (func $test2)) + + ;; CHECK: (func $test2 (type $0) + ;; CHECK-NEXT: (i32.store8 + ;; CHECK-NEXT: (i32.const 104857600) + ;; CHECK-NEXT: (i32.const 43) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $test2 (export "test2") ;; We stop at this write to a high address (wasm-ctor-eval generally only ;; writes to low addresses, so it is tuned for that) (i32.store8 @@ -24,19 +36,6 @@ ) ) ) -;; CHECK: (data $0 (i32.const 104857599) "*") - -;; CHECK: (export "test1" (func $0_2)) - -;; CHECK: (export "test2" (func $1)) - -;; CHECK: (func $1 (type $0) -;; CHECK-NEXT: (i32.store8 -;; CHECK-NEXT: (i32.const 104857600) -;; CHECK-NEXT: (i32.const 43) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) - -;; CHECK: (func $0_2 (type $0) +;; CHECK: (func $test1_2 (type $0) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) diff --git a/test/lit/exec/array.wast b/test/lit/exec/array.wast index 7e74c7b7d74..fb6a8b34616 100644 --- a/test/lit/exec/array.wast +++ b/test/lit/exec/array.wast @@ -7,7 +7,7 @@ ;; CHECK: [fuzz-exec] calling func ;; CHECK-NEXT: [fuzz-exec] note result: func => 1 - (func "func" (result i32) + (func $func (export "func") (result i32) ;; Verifies the order of execution is correct - we should return 1, not 2. (array.new $array (return (i32.const 1)) diff --git a/test/lit/exec/delegate-vacuum.wast b/test/lit/exec/delegate-vacuum.wast index c9276056810..084113c2bbe 100644 --- a/test/lit/exec/delegate-vacuum.wast +++ b/test/lit/exec/delegate-vacuum.wast @@ -9,7 +9,7 @@ (tag $tag$0 (param i32)) ;; CHECK: [fuzz-exec] calling export-1 ;; CHECK-NEXT: [exception thrown: tag$0 0] - (func "export-1" + (func $export-1 (export "export-1") (try (do (try @@ -30,7 +30,7 @@ ) ;; CHECK: [fuzz-exec] calling export-2 ;; CHECK-NEXT: [trap unreachable] - (func "export-2" + (func $export-2 (export "export-2") (call $inner) (unreachable) ) diff --git a/test/lit/exec/eh-gc.wast b/test/lit/exec/eh-gc.wast index cac2f6adf0d..f10a27c5765 100644 --- a/test/lit/exec/eh-gc.wast +++ b/test/lit/exec/eh-gc.wast @@ -6,7 +6,7 @@ (tag $tag (param externref)) ;; CHECK: [fuzz-exec] calling catch-null - (func "catch-null" + (func $catch-null (export "catch-null") (try $label$3 (do ;; Throw a null. diff --git a/test/lit/exec/eh-print.wast b/test/lit/exec/eh-print.wast index 8f9520e75a2..f501646313f 100644 --- a/test/lit/exec/eh-print.wast +++ b/test/lit/exec/eh-print.wast @@ -12,7 +12,7 @@ ;; CHECK: [fuzz-exec] calling array ;; CHECK-NEXT: [exception thrown: A [ref (type $array.0 (array (mut i32))) (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0[..])]] - (func "array" (result (ref $A)) + (func $array (export "array") (result (ref $A)) ;; Throw a very large array. We should not print all 12K items in it, as that ;; would be very verbose. Instead we stop after a reasonable amount and ;; print [..] for the rest. @@ -25,7 +25,7 @@ ;; CHECK: [fuzz-exec] calling struct ;; CHECK-NEXT: [exception thrown: B [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [ref (type $struct.0 (struct (field (mut anyref)))) [..]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] - (func "struct" (result (ref $B)) + (func $struct (export "struct") (result (ref $B)) (local $x (ref $B)) ;; As above, but now with a recursive struct. (local.set $x @@ -40,4 +40,3 @@ ) ) ) - diff --git a/test/lit/exec/eh.wast b/test/lit/exec/eh.wast index 779309eb6d5..930e57c202f 100644 --- a/test/lit/exec/eh.wast +++ b/test/lit/exec/eh.wast @@ -7,12 +7,12 @@ ;; CHECK: [fuzz-exec] calling throw ;; CHECK-NEXT: [exception thrown: e-i32 1] - (func "throw" + (func $throw (export "throw") (throw $e-i32 (i32.const 1)) ) ;; CHECK: [fuzz-exec] calling try-catch - (func "try-catch" + (func $try-catch (export "try-catch") (try (do (throw $e-i32 (i32.const 2)) @@ -25,7 +25,7 @@ ;; CHECK: [fuzz-exec] calling catchless-try ;; CHECK-NEXT: [exception thrown: e-i32 3] - (func "catchless-try" + (func $catchless-try (export "catchless-try") (try (do (throw $e-i32 (i32.const 3)) @@ -35,7 +35,7 @@ ;; CHECK: [fuzz-exec] calling try-delegate ;; CHECK-NEXT: [exception thrown: e-i32 4] - (func "try-delegate" + (func $try-delegate (export "try-delegate") (try $l0 (do (try diff --git a/test/lit/exec/gc-cycle-leak.wast b/test/lit/exec/gc-cycle-leak.wast index 75c3293927d..f4f62b53367 100644 --- a/test/lit/exec/gc-cycle-leak.wast +++ b/test/lit/exec/gc-cycle-leak.wast @@ -6,7 +6,7 @@ (type $A (struct (field (mut (ref null $A))))) ;; CHECK: [fuzz-exec] calling test - (func "test" + (func $test (export "test") (local $a (ref $A)) ;; This function makes a self-cycle where the local $a's ref field points to ;; itself. This test checks that we do not error, even in sanitizers, when diff --git a/test/lit/exec/host-limit.wast b/test/lit/exec/host-limit.wast index ee59d655b2f..e64a47d8a3f 100644 --- a/test/lit/exec/host-limit.wast +++ b/test/lit/exec/host-limit.wast @@ -18,10 +18,9 @@ ;; CHECK: [fuzz-exec] calling export ;; CHECK-NEXT: [LoggingExternalInterface logging 42] ;; CHECK-NEXT: ignoring comparison of ExecutionResults! - (func "export" + (func $export (export "export") (call $log (i32.const 42) ) ) ) - diff --git a/test/lit/exec/i31.wast b/test/lit/exec/i31.wast index cd25dffa029..70d220d8c50 100644 --- a/test/lit/exec/i31.wast +++ b/test/lit/exec/i31.wast @@ -5,7 +5,7 @@ (module ;; CHECK: [fuzz-exec] calling null-local ;; CHECK-NEXT: [fuzz-exec] note result: null-local => 1 - (func "null-local" (result i32) + (func $null-local (export "null-local") (result i32) (local $ref (ref null i31)) (ref.is_null (local.get $ref) @@ -14,7 +14,7 @@ ;; CHECK: [fuzz-exec] calling null-immediate ;; CHECK-NEXT: [fuzz-exec] note result: null-immediate => 1 - (func "null-immediate" (result i32) + (func $null-immediate (export "null-immediate") (result i32) (ref.is_null (ref.null i31) ) @@ -22,7 +22,7 @@ ;; CHECK: [fuzz-exec] calling non-null ;; CHECK-NEXT: [fuzz-exec] note result: non-null => 0 - (func "non-null" (result i32) + (func $non-null (export "non-null") (result i32) (ref.is_null (ref.i31 (i32.const 1234) @@ -32,7 +32,7 @@ ;; CHECK: [fuzz-exec] calling nn-u ;; CHECK-NEXT: [fuzz-exec] note result: nn-u => 2147483647 - (func "nn-u" (result i32) + (func $nn-u (export "nn-u") (result i32) (i31.get_u (ref.i31 (i32.const 0xffffffff) @@ -42,7 +42,7 @@ ;; CHECK: [fuzz-exec] calling nn-s ;; CHECK-NEXT: [fuzz-exec] note result: nn-s => -1 - (func "nn-s" (result i32) + (func $nn-s (export "nn-s") (result i32) (i31.get_s (ref.i31 (i32.const 0xffffffff) @@ -52,7 +52,7 @@ ;; CHECK: [fuzz-exec] calling zero-is-not-null ;; CHECK-NEXT: [fuzz-exec] note result: zero-is-not-null => 0 - (func "zero-is-not-null" (result i32) + (func $zero-is-not-null (export "zero-is-not-null") (result i32) (local $ref (ref null i31)) (local.set $ref (ref.i31 @@ -71,7 +71,7 @@ ;; CHECK: [fuzz-exec] calling trap ;; CHECK-NEXT: [trap null ref] - (func "trap" (result i32) + (func $trap (export "trap") (result i32) (i31.get_u (ref.null i31) ) diff --git a/test/lit/exec/intrinsics.wast b/test/lit/exec/intrinsics.wast index d53082a77bd..c8ae2864338 100644 --- a/test/lit/exec/intrinsics.wast +++ b/test/lit/exec/intrinsics.wast @@ -7,7 +7,7 @@ ;; CHECK: [fuzz-exec] calling get-ref ;; CHECK-NEXT: [fuzz-exec] note result: get-ref => 42 - (func "get-ref" (result i32) + (func $get-ref (export "get-ref") (result i32) (call $cwe (i32.const 41) (ref.func $add-one) @@ -21,4 +21,3 @@ ) ) ) - diff --git a/test/lit/exec/memory.grow.wast b/test/lit/exec/memory.grow.wast index 64d88bfc789..426f4b4c021 100644 --- a/test/lit/exec/memory.grow.wast +++ b/test/lit/exec/memory.grow.wast @@ -7,7 +7,7 @@ ;; CHECK: [fuzz-exec] calling grow_twice ;; CHECK-NEXT: [fuzz-exec] note result: grow_twice => 3 - (func "grow_twice" (result i32) + (func $grow_twice (export "grow_twice") (result i32) ;; The nested grow will increase the size from 1 to 3, and return the old ;; size, 1. Then the outer grow will grow by that amount 1, from 3 to 4. (memory.grow @@ -19,7 +19,7 @@ ;; CHECK: [fuzz-exec] calling measure ;; CHECK-NEXT: [fuzz-exec] note result: measure => 4 - (func "measure" (export "measure") (result i32) + (func $measure (export "measure") (result i32) ;; This should return the final size, 4. (memory.size) ) diff --git a/test/lit/exec/negative-zero.wast b/test/lit/exec/negative-zero.wast index 4a1e339cad3..2c45dbdfb9c 100644 --- a/test/lit/exec/negative-zero.wast +++ b/test/lit/exec/negative-zero.wast @@ -5,7 +5,7 @@ (module ;; CHECK: [fuzz-exec] calling min1 ;; CHECK-NEXT: [fuzz-exec] note result: min1 => -0 - (func "min1" (result f64) + (func $min1 (export "min1") (result f64) ;; This should return -0. (f64.min (f64.const 0) @@ -15,7 +15,7 @@ ;; CHECK: [fuzz-exec] calling min2 ;; CHECK-NEXT: [fuzz-exec] note result: min2 => -0 - (func "min2" (result f64) + (func $min2 (export "min2") (result f64) ;; Flipped arms; still -0. (f64.min (f64.const -0) @@ -25,7 +25,7 @@ ;; CHECK: [fuzz-exec] calling min1-f32 ;; CHECK-NEXT: [fuzz-exec] note result: min1-f32 => -0 - (func "min1-f32" (result f32) + (func $min1-f32 (export "min1-f32") (result f32) ;; As above, but f32 and not f64 (f32.min (f32.const 0) @@ -35,7 +35,7 @@ ;; CHECK: [fuzz-exec] calling min2-f32 ;; CHECK-NEXT: [fuzz-exec] note result: min2-f32 => -0 - (func "min2-f32" (result f32) + (func $min2-f32 (export "min2-f32") (result f32) ;; Flipped arms; still -0. (f32.min (f32.const -0) @@ -45,7 +45,7 @@ ;; CHECK: [fuzz-exec] calling max1 ;; CHECK-NEXT: [fuzz-exec] note result: max1 => 0 - (func "max1" (result f64) + (func $max1 (export "max1") (result f64) ;; This should return 0. (f64.max (f64.const 0) @@ -55,7 +55,7 @@ ;; CHECK: [fuzz-exec] calling max2 ;; CHECK-NEXT: [fuzz-exec] note result: max2 => 0 - (func "max2" (result f64) + (func $max2 (export "max2") (result f64) ;; Flipped arms; still 0. (f64.max (f64.const -0) @@ -65,7 +65,7 @@ ;; CHECK: [fuzz-exec] calling max1-f32 ;; CHECK-NEXT: [fuzz-exec] note result: max1-f32 => 0 - (func "max1-f32" (result f32) + (func $max1-f32 (export "max1-f32") (result f32) ;; As above, but f32 and not f64 (f32.max (f32.const 0) @@ -76,7 +76,7 @@ ;; CHECK: [fuzz-exec] calling max2-f32 ;; CHECK-NEXT: [fuzz-exec] note result: max2-f32 => 0 ;; CHECK-NEXT: warning: no passes specified, not doing any work - (func "max2-f32" (result f32) + (func $max2-f32 (export "max2-f32") (result f32) ;; Flipped arms; still 0. (f32.max (f32.const -0) diff --git a/test/lit/exec/no-compare-refs.wast b/test/lit/exec/no-compare-refs.wast index 95afa51dccc..bfa317a53d9 100644 --- a/test/lit/exec/no-compare-refs.wast +++ b/test/lit/exec/no-compare-refs.wast @@ -13,7 +13,7 @@ ;; signature pruning. The fuzzer should not complain about this. ;; CHECK: [fuzz-exec] calling return-ref ;; CHECK-NEXT: [fuzz-exec] note result: return-ref => funcref - (func "return-ref" (result funcref) + (func $return-ref (export "return-ref") (result funcref) (ref.func $no-use-param) ) ) diff --git a/test/lit/exec/non-nullable.wast b/test/lit/exec/non-nullable.wast index d443947c60b..da71d53ebeb 100644 --- a/test/lit/exec/non-nullable.wast +++ b/test/lit/exec/non-nullable.wast @@ -5,7 +5,7 @@ (module ;; CHECK: [fuzz-exec] calling get-ref ;; CHECK-NEXT: [trap fuzzer can only send defaultable parameters to exports] - (func "get-ref" (param $0 (ref any)) + (func $get-ref (export "get-ref") (param $0 (ref any)) (nop) ) ) diff --git a/test/lit/exec/read-nn-null.wast b/test/lit/exec/read-nn-null.wast index d726889695d..beb2c5c7ec9 100644 --- a/test/lit/exec/read-nn-null.wast +++ b/test/lit/exec/read-nn-null.wast @@ -30,6 +30,12 @@ (module (import "fuzzing-support" "log-i32" (func $log (param i32))) + ;; NORMAL: [fuzz-exec] calling foo + ;; NORMAL-NEXT: [LoggingExternalInterface logging 42] + ;; NORMAL-NEXT: [trap unreachable] + ;; TNH: [fuzz-exec] calling foo + ;; TNH-NEXT: [LoggingExternalInterface logging 42] + ;; TNH-NEXT: [trap unreachable] (func $foo (export "foo") (param $i i32) (result funcref) (local $ref (ref func)) (local.set $ref @@ -55,19 +61,11 @@ ) ) ) -;; NORMAL: [fuzz-exec] calling foo -;; NORMAL-NEXT: [LoggingExternalInterface logging 42] -;; NORMAL-NEXT: [trap unreachable] - ;; NORMAL: [fuzz-exec] calling foo ;; NORMAL-NEXT: [LoggingExternalInterface logging 42] ;; NORMAL-NEXT: [trap unreachable] ;; NORMAL-NEXT: [fuzz-exec] comparing foo -;; TNH: [fuzz-exec] calling foo -;; TNH-NEXT: [LoggingExternalInterface logging 42] -;; TNH-NEXT: [trap unreachable] - ;; TNH: [fuzz-exec] calling foo ;; TNH-NEXT: [LoggingExternalInterface logging 42] ;; TNH-NEXT: [trap unreachable] diff --git a/test/lit/exec/strings.wast b/test/lit/exec/strings.wast index 320fe5de57c..5460abd2ab0 100644 --- a/test/lit/exec/strings.wast +++ b/test/lit/exec/strings.wast @@ -7,7 +7,7 @@ ;; CHECK: [fuzz-exec] calling new_wtf16_array ;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello") - (func "new_wtf16_array" (result stringref) + (func $new_wtf16_array (export "new_wtf16_array") (result stringref) (string.new_wtf16_array (array.new_fixed $array16 5 (i32.const 104) ;; h @@ -23,13 +23,13 @@ ;; CHECK: [fuzz-exec] calling const ;; CHECK-NEXT: [fuzz-exec] note result: const => string("world") - (func "const" (result stringref) + (func $const (export "const") (result stringref) (string.const "world") ) ;; CHECK: [fuzz-exec] calling eq.1 ;; CHECK-NEXT: [fuzz-exec] note result: eq.1 => 0 - (func "eq.1" (result i32) + (func $eq.1 (export "eq.1") (result i32) (string.eq (string.const "hello") (string.const "world") @@ -38,7 +38,7 @@ ;; CHECK: [fuzz-exec] calling eq.2 ;; CHECK-NEXT: [fuzz-exec] note result: eq.2 => 1 - (func "eq.2" (result i32) + (func $eq.2 (export "eq.2") (result i32) (string.eq (string.const "hello") (string.const "hello") @@ -47,7 +47,7 @@ ;; CHECK: [fuzz-exec] calling eq.3 ;; CHECK-NEXT: [fuzz-exec] note result: eq.3 => 0 - (func "eq.3" (result i32) + (func $eq.3 (export "eq.3") (result i32) (string.eq (string.const "hello") (ref.null string) @@ -56,7 +56,7 @@ ;; CHECK: [fuzz-exec] calling eq.4 ;; CHECK-NEXT: [fuzz-exec] note result: eq.4 => 0 - (func "eq.4" (result i32) + (func $eq.4 (export "eq.4") (result i32) (string.eq (ref.null string) (string.const "world") @@ -65,7 +65,7 @@ ;; CHECK: [fuzz-exec] calling eq.5 ;; CHECK-NEXT: [fuzz-exec] note result: eq.5 => 1 - (func "eq.5" (result i32) + (func $eq.5 (export "eq.5") (result i32) (string.eq (ref.null string) (ref.null string) @@ -74,7 +74,7 @@ ;; CHECK: [fuzz-exec] calling compare.1 ;; CHECK-NEXT: [trap null ref] - (func "compare.1" (result i32) + (func $compare.1 (export "compare.1") (result i32) (string.compare (string.const "hello") (ref.null string) @@ -83,7 +83,7 @@ ;; CHECK: [fuzz-exec] calling compare.2 ;; CHECK-NEXT: [trap null ref] - (func "compare.2" (result i32) + (func $compare.2 (export "compare.2") (result i32) (string.compare (ref.null string) (string.const "world") @@ -92,7 +92,7 @@ ;; CHECK: [fuzz-exec] calling compare.3 ;; CHECK-NEXT: [trap null ref] - (func "compare.3" (result i32) + (func $compare.3 (export "compare.3") (result i32) (string.compare (ref.null string) (ref.null string) @@ -101,7 +101,7 @@ ;; CHECK: [fuzz-exec] calling compare.4 ;; CHECK-NEXT: [fuzz-exec] note result: compare.4 => 0 - (func "compare.4" (result i32) + (func $compare.4 (export "compare.4") (result i32) (string.compare (string.const "hello") (string.const "hello") @@ -110,7 +110,7 @@ ;; CHECK: [fuzz-exec] calling compare.5 ;; CHECK-NEXT: [fuzz-exec] note result: compare.5 => -1 - (func "compare.5" (result i32) + (func $compare.5 (export "compare.5") (result i32) (string.compare (string.const "hello") (string.const "hezlo") @@ -119,7 +119,7 @@ ;; CHECK: [fuzz-exec] calling compare.6 ;; CHECK-NEXT: [fuzz-exec] note result: compare.6 => 1 - (func "compare.6" (result i32) + (func $compare.6 (export "compare.6") (result i32) (string.compare (string.const "hezlo") (string.const "hello") @@ -128,7 +128,7 @@ ;; CHECK: [fuzz-exec] calling compare.7 ;; CHECK-NEXT: [fuzz-exec] note result: compare.7 => -1 - (func "compare.7" (result i32) + (func $compare.7 (export "compare.7") (result i32) (string.compare (string.const "he") (string.const "hello") @@ -137,7 +137,7 @@ ;; CHECK: [fuzz-exec] calling compare.8 ;; CHECK-NEXT: [fuzz-exec] note result: compare.8 => 1 - (func "compare.8" (result i32) + (func $compare.8 (export "compare.8") (result i32) (string.compare (string.const "hello") (string.const "he") @@ -146,7 +146,7 @@ ;; CHECK: [fuzz-exec] calling compare.9 ;; CHECK-NEXT: [fuzz-exec] note result: compare.9 => 1 - (func "compare.9" (result i32) + (func $compare.9 (export "compare.9") (result i32) (string.compare (string.const "hf") (string.const "hello") @@ -155,7 +155,7 @@ ;; CHECK: [fuzz-exec] calling compare.10 ;; CHECK-NEXT: [fuzz-exec] note result: compare.10 => -1 - (func "compare.10" (result i32) + (func $compare.10 (export "compare.10") (result i32) (string.compare (string.const "hello") (string.const "hf") diff --git a/test/lit/merge/table_elem.wat b/test/lit/merge/table_elem.wat index c7505d0eec8..8177cd75d79 100644 --- a/test/lit/merge/table_elem.wat +++ b/test/lit/merge/table_elem.wat @@ -29,7 +29,39 @@ ;; CHECK: (elem $b (table $bar) (i32.const 0) func) (elem $b (table $bar) (i32.const 0) func) - (func "keepalive2" + ;; CHECK: (elem $a_2 (table $foo_2) (i32.const 0) func) + + ;; CHECK: (elem $b_2 (table $other) (i32.const 0) func) + + ;; CHECK: (export "keepalive2" (func $keepalive2)) + + ;; CHECK: (export "keepalive2_1" (func $keepalive2_1)) + + ;; CHECK: (func $keepalive2 (type $1) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (table.get $foo + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (table.get $bar + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (array.new_elem $vec $a + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (array.new_elem $vec $b + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $keepalive2 (export "keepalive2") (drop (table.get $foo (i32.const 1) @@ -55,40 +87,7 @@ ) ) ) -;; CHECK: (elem $a_2 (table $foo_2) (i32.const 0) func) - -;; CHECK: (elem $b_2 (table $other) (i32.const 0) func) - -;; CHECK: (export "keepalive2" (func $0)) - -;; CHECK: (export "keepalive2_1" (func $0_1)) - -;; CHECK: (func $0 (type $1) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (table.get $foo -;; CHECK-NEXT: (i32.const 1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (table.get $bar -;; CHECK-NEXT: (i32.const 1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (array.new_elem $vec $a -;; CHECK-NEXT: (i32.const 1) -;; CHECK-NEXT: (i32.const 2) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (array.new_elem $vec $b -;; CHECK-NEXT: (i32.const 3) -;; CHECK-NEXT: (i32.const 4) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) - -;; CHECK: (func $0_1 (type $1) +;; CHECK: (func $keepalive2_1 (type $1) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (table.get $foo_2 ;; CHECK-NEXT: (i32.const 1) diff --git a/test/lit/merge/table_elem.wat.second b/test/lit/merge/table_elem.wat.second index 7aa960c7f2b..c186e6b16c6 100644 --- a/test/lit/merge/table_elem.wat.second +++ b/test/lit/merge/table_elem.wat.second @@ -9,7 +9,7 @@ (elem $b (table $other) (i32.const 0) func) - (func "keepalive2" + (func $keepalive2 (export "keepalive2") (drop (table.get $foo (i32.const 1) diff --git a/test/lit/passes/O1.wast b/test/lit/passes/O1.wast index 516c9b2ee59..8ffc2930148 100644 --- a/test/lit/passes/O1.wast +++ b/test/lit/passes/O1.wast @@ -9,7 +9,17 @@ ;; CHECK: (memory $0 1 1) (memory $0 1 1) (global $global$0 (mut i32) (i32.const 10)) - (func "foo" (result i32) + ;; CHECK: (export "foo" (func $foo)) + + ;; CHECK: (func $foo (result i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.load align=1 + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $foo (export "foo") (result i32) (i32.load offset=4 align=1 (i32.and (block $label$1 (result i32) @@ -31,13 +41,3 @@ ) -;; CHECK: (export "foo" (func $0)) - -;; CHECK: (func $0 (result i32) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (i32.const 0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.load align=1 -;; CHECK-NEXT: (i32.const 4) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) diff --git a/test/lit/passes/O1_skip.wast b/test/lit/passes/O1_skip.wast index d4eef7c843e..2cefecdcf98 100644 --- a/test/lit/passes/O1_skip.wast +++ b/test/lit/passes/O1_skip.wast @@ -14,7 +14,7 @@ ;; CHECK: (import "a" "b" (func $log (param i32 i32))) (import "a" "b" (func $log (param i32 i32))) - (func "foo" (param $p i32) + (func $foo (export "foo") (param $p i32) ;; The locals $x and $y can be coalesced into a single local, but as we do not ;; run that pass, they will not be. Other minor optimizations will occur here, ;; such as using a tee. @@ -44,9 +44,9 @@ ) ) ) -;; CHECK: (export "foo" (func $0)) +;; CHECK: (export "foo" (func $foo)) -;; CHECK: (func $0 (; has Stack IR ;) (param $p i32) +;; CHECK: (func $foo (; has Stack IR ;) (param $p i32) ;; CHECK-NEXT: (local $x i32) ;; CHECK-NEXT: (local $y i32) ;; CHECK-NEXT: (call $log diff --git a/test/lit/passes/O3_Oz.wast b/test/lit/passes/O3_Oz.wast index 4dca886acaa..48345663e65 100644 --- a/test/lit/passes/O3_Oz.wast +++ b/test/lit/passes/O3_Oz.wast @@ -10,7 +10,22 @@ ) ) - (func "export" (param $x i32) (result i32) + ;; CHECK: (type $0 (func (param i32) (result i32))) + + ;; CHECK: (export "export" (func $export)) + + ;; CHECK: (func $export (; has Stack IR ;) (param $0 i32) (result i32) + ;; CHECK-NEXT: (i32.add + ;; CHECK-NEXT: (local.tee $0 + ;; CHECK-NEXT: (i32.add + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $export (export "export") (param $x i32) (result i32) ;; $inline.me is called twice, so we do not always inline it like called- ;; once functions are. -Oz is too cautious to inline such things that may ;; end up increasing total code size, but we are running -O3 -Oz here and so @@ -28,18 +43,3 @@ ) ) ) -;; CHECK: (type $0 (func (param i32) (result i32))) - -;; CHECK: (export "export" (func $1)) - -;; CHECK: (func $1 (; has Stack IR ;) (param $0 i32) (result i32) -;; CHECK-NEXT: (i32.add -;; CHECK-NEXT: (local.tee $0 -;; CHECK-NEXT: (i32.add -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: (i32.const 2) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) diff --git a/test/lit/passes/O_fast-math.wast b/test/lit/passes/O_fast-math.wast index bff7553a344..722f44a05c4 100644 --- a/test/lit/passes/O_fast-math.wast +++ b/test/lit/passes/O_fast-math.wast @@ -5,73 +5,129 @@ ;; with fast-math we can optimize some of these patterns (module - (func "div" (result f32) + ;; CHECK: (type $0 (func (result f32))) + + ;; CHECK: (type $1 (func (param f32) (result f32))) + + ;; CHECK: (type $2 (func (param f64) (result f64))) + + ;; CHECK: (export "div" (func $div)) + + ;; CHECK: (export "mul1" (func $mul1)) + + ;; CHECK: (export "mul2" (func $mul2)) + + ;; CHECK: (export "add1" (func $mul1)) + + ;; CHECK: (export "add2" (func $mul2)) + + ;; CHECK: (export "add3" (func $mul2)) + + ;; CHECK: (export "add4" (func $mul2)) + + ;; CHECK: (export "sub1" (func $mul1)) + + ;; CHECK: (export "sub2" (func $mul2)) + + ;; CHECK: (export "mul_neg_one1" (func $mul_neg_one1)) + + ;; CHECK: (export "mul_neg_one2" (func $mul_neg_one2)) + + ;; CHECK: (export "abs_sub_zero1" (func $abs_sub_zero1)) + + ;; CHECK: (export "abs_sub_zero2" (func $abs_sub_zero2)) + + ;; CHECK: (func $div (; has Stack IR ;) (result f32) + ;; CHECK-NEXT: (f32.const -nan:0x23017a) + ;; CHECK-NEXT: ) + (func $div (export "div") (result f32) (f32.div (f32.const -nan:0x23017a) (f32.const 1) ) ) - (func "mul1" (result f32) + ;; CHECK: (func $mul1 (; has Stack IR ;) (result f32) + ;; CHECK-NEXT: (f32.const -nan:0x34546d) + ;; CHECK-NEXT: ) + (func $mul1 (export "mul1") (result f32) (f32.mul (f32.const -nan:0x34546d) (f32.const 1) ) ) - (func "mul2" (result f32) + ;; CHECK: (func $mul2 (; has Stack IR ;) (result f32) + ;; CHECK-NEXT: (f32.const nan:0x400000) + ;; CHECK-NEXT: ) + (func $mul2 (export "mul2") (result f32) (f32.mul (f32.const 1) (f32.const -nan:0x34546d) ) ) - (func "add1" (result f32) + (func $add1 (export "add1") (result f32) (f32.add (f32.const -nan:0x34546d) (f32.const -0) ) ) - (func "add2" (result f32) + (func $add2 (export "add2") (result f32) (f32.add (f32.const -0) (f32.const -nan:0x34546d) ) ) - (func "add3" (result f32) + (func $add3 (export "add3") (result f32) (f32.add (f32.const -nan:0x34546d) (f32.const 0) ) ) - (func "add4" (result f32) + (func $add4 (export "add4") (result f32) (f32.add (f32.const 0) (f32.const -nan:0x34546d) ) ) - (func "sub1" (result f32) + (func $sub1 (export "sub1") (result f32) (f32.sub (f32.const -nan:0x34546d) (f32.const 0) ) ) - (func "sub2" (result f32) + (func $sub2 (export "sub2") (result f32) (f32.sub (f32.const -nan:0x34546d) (f32.const -0) ) ) - (func "mul_neg_one1" (param $x f32) (result f32) + ;; CHECK: (func $mul_neg_one1 (; has Stack IR ;) (param $0 f32) (result f32) + ;; CHECK-NEXT: (f32.neg + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $mul_neg_one1 (export "mul_neg_one1") (param $x f32) (result f32) (f32.mul (local.get $x) (f32.const -1) ) ) - (func "mul_neg_one2" (param $x f64) (result f64) + ;; CHECK: (func $mul_neg_one2 (; has Stack IR ;) (param $0 f64) (result f64) + ;; CHECK-NEXT: (f64.neg + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $mul_neg_one2 (export "mul_neg_one2") (param $x f64) (result f64) (f64.mul (local.get $x) (f64.const -1) ) ) - (func "abs_sub_zero1" (param $x f32) (result f32) + ;; CHECK: (func $abs_sub_zero1 (; has Stack IR ;) (param $0 f32) (result f32) + ;; CHECK-NEXT: (f32.abs + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $abs_sub_zero1 (export "abs_sub_zero1") (param $x f32) (result f32) ;; abs(0 - x) ==> abs(x) (f32.abs (f32.sub @@ -80,7 +136,12 @@ ) ) ) - (func "abs_sub_zero2" (param $x f64) (result f64) + ;; CHECK: (func $abs_sub_zero2 (; has Stack IR ;) (param $0 f64) (result f64) + ;; CHECK-NEXT: (f64.abs + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $abs_sub_zero2 (export "abs_sub_zero2") (param $x f64) (result f64) ;; abs(0 - x) ==> abs(x) (f64.abs (f64.sub @@ -90,70 +151,3 @@ ) ) ) -;; CHECK: (type $0 (func (result f32))) - -;; CHECK: (type $1 (func (param f32) (result f32))) - -;; CHECK: (type $2 (func (param f64) (result f64))) - -;; CHECK: (export "div" (func $0)) - -;; CHECK: (export "mul1" (func $1)) - -;; CHECK: (export "mul2" (func $2)) - -;; CHECK: (export "add1" (func $1)) - -;; CHECK: (export "add2" (func $2)) - -;; CHECK: (export "add3" (func $2)) - -;; CHECK: (export "add4" (func $2)) - -;; CHECK: (export "sub1" (func $1)) - -;; CHECK: (export "sub2" (func $2)) - -;; CHECK: (export "mul_neg_one1" (func $9)) - -;; CHECK: (export "mul_neg_one2" (func $10)) - -;; CHECK: (export "abs_sub_zero1" (func $11)) - -;; CHECK: (export "abs_sub_zero2" (func $12)) - -;; CHECK: (func $0 (; has Stack IR ;) (result f32) -;; CHECK-NEXT: (f32.const -nan:0x23017a) -;; CHECK-NEXT: ) - -;; CHECK: (func $1 (; has Stack IR ;) (result f32) -;; CHECK-NEXT: (f32.const -nan:0x34546d) -;; CHECK-NEXT: ) - -;; CHECK: (func $2 (; has Stack IR ;) (result f32) -;; CHECK-NEXT: (f32.const nan:0x400000) -;; CHECK-NEXT: ) - -;; CHECK: (func $9 (; has Stack IR ;) (param $0 f32) (result f32) -;; CHECK-NEXT: (f32.neg -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) - -;; CHECK: (func $10 (; has Stack IR ;) (param $0 f64) (result f64) -;; CHECK-NEXT: (f64.neg -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) - -;; CHECK: (func $11 (; has Stack IR ;) (param $0 f32) (result f32) -;; CHECK-NEXT: (f32.abs -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) - -;; CHECK: (func $12 (; has Stack IR ;) (param $0 f64) (result f64) -;; CHECK-NEXT: (f64.abs -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) diff --git a/test/lit/passes/dae-gc-refine-params.wast b/test/lit/passes/dae-gc-refine-params.wast index 2f55e401249..51e97456c05 100644 --- a/test/lit/passes/dae-gc-refine-params.wast +++ b/test/lit/passes/dae-gc-refine-params.wast @@ -21,12 +21,12 @@ ;; CHECK: (func $call-various-params-no (type $0) ;; CHECK-NEXT: (call $various-params-no - ;; CHECK-NEXT: (call $get_{}) - ;; CHECK-NEXT: (call $get_{i32}) + ;; CHECK-NEXT: (call $"get_{}") + ;; CHECK-NEXT: (call $"get_{i32}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $various-params-no - ;; CHECK-NEXT: (call $get_{i32}) - ;; CHECK-NEXT: (call $get_{f64}) + ;; CHECK-NEXT: (call $"get_{i32}") + ;; CHECK-NEXT: (call $"get_{f64}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $call-various-params-no @@ -59,35 +59,26 @@ (drop (local.get $y)) ) - ;; CHECK: (func $get_{} (type $8) (result (ref null ${})) - ;; CHECK-NEXT: (unreachable) - ;; CHECK-NEXT: ) (func $get_{} (result (ref null ${})) (unreachable) ) - ;; CHECK: (func $get_{i32} (type $5) (result (ref null ${i32})) - ;; CHECK-NEXT: (unreachable) - ;; CHECK-NEXT: ) (func $get_{i32} (result (ref null ${i32})) (unreachable) ) - ;; CHECK: (func $get_{f64} (type $10) (result (ref null ${f64})) - ;; CHECK-NEXT: (unreachable) - ;; CHECK-NEXT: ) (func $get_{f64} (result (ref null ${f64})) (unreachable) ) ;; CHECK: (func $call-various-params-yes (type $0) ;; CHECK-NEXT: (call $various-params-yes - ;; CHECK-NEXT: (call $get_null_{i32}) + ;; CHECK-NEXT: (call $"get_null_{i32}") ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: (call $get_null_{i32}) + ;; CHECK-NEXT: (call $"get_null_{i32}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $various-params-yes - ;; CHECK-NEXT: (call $get_null_{i32}) + ;; CHECK-NEXT: (call $"get_null_{i32}") ;; CHECK-NEXT: (i32.const 1) - ;; CHECK-NEXT: (call $get_null_{i32_i64}) + ;; CHECK-NEXT: (call $"get_null_{i32_i64}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $call-various-params-yes @@ -127,12 +118,12 @@ ;; CHECK: (func $call-various-params-set (type $0) ;; CHECK-NEXT: (call $various-params-set - ;; CHECK-NEXT: (call $get_null_{i32}) - ;; CHECK-NEXT: (call $get_null_{i32}) + ;; CHECK-NEXT: (call $"get_null_{i32}") + ;; CHECK-NEXT: (call $"get_null_{i32}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $various-params-set - ;; CHECK-NEXT: (call $get_null_{i32}) - ;; CHECK-NEXT: (call $get_null_{i32_i64}) + ;; CHECK-NEXT: (call $"get_null_{i32}") + ;; CHECK-NEXT: (call $"get_null_{i32_i64}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $call-various-params-set @@ -169,7 +160,7 @@ ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $y - ;; CHECK-NEXT: (call $get_null_{i32_i64}) + ;; CHECK-NEXT: (call $"get_null_{i32_i64}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $y) @@ -198,7 +189,7 @@ ;; CHECK: (func $call-various-params-tee (type $0) ;; CHECK-NEXT: (call $various-params-tee - ;; CHECK-NEXT: (call $get_null_{i32}) + ;; CHECK-NEXT: (call $"get_null_{i32}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $call-various-params-tee @@ -214,7 +205,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref null ${i32})) ;; CHECK-NEXT: (local.tee $x - ;; CHECK-NEXT: (call $get_null_{i32_i64}) + ;; CHECK-NEXT: (call $"get_null_{i32_i64}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -237,7 +228,7 @@ ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (call $get_null_{i32}) + ;; CHECK-NEXT: (call $"get_null_{i32}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $various-params-null ;; CHECK-NEXT: (ref.as_non_null @@ -288,10 +279,10 @@ ;; CHECK: (func $call-various-params-middle (type $0) ;; CHECK-NEXT: (call $various-params-middle - ;; CHECK-NEXT: (call $get_null_{i32_i64}) + ;; CHECK-NEXT: (call $"get_null_{i32_i64}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $various-params-middle - ;; CHECK-NEXT: (call $get_null_{i32_f32}) + ;; CHECK-NEXT: (call $"get_null_{i32_f32}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $call-various-params-middle @@ -399,13 +390,6 @@ (drop (local.get $x)) ) - ;; CHECK: (func $get_null_{i32} (type $5) (result (ref null ${i32})) - ;; CHECK-NEXT: (select (result (ref null ${i32})) - ;; CHECK-NEXT: (ref.null none) - ;; CHECK-NEXT: (struct.new_default ${i32}) - ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) (func $get_null_{i32} (result (ref null ${i32})) ;; Helper function that returns a null value of ${i32}. We use this instead of ;; a direct ref.null because those can be rewritten by LUBFinder. @@ -416,13 +400,6 @@ ) ) - ;; CHECK: (func $get_null_{i32_i64} (type $16) (result (ref null ${i32_i64})) - ;; CHECK-NEXT: (select (result (ref null ${i32_i64})) - ;; CHECK-NEXT: (ref.null none) - ;; CHECK-NEXT: (struct.new_default ${i32_i64}) - ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) (func $get_null_{i32_i64} (result (ref null ${i32_i64})) (select (ref.null none) @@ -431,13 +408,6 @@ ) ) - ;; CHECK: (func $get_null_{i32_f32} (type $17) (result (ref null ${i32_f32})) - ;; CHECK-NEXT: (select (result (ref null ${i32_f32})) - ;; CHECK-NEXT: (ref.null none) - ;; CHECK-NEXT: (struct.new_default ${i32_f32}) - ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) (func $get_null_{i32_f32} (result (ref null ${i32_f32})) (select (ref.null none) diff --git a/test/lit/passes/dae-gc-refine-return.wast b/test/lit/passes/dae-gc-refine-return.wast index 806683a628b..aa474d7f393 100644 --- a/test/lit/passes/dae-gc-refine-return.wast +++ b/test/lit/passes/dae-gc-refine-return.wast @@ -395,9 +395,9 @@ (unreachable) ) ;; CHECK: (func $tail-caller-call_ref-yes (type $return_{}) (result (ref ${})) - ;; CHECK-NEXT: (local $return_{} (ref null $return_{})) + ;; CHECK-NEXT: (local $"return_{}" (ref null $return_{})) ;; CHECK-NEXT: (return_call_ref $return_{} - ;; CHECK-NEXT: (local.get $return_{}) + ;; CHECK-NEXT: (local.get $"return_{}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $tail-caller-call_ref-yes (result anyref) @@ -407,7 +407,7 @@ ) ;; CHECK: (func $tail-caller-call_ref-no (type $2) (result anyref) ;; CHECK-NEXT: (local $any anyref) - ;; CHECK-NEXT: (local $return_{} (ref null $return_{})) + ;; CHECK-NEXT: (local $"return_{}" (ref null $return_{})) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (return @@ -415,7 +415,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return_call_ref $return_{} - ;; CHECK-NEXT: (local.get $return_{}) + ;; CHECK-NEXT: (local.get $"return_{}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $tail-caller-call_ref-no (result anyref) diff --git a/test/lit/passes/dae_all-features.wast b/test/lit/passes/dae_all-features.wast index dee38f64638..17626c953f8 100644 --- a/test/lit/passes/dae_all-features.wast +++ b/test/lit/passes/dae_all-features.wast @@ -361,21 +361,20 @@ ) ) (module ;; both operations at once: remove params and return value - (func "a" + ;; CHECK: (type $0 (func)) + + ;; CHECK: (export "a" (func $a)) + + ;; CHECK: (func $a (type $0) + ;; CHECK-NEXT: (call $b) + ;; CHECK-NEXT: ) + (func $a (export "a") (drop (call $b (i32.const 1) ) ) ) - ;; CHECK: (type $0 (func)) - - ;; CHECK: (export "a" (func $0)) - - ;; CHECK: (func $0 (type $0) - ;; CHECK-NEXT: (call $b) - ;; CHECK-NEXT: ) - ;; CHECK: (func $b (type $0) ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (drop @@ -467,7 +466,7 @@ ;; CHECK: (elem declare func $0) - ;; CHECK: (export "export" (func $1)) + ;; CHECK: (export "export" (func $export)) ;; CHECK: (func $0 (type $0) (param $0 funcref) (param $1 i32) (param $2 f64) (result i64) ;; CHECK-NEXT: (nop) @@ -477,15 +476,15 @@ (nop) (unreachable) ) - (func "export" (param $0 f32) (result funcref) + ;; CHECK: (func $export (type $1) (param $0 f32) (result funcref) + ;; CHECK-NEXT: (ref.func $0) + ;; CHECK-NEXT: ) + (func $export (export "export") (param $0 f32) (result funcref) ;; a ref.func should prevent us from changing the type of a function, as it ;; may escape (ref.func $0) ) ) -;; CHECK: (func $1 (type $1) (param $0 f32) (result funcref) -;; CHECK-NEXT: (ref.func $0) -;; CHECK-NEXT: ) (module ;; CHECK: (type $i64 (func (param i64))) (type $i64 (func (param i64))) diff --git a/test/lit/passes/flatten_all-features.wast b/test/lit/passes/flatten_all-features.wast index 5ae10ac1469..3ce8496863e 100644 --- a/test/lit/passes/flatten_all-features.wast +++ b/test/lit/passes/flatten_all-features.wast @@ -3481,7 +3481,7 @@ ;; CHECK: (type $1 (func (result i32))) - ;; CHECK: (export "test" (func $1)) + ;; CHECK: (export "test" (func $test)) ;; CHECK: (func $0 (type $0) (param $0 i64) (param $1 f32) ;; CHECK-NEXT: (nop) @@ -3489,7 +3489,18 @@ (func $0 (param $0 i64) (param $1 f32) (nop) ) - (func "test" (result i32) + ;; CHECK: (func $test (type $1) (result i32) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: (return + ;; CHECK-NEXT: (i32.const -111) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $0 + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $test (export "test") (result i32) (call $0 (unreachable) ;; the unreachable should be handled properly, and not be ;; reordered with the return @@ -3501,17 +3512,6 @@ ) ;; non-nullable temp vars we add must be handled properly, as non-nullable ;; locals are not allowed -;; CHECK: (func $1 (type $1) (result i32) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: (return -;; CHECK-NEXT: (i32.const -111) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (call $0 -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) (module (type $none_=>_none (func)) ;; CHECK: (type $0 (func (result funcref))) diff --git a/test/lit/passes/flatten_dfo_O3_enable-threads.wast b/test/lit/passes/flatten_dfo_O3_enable-threads.wast index 7aa7df592d7..55bf54dc911 100644 --- a/test/lit/passes/flatten_dfo_O3_enable-threads.wast +++ b/test/lit/passes/flatten_dfo_O3_enable-threads.wast @@ -16,7 +16,29 @@ ;; CHECK: (memory $0 (shared 1 1)) (memory $0 (shared 1 1)) - (func "one" + ;; CHECK: (export "one" (func $one)) + + ;; CHECK: (export "two" (func $two)) + + ;; CHECK: (export "use-var" (func $use-var)) + + ;; CHECK: (export "bad1" (func $bad1)) + + ;; CHECK: (export "only-dfo" (func $only-dfo)) + + ;; CHECK: (export "dfo-tee-get" (func $dfo-tee-get)) + + ;; CHECK: (func $one (; has Stack IR ;) + ;; CHECK-NEXT: (block $label$3 + ;; CHECK-NEXT: (br_if $label$3 + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (i32.const 3060) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $one (export "one") (loop $label$2 (br_if $label$2 (block $label$3 (result i32) @@ -34,7 +56,10 @@ ) (unreachable) ) - (func "two" (param $var$0 i32) (param $var$1 i32) (result i32) + ;; CHECK: (func $two (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + (func $two (export "two") (param $var$0 i32) (param $var$1 i32) (result i32) (nop) (nop) (nop) @@ -81,7 +106,15 @@ (nop) (i32.const 0) ) - (func "use-var" (param $var$0 i64) (param $var$1 i32) (result f64) + ;; CHECK: (func $use-var (; has Stack IR ;) (param $0 i64) (param $1 i32) (result f64) + ;; CHECK-NEXT: (loop $label$8 + ;; CHECK-NEXT: (br_if $label$8 + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $use-var (export "use-var") (param $var$0 i64) (param $var$1 i32) (result f64) (local $var$2 i32) (block $label$1 (br_table $label$1 $label$1 $label$1 $label$1 $label$1 $label$1 $label$1 $label$1 $label$1 $label$1 @@ -133,7 +166,13 @@ ) (unreachable) ) - (func "bad1" + ;; CHECK: (func $bad1 (; has Stack IR ;) + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (i32.const -16384) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $bad1 (export "bad1") (local $var$2 i32) (local $var$4 i32) (block $label$1 @@ -175,7 +214,13 @@ ) ) ) - (func "only-dfo" (param $var$0 f64) (result f64) + ;; CHECK: (func $only-dfo (; has Stack IR ;) (param $0 f64) (result f64) + ;; CHECK-NEXT: (local $1 i32) + ;; CHECK-NEXT: (loop $label$1 + ;; CHECK-NEXT: (br $label$1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $only-dfo (export "only-dfo") (param $var$0 f64) (result f64) (local $var$1 i32) (local $var$2 i32) (loop $label$1 @@ -199,7 +244,10 @@ (br $label$1) ) ) - (func "dfo-tee-get" (result i32) + ;; CHECK: (func $dfo-tee-get (; has Stack IR ;) (result i32) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + (func $dfo-tee-get (export "dfo-tee-get") (result i32) (local $0 i32) (if (result i32) (local.tee $0 @@ -217,56 +265,3 @@ ) ) -;; CHECK: (export "one" (func $0)) - -;; CHECK: (export "two" (func $1)) - -;; CHECK: (export "use-var" (func $2)) - -;; CHECK: (export "bad1" (func $3)) - -;; CHECK: (export "only-dfo" (func $4)) - -;; CHECK: (export "dfo-tee-get" (func $5)) - -;; CHECK: (func $0 (; has Stack IR ;) -;; CHECK-NEXT: (block $label$3 -;; CHECK-NEXT: (br_if $label$3 -;; CHECK-NEXT: (i32.load -;; CHECK-NEXT: (i32.const 3060) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) - -;; CHECK: (func $1 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) -;; CHECK-NEXT: (i32.const 0) -;; CHECK-NEXT: ) - -;; CHECK: (func $2 (; has Stack IR ;) (param $0 i64) (param $1 i32) (result f64) -;; CHECK-NEXT: (loop $label$8 -;; CHECK-NEXT: (br_if $label$8 -;; CHECK-NEXT: (local.get $1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) - -;; CHECK: (func $3 (; has Stack IR ;) -;; CHECK-NEXT: (i32.store -;; CHECK-NEXT: (i32.const 1) -;; CHECK-NEXT: (i32.const -16384) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) - -;; CHECK: (func $4 (; has Stack IR ;) (param $0 f64) (result f64) -;; CHECK-NEXT: (local $1 i32) -;; CHECK-NEXT: (loop $label$1 -;; CHECK-NEXT: (br $label$1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) - -;; CHECK: (func $5 (; has Stack IR ;) (result i32) -;; CHECK-NEXT: (i32.const 1) -;; CHECK-NEXT: ) diff --git a/test/lit/passes/flatten_i64-to-i32-lowering.wast b/test/lit/passes/flatten_i64-to-i32-lowering.wast index ade1d1e58bd..16ebaf8829b 100644 --- a/test/lit/passes/flatten_i64-to-i32-lowering.wast +++ b/test/lit/passes/flatten_i64-to-i32-lowering.wast @@ -472,19 +472,96 @@ ;; CHECK: (global $i64toi32_i32$HIGH_BITS (mut i32) (i32.const 0)) - ;; CHECK: (export "exp" (func $1)) + ;; CHECK: (export "exp" (func $exp)) - ;; CHECK: (export "unreach" (func $2)) + ;; CHECK: (export "unreach" (func $unreach)) ;; CHECK: (func $call (type $1) (param $0 i32) (param $0$hi i32) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $call (param i64)) - (func "exp" + ;; CHECK: (func $exp (type $0) + ;; CHECK-NEXT: (local $0 i32) + ;; CHECK-NEXT: (local $0$hi i32) + ;; CHECK-NEXT: (local $i64toi32_i32$0 i32) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (local.set $0 + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (local.set $i64toi32_i32$0 + ;; CHECK-NEXT: (global.get $f$hi) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.get $f) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $0$hi + ;; CHECK-NEXT: (local.get $i64toi32_i32$0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $call + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (local.set $i64toi32_i32$0 + ;; CHECK-NEXT: (local.get $0$hi) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $i64toi32_i32$0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (global.set $f + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (local.set $i64toi32_i32$0 + ;; CHECK-NEXT: (i32.const 287454020) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 1432778632) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.set $f$hi + ;; CHECK-NEXT: (local.get $i64toi32_i32$0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $exp (export "exp") (call $call (global.get $f)) (global.set $f (i64.const 0x1122334455667788)) ) - (func "unreach" + ;; CHECK: (func $unreach (type $0) + ;; CHECK-NEXT: (local $0 i32) + ;; CHECK-NEXT: (local $0$hi i32) + ;; CHECK-NEXT: (local $1 i32) + ;; CHECK-NEXT: (local $1$hi i32) + ;; CHECK-NEXT: (local $i64toi32_i32$0 i32) + ;; CHECK-NEXT: (block $label$1 + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (local.set $1 + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (local.set $i64toi32_i32$0 + ;; CHECK-NEXT: (local.get $0$hi) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $1$hi + ;; CHECK-NEXT: (local.get $i64toi32_i32$0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (global.set $f + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (local.set $i64toi32_i32$0 + ;; CHECK-NEXT: (local.get $1$hi) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.set $f$hi + ;; CHECK-NEXT: (local.get $i64toi32_i32$0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $unreach (export "unreach") (global.set $f (block $label$1 (result i64) (unreachable) @@ -492,84 +569,6 @@ ) ) ) -;; CHECK: (func $1 (type $0) -;; CHECK-NEXT: (local $0 i32) -;; CHECK-NEXT: (local $0$hi i32) -;; CHECK-NEXT: (local $i64toi32_i32$0 i32) -;; CHECK-NEXT: (block -;; CHECK-NEXT: (local.set $0 -;; CHECK-NEXT: (block (result i32) -;; CHECK-NEXT: (local.set $i64toi32_i32$0 -;; CHECK-NEXT: (global.get $f$hi) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.get $f) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.set $0$hi -;; CHECK-NEXT: (local.get $i64toi32_i32$0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (call $call -;; CHECK-NEXT: (block (result i32) -;; CHECK-NEXT: (local.set $i64toi32_i32$0 -;; CHECK-NEXT: (local.get $0$hi) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.get $i64toi32_i32$0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (block -;; CHECK-NEXT: (global.set $f -;; CHECK-NEXT: (block (result i32) -;; CHECK-NEXT: (local.set $i64toi32_i32$0 -;; CHECK-NEXT: (i32.const 287454020) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.const 1432778632) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.set $f$hi -;; CHECK-NEXT: (local.get $i64toi32_i32$0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) - -;; CHECK: (func $2 (type $0) -;; CHECK-NEXT: (local $0 i32) -;; CHECK-NEXT: (local $0$hi i32) -;; CHECK-NEXT: (local $1 i32) -;; CHECK-NEXT: (local $1$hi i32) -;; CHECK-NEXT: (local $i64toi32_i32$0 i32) -;; CHECK-NEXT: (block $label$1 -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (block -;; CHECK-NEXT: (local.set $1 -;; CHECK-NEXT: (block (result i32) -;; CHECK-NEXT: (local.set $i64toi32_i32$0 -;; CHECK-NEXT: (local.get $0$hi) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.set $1$hi -;; CHECK-NEXT: (local.get $i64toi32_i32$0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (block -;; CHECK-NEXT: (global.set $f -;; CHECK-NEXT: (block (result i32) -;; CHECK-NEXT: (local.set $i64toi32_i32$0 -;; CHECK-NEXT: (local.get $1$hi) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.get $1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.set $f$hi -;; CHECK-NEXT: (local.get $i64toi32_i32$0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) (module ;; CHECK: (type $0 (func (param i32 i32))) @@ -581,57 +580,57 @@ ;; CHECK: (global $i64toi32_i32$HIGH_BITS (mut i32) (i32.const 0)) - ;; CHECK: (export "exp" (func $1)) + ;; CHECK: (export "exp" (func $exp)) ;; CHECK: (func $call (type $0) (param $0 i32) (param $0$hi i32) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $call (param i64)) - (func "exp" + ;; CHECK: (func $exp (type $1) + ;; CHECK-NEXT: (local $0 i32) + ;; CHECK-NEXT: (local $0$hi i32) + ;; CHECK-NEXT: (local $i64toi32_i32$0 i32) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (local.set $0 + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (local.set $i64toi32_i32$0 + ;; CHECK-NEXT: (global.get $f$hi) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.get $f) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $0$hi + ;; CHECK-NEXT: (local.get $i64toi32_i32$0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $call + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (local.set $i64toi32_i32$0 + ;; CHECK-NEXT: (local.get $0$hi) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $i64toi32_i32$0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (global.set $f + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (local.set $i64toi32_i32$0 + ;; CHECK-NEXT: (i32.const 287454020) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 1432778632) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.set $f$hi + ;; CHECK-NEXT: (local.get $i64toi32_i32$0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $exp (export "exp") (call $call (global.get $f)) (global.set $f (i64.const 0x1122334455667788)) ) ) -;; CHECK: (func $1 (type $1) -;; CHECK-NEXT: (local $0 i32) -;; CHECK-NEXT: (local $0$hi i32) -;; CHECK-NEXT: (local $i64toi32_i32$0 i32) -;; CHECK-NEXT: (block -;; CHECK-NEXT: (local.set $0 -;; CHECK-NEXT: (block (result i32) -;; CHECK-NEXT: (local.set $i64toi32_i32$0 -;; CHECK-NEXT: (global.get $f$hi) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.get $f) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.set $0$hi -;; CHECK-NEXT: (local.get $i64toi32_i32$0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (call $call -;; CHECK-NEXT: (block (result i32) -;; CHECK-NEXT: (local.set $i64toi32_i32$0 -;; CHECK-NEXT: (local.get $0$hi) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.get $i64toi32_i32$0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (block -;; CHECK-NEXT: (global.set $f -;; CHECK-NEXT: (block (result i32) -;; CHECK-NEXT: (local.set $i64toi32_i32$0 -;; CHECK-NEXT: (i32.const 287454020) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.const 1432778632) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.set $f$hi -;; CHECK-NEXT: (local.get $i64toi32_i32$0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) (module (type $i64_f64_i32_=>_none (func (param i64 f64 i32))) ;; CHECK: (type $0 (func)) diff --git a/test/lit/passes/flatten_simplify-locals-nonesting_dfo_O3.wast b/test/lit/passes/flatten_simplify-locals-nonesting_dfo_O3.wast index db92b688d39..011ea86e9e5 100644 --- a/test/lit/passes/flatten_simplify-locals-nonesting_dfo_O3.wast +++ b/test/lit/passes/flatten_simplify-locals-nonesting_dfo_O3.wast @@ -5,7 +5,30 @@ (module (memory 1) - (func "if-select" + ;; CHECK: (type $0 (func)) + + ;; CHECK: (type $1 (func (result f64))) + + ;; CHECK: (type $2 (func (param i32 f64 f64) (result i32))) + + ;; CHECK: (type $3 (func (param i64))) + + ;; CHECK: (type $4 (func (param f64) (result i32))) + + ;; CHECK: (export "if-select" (func $if-select)) + + ;; CHECK: (export "unreachable-body-update-zext" (func $unreachable-body-update-zext)) + + ;; CHECK: (export "ssa-const" (func $ssa-const)) + + ;; CHECK: (export "if-nothing" (func $if-nothing)) + + ;; CHECK: (export "only-dfo" (func $only-dfo)) + + ;; CHECK: (func $if-select (; has Stack IR ;) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $if-select (export "if-select") (local $var$0 i32) (nop) (drop @@ -20,7 +43,10 @@ ) ) ) - (func "unreachable-body-update-zext" (result f64) + ;; CHECK: (func $unreachable-body-update-zext (; has Stack IR ;) (result f64) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $unreachable-body-update-zext (export "unreachable-body-update-zext") (result f64) (if (i32.eqz (i32.const 0) @@ -29,7 +55,10 @@ ) (f64.const -9223372036854775808) ) - (func "ssa-const" (param $var$0 i32) (param $var$1 f64) (param $var$2 f64) (result i32) + ;; CHECK: (func $ssa-const (; has Stack IR ;) (param $0 i32) (param $1 f64) (param $2 f64) (result i32) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $ssa-const (export "ssa-const") (param $var$0 i32) (param $var$1 f64) (param $var$2 f64) (result i32) (block $label$1 (result i32) (block $label$2 (if @@ -59,7 +88,10 @@ ) ) ) - (func "if-nothing" (param $var$0 i64) + ;; CHECK: (func $if-nothing (; has Stack IR ;) (param $0 i64) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $if-nothing (export "if-nothing") (param $var$0 i64) (local $var$1 i32) (local $var$2 i32) (block $label$1 @@ -83,7 +115,24 @@ (unreachable) ) ) - (func "only-dfo" (param $var$0 f64) (result i32) + ;; CHECK: (func $only-dfo (; has Stack IR ;) (param $0 f64) (result i32) + ;; CHECK-NEXT: (local $1 i32) + ;; CHECK-NEXT: (loop $label$1 + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (local.set $1 + ;; CHECK-NEXT: (i32.const -2147483648) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br $label$1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const -2766) + ;; CHECK-NEXT: ) + (func $only-dfo (export "only-dfo") (param $var$0 f64) (result i32) (local $var$1 i32) (local $var$2 i32) (local $var$3 i32) @@ -116,56 +165,3 @@ ) ) -;; CHECK: (type $0 (func)) - -;; CHECK: (type $1 (func (result f64))) - -;; CHECK: (type $2 (func (param i32 f64 f64) (result i32))) - -;; CHECK: (type $3 (func (param i64))) - -;; CHECK: (type $4 (func (param f64) (result i32))) - -;; CHECK: (export "if-select" (func $0)) - -;; CHECK: (export "unreachable-body-update-zext" (func $1)) - -;; CHECK: (export "ssa-const" (func $2)) - -;; CHECK: (export "if-nothing" (func $3)) - -;; CHECK: (export "only-dfo" (func $4)) - -;; CHECK: (func $0 (; has Stack IR ;) -;; CHECK-NEXT: (nop) -;; CHECK-NEXT: ) - -;; CHECK: (func $1 (; has Stack IR ;) (result f64) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) - -;; CHECK: (func $2 (; has Stack IR ;) (param $0 i32) (param $1 f64) (param $2 f64) (result i32) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) - -;; CHECK: (func $3 (; has Stack IR ;) (param $0 i64) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) - -;; CHECK: (func $4 (; has Stack IR ;) (param $0 f64) (result i32) -;; CHECK-NEXT: (local $1 i32) -;; CHECK-NEXT: (loop $label$1 -;; CHECK-NEXT: (if -;; CHECK-NEXT: (i32.eqz -;; CHECK-NEXT: (local.get $1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (block -;; CHECK-NEXT: (local.set $1 -;; CHECK-NEXT: (i32.const -2147483648) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (br $label$1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.const -2766) -;; CHECK-NEXT: ) diff --git a/test/lit/passes/flatten_simplify-locals-nonesting_souperify-single-use_enable-threads.wast b/test/lit/passes/flatten_simplify-locals-nonesting_souperify-single-use_enable-threads.wast index 2b17886b75b..0bcc36de280 100644 --- a/test/lit/passes/flatten_simplify-locals-nonesting_souperify-single-use_enable-threads.wast +++ b/test/lit/passes/flatten_simplify-locals-nonesting_souperify-single-use_enable-threads.wast @@ -33,7 +33,7 @@ ;; CHECK: (memory $0 (shared 1 1)) (memory $0 (shared 1 1)) ;; Figure 1a from the Souper paper https://arxiv.org/pdf/1711.04422.pdf - ;; CHECK: (export "replaced-print-internal" (func $55)) + ;; CHECK: (export "replaced-print-internal" (func $replaced-print-internal)) ;; CHECK: (func $figure-1a (param $a i64) (param $x i64) (param $y i64) (result i32) ;; CHECK-NEXT: (local $i i32) @@ -3827,48 +3827,7 @@ ) ) ) - (func "replaced-print-internal" (param $var$0 i32) - (local $var$1 i32) - (local $var$2 i32) - (local $var$3 i32) - (if - (local.tee $var$0 - (i32.add - (local.get $var$0) - (i32.const -7) - ) - ) - (block $label$2 - (block $label$3 - (local.set $var$1 - (local.get $var$0) - ) - (br_if $label$3 - (local.tee $var$3 - (i32.const 12) - ) - ) - (unreachable) - ) - (br_if $label$2 - (i32.eqz - (local.get $var$1) - ) - ) - (if - (i32.ne - (i32.load - (i32.const 0) - ) - (local.get $var$0) - ) - (unreachable) - ) - (unreachable) - ) - ) - ) - ;; CHECK: (func $55 (param $var$0 i32) + ;; CHECK: (func $replaced-print-internal (param $var$0 i32) ;; CHECK-NEXT: (local $var$1 i32) ;; CHECK-NEXT: (local $var$2 i32) ;; CHECK-NEXT: (local $var$3 i32) @@ -3944,7 +3903,47 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - + (func $replaced-print-internal (export "replaced-print-internal") (param $var$0 i32) + (local $var$1 i32) + (local $var$2 i32) + (local $var$3 i32) + (if + (local.tee $var$0 + (i32.add + (local.get $var$0) + (i32.const -7) + ) + ) + (block $label$2 + (block $label$3 + (local.set $var$1 + (local.get $var$0) + ) + (br_if $label$3 + (local.tee $var$3 + (i32.const 12) + ) + ) + (unreachable) + ) + (br_if $label$2 + (i32.eqz + (local.get $var$1) + ) + ) + (if + (i32.ne + (i32.load + (i32.const 0) + ) + (local.get $var$0) + ) + (unreachable) + ) + (unreachable) + ) + ) + ) ;; CHECK: (func $multiple-uses-to-non-expression (param $x i32) ;; CHECK-NEXT: (local $temp i32) ;; CHECK-NEXT: (local $2 i32) diff --git a/test/lit/passes/flatten_simplify-locals-nonesting_souperify_enable-threads.wast b/test/lit/passes/flatten_simplify-locals-nonesting_souperify_enable-threads.wast index e53bd44b48b..61430d653c0 100644 --- a/test/lit/passes/flatten_simplify-locals-nonesting_souperify_enable-threads.wast +++ b/test/lit/passes/flatten_simplify-locals-nonesting_souperify_enable-threads.wast @@ -33,7 +33,7 @@ ;; CHECK: (memory $0 (shared 1 1)) (memory $0 (shared 1 1)) ;; Figure 1a from the Souper paper https://arxiv.org/pdf/1711.04422.pdf - ;; CHECK: (export "replaced-print-internal" (func $56)) + ;; CHECK: (export "replaced-print-internal" (func $replaced-print-internal)) ;; CHECK: (func $figure-1a (param $a i64) (param $x i64) (param $y i64) (result i32) ;; CHECK-NEXT: (local $i i32) @@ -3895,48 +3895,7 @@ ) ) ) - (func "replaced-print-internal" (param $var$0 i32) - (local $var$1 i32) - (local $var$2 i32) - (local $var$3 i32) - (if - (local.tee $var$0 - (i32.add - (local.get $var$0) - (i32.const -7) - ) - ) - (block $label$2 - (block $label$3 - (local.set $var$1 - (local.get $var$0) - ) - (br_if $label$3 - (local.tee $var$3 - (i32.const 12) - ) - ) - (unreachable) - ) - (br_if $label$2 - (i32.eqz - (local.get $var$1) - ) - ) - (if - (i32.ne - (i32.load - (i32.const 0) - ) - (local.get $var$0) - ) - (unreachable) - ) - (unreachable) - ) - ) - ) - ;; CHECK: (func $56 (param $var$0 i32) + ;; CHECK: (func $replaced-print-internal (param $var$0 i32) ;; CHECK-NEXT: (local $var$1 i32) ;; CHECK-NEXT: (local $var$2 i32) ;; CHECK-NEXT: (local $var$3 i32) @@ -4012,7 +3971,47 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - + (func $replaced-print-internal (export "replaced-print-internal") (param $var$0 i32) + (local $var$1 i32) + (local $var$2 i32) + (local $var$3 i32) + (if + (local.tee $var$0 + (i32.add + (local.get $var$0) + (i32.const -7) + ) + ) + (block $label$2 + (block $label$3 + (local.set $var$1 + (local.get $var$0) + ) + (br_if $label$3 + (local.tee $var$3 + (i32.const 12) + ) + ) + (unreachable) + ) + (br_if $label$2 + (i32.eqz + (local.get $var$1) + ) + ) + (if + (i32.ne + (i32.load + (i32.const 0) + ) + (local.get $var$0) + ) + (unreachable) + ) + (unreachable) + ) + ) + ) ;; CHECK: (func $multiple-uses-to-non-expression (param $x i32) ;; CHECK-NEXT: (local $temp i32) ;; CHECK-NEXT: (local $2 i32) diff --git a/test/lit/passes/gto-removals.wast b/test/lit/passes/gto-removals.wast index 07bd3fa4584..ec4cc38dfec 100644 --- a/test/lit/passes/gto-removals.wast +++ b/test/lit/passes/gto-removals.wast @@ -807,14 +807,14 @@ ;; CHECK: (type $4 (func (param (ref null ${mut:i8})))) - ;; CHECK: (func $unreachable-set (type $4) (param ${mut:i8} (ref null ${mut:i8})) + ;; CHECK: (func $unreachable-set (type $4) (param $"{mut:i8}" (ref null ${mut:i8})) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (block (result (ref null ${mut:i8})) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $helper-i32) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.get ${mut:i8}) + ;; CHECK-NEXT: (local.get $"{mut:i8}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -831,13 +831,13 @@ ) ) - ;; CHECK: (func $unreachable-set-2 (type $4) (param ${mut:i8} (ref null ${mut:i8})) + ;; CHECK: (func $unreachable-set-2 (type $4) (param $"{mut:i8}" (ref null ${mut:i8})) ;; CHECK-NEXT: (block $block ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (local.get ${mut:i8}) + ;; CHECK-NEXT: (local.get $"{mut:i8}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br $block) @@ -858,13 +858,13 @@ ) ) - ;; CHECK: (func $unreachable-set-2b (type $4) (param ${mut:i8} (ref null ${mut:i8})) + ;; CHECK: (func $unreachable-set-2b (type $4) (param $"{mut:i8}" (ref null ${mut:i8})) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (local.get ${mut:i8}) + ;; CHECK-NEXT: (local.get $"{mut:i8}") ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (unreachable) 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 efa9ece608d..385433189db 100644 --- a/test/lit/passes/remove-unused-module-elements_all-features.wast +++ b/test/lit/passes/remove-unused-module-elements_all-features.wast @@ -732,7 +732,22 @@ (memory $B 1 1) (memory $C-unused 1 1) - (func "func" + ;; CHECK: (export "func" (func $func)) + + ;; CHECK: (func $func (type $0) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (v128.load64_splat $A + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (v128.load16_lane $B 0 + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $func (export "func") (drop (v128.load64_splat $A (i32.const 0) @@ -747,21 +762,6 @@ ) ) -;; CHECK: (export "func" (func $0)) - -;; CHECK: (func $0 (type $0) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (v128.load64_splat $A -;; CHECK-NEXT: (i32.const 0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (v128.load16_lane $B 0 -;; CHECK-NEXT: (i32.const 0) -;; CHECK-NEXT: (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) (module ;; When we export a function that calls another, we can export the called ;; function, skipping the one in the middle. The exports of $middle and diff --git a/test/lit/passes/stack-check-memory64.wast b/test/lit/passes/stack-check-memory64.wast index fc0db8d20fc..201910f36b0 100644 --- a/test/lit/passes/stack-check-memory64.wast +++ b/test/lit/passes/stack-check-memory64.wast @@ -11,48 +11,47 @@ ;; CHECK: (global $sp (mut i64) (i64.const 0)) (global $sp (mut i64) (i64.const 0)) - (func "use_stack" (result i64) - (global.set $sp (i64.const 42)) - (global.get $sp) - ) -) -;; CHECK: (global $__stack_base (mut i64) (i64.const 0)) - -;; CHECK: (global $__stack_limit (mut i64) (i64.const 0)) + ;; CHECK: (global $__stack_base (mut i64) (i64.const 0)) -;; CHECK: (memory $0 i64 0 65536) + ;; CHECK: (global $__stack_limit (mut i64) (i64.const 0)) -;; CHECK: (data $0 (i64.const 0) "") + ;; CHECK: (memory $0 i64 0 65536) -;; CHECK: (export "use_stack" (func $0)) + ;; CHECK: (data $0 (i64.const 0) "") -;; CHECK: (export "__set_stack_limits" (func $__set_stack_limits)) + ;; CHECK: (export "use_stack" (func $use_stack)) -;; CHECK: (func $0 (result i64) -;; CHECK-NEXT: (local $0 i64) -;; CHECK-NEXT: (block -;; CHECK-NEXT: (if -;; CHECK-NEXT: (i32.or -;; CHECK-NEXT: (i64.gt_u -;; CHECK-NEXT: (local.tee $0 -;; CHECK-NEXT: (i64.const 42) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.get $__stack_base) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i64.lt_u -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: (global.get $__stack_limit) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.set $sp -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.get $sp) -;; CHECK-NEXT: ) + ;; CHECK: (export "__set_stack_limits" (func $__set_stack_limits)) + ;; CHECK: (func $use_stack (result i64) + ;; CHECK-NEXT: (local $0 i64) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (i32.or + ;; CHECK-NEXT: (i64.gt_u + ;; CHECK-NEXT: (local.tee $0 + ;; CHECK-NEXT: (i64.const 42) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.get $__stack_base) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i64.lt_u + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (global.get $__stack_limit) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.set $sp + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.get $sp) + ;; CHECK-NEXT: ) + (func $use_stack (export "use_stack") (result i64) + (global.set $sp (i64.const 42)) + (global.get $sp) + ) +) ;; CHECK: (func $__set_stack_limits (param $0 i64) (param $1 i64) ;; CHECK-NEXT: (global.set $__stack_base ;; CHECK-NEXT: (local.get $0) diff --git a/test/lit/passes/vacuum_all-features.wast b/test/lit/passes/vacuum_all-features.wast index 9b06624cf7e..b228d13eeb4 100644 --- a/test/lit/passes/vacuum_all-features.wast +++ b/test/lit/passes/vacuum_all-features.wast @@ -1040,7 +1040,7 @@ (global $global$1 (mut i32) (i32.const 0)) ;; CHECK: (memory $0 1 1) - ;; CHECK: (export "compress" (func $3)) + ;; CHECK: (export "compress" (func $compress)) ;; CHECK: (func $_deflate (type $0) (param $0 i32) (result i32) ;; CHECK-NEXT: (call $_deflate @@ -1066,7 +1066,100 @@ (func $_deflateEnd (param i32) (result i32) (call $_deflateEnd (local.get $0)) ) - (func "compress" (param $0 i32) (param $1 i32) (param $2 i32) + ;; CHECK: (func $compress (type $1) (param $0 i32) (param $1 i32) (param $2 i32) + ;; CHECK-NEXT: (local $3 i32) + ;; CHECK-NEXT: (local.set $3 + ;; CHECK-NEXT: (global.get $global$1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.set $global$1 + ;; CHECK-NEXT: (i32.sub + ;; CHECK-NEXT: (global.get $global$1) + ;; CHECK-NEXT: (i32.const -64) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: (local.get $2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store offset=4 + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: (i32.const 100000) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store offset=12 + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store offset=16 + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store offset=32 + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store offset=36 + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store offset=40 + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (call $_deflateInit2_ + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (global.set $global$1 + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (return) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (if (result i32) + ;; CHECK-NEXT: (i32.eq + ;; CHECK-NEXT: (local.tee $0 + ;; CHECK-NEXT: (call $_deflate + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: (i32.load offset=20 + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $0 + ;; CHECK-NEXT: (call $_deflateEnd + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.set $global$1 + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $_deflateEnd + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.set $global$1 + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $compress (export "compress") (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local.set $3 (global.get $global$1) @@ -1165,99 +1258,6 @@ ) ) -;; CHECK: (func $3 (type $1) (param $0 i32) (param $1 i32) (param $2 i32) -;; CHECK-NEXT: (local $3 i32) -;; CHECK-NEXT: (local.set $3 -;; CHECK-NEXT: (global.get $global$1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.set $global$1 -;; CHECK-NEXT: (i32.sub -;; CHECK-NEXT: (global.get $global$1) -;; CHECK-NEXT: (i32.const -64) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.store -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: (local.get $2) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.store offset=4 -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: (i32.const 100000) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.store offset=12 -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.store offset=16 -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: (i32.load -;; CHECK-NEXT: (local.get $1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.store offset=32 -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: (i32.const 0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.store offset=36 -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: (i32.const 0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.store offset=40 -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: (i32.const 0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (if -;; CHECK-NEXT: (call $_deflateInit2_ -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (block -;; CHECK-NEXT: (global.set $global$1 -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (return) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (if (result i32) -;; CHECK-NEXT: (i32.eq -;; CHECK-NEXT: (local.tee $0 -;; CHECK-NEXT: (call $_deflate -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.const 1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (block (result i32) -;; CHECK-NEXT: (i32.store -;; CHECK-NEXT: (local.get $1) -;; CHECK-NEXT: (i32.load offset=20 -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (local.set $0 -;; CHECK-NEXT: (call $_deflateEnd -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.set $global$1 -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.const 0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (block (result i32) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (call $_deflateEnd -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.set $global$1 -;; CHECK-NEXT: (local.get $3) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (i32.const 0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) (module (type $A (struct (field (mut i32)))) ;; CHECK: (type $0 (func)) diff --git a/test/lit/validation/intrinsics.wast b/test/lit/validation/intrinsics.wast index 6437b2217c1..f734a749ec7 100644 --- a/test/lit/validation/intrinsics.wast +++ b/test/lit/validation/intrinsics.wast @@ -7,7 +7,7 @@ (module (import "binaryen-intrinsics" "call.without.effects" (func $cwe (param i32 funcref) (result i32))) - (func "get-ref" (result i32) + (func $get-ref (export "get-ref") (result i32) ;; This call-without-effects is done to a $func, but $func has the wrong ;; signature - it lacks the i32 parameter. (call $cwe @@ -20,4 +20,3 @@ (i32.const 1) ) ) - diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast index 4368a1cb2f2..af2fbffc5f5 100644 --- a/test/lit/wat-kitchen-sink.wast +++ b/test/lit/wat-kitchen-sink.wast @@ -335,14 +335,13 @@ ;; CHECK: (elem $passive-2 anyref (struct.new_default $s0) (struct.new_default $s0)) (elem $passive-2 anyref (item struct.new $s0) (struct.new $s0)) - (elem $declare declare func 0 1 2 3) + ;; CHECK: (elem declare func $ref-func $table-fill $table-grow $table-set) + (elem declare func 0 1 2 3) (elem $declare-2 declare funcref (item ref.func 0) (ref.func 1) (item (ref.func 2))) ;; tags (tag) - ;; CHECK: (elem declare func $ref-func $table-fill $table-grow $table-set) - ;; CHECK: (tag $1) ;; CHECK: (tag $empty) diff --git a/test/passes/O2_precompute-propagate_print-stack-ir.txt b/test/passes/O2_precompute-propagate_print-stack-ir.txt index 82b8601c331..b0789141a81 100644 --- a/test/passes/O2_precompute-propagate_print-stack-ir.txt +++ b/test/passes/O2_precompute-propagate_print-stack-ir.txt @@ -1,7 +1,7 @@ (module (type $0 (func (param i32 i32 i32 i64) (result i64))) - (export "func" (func $0)) - (func $0 (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i64) (result i64) + (export "func" (func $func)) + (func $func (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i64) (result i64) (local $4 i32) (local.set $3 (i64.const 2147483647) @@ -12,8 +12,8 @@ ) (module (type $0 (func (param i32 i32 i32 i64) (result i64))) - (export "func" (func $0)) - (func $0 (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i64) (result i64) + (export "func" (func $func)) + (func $func (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i64) (result i64) (local $4 i32) (local.set $3 (i64.const 2147483647) diff --git a/test/passes/O2_precompute-propagate_print-stack-ir.wast b/test/passes/O2_precompute-propagate_print-stack-ir.wast index 96a7d8797a5..0a1b6807e0d 100644 --- a/test/passes/O2_precompute-propagate_print-stack-ir.wast +++ b/test/passes/O2_precompute-propagate_print-stack-ir.wast @@ -1,5 +1,5 @@ (module - (func "func" (param $var$0 i32) (param $var$1 i32) (param $var$2 i32) (param $var$3 i64) (result i64) + (func $func (export "func") (param $var$0 i32) (param $var$1 i32) (param $var$2 i32) (param $var$3 i64) (result i64) (local $var$4 i32) (block $label$1 (local.set $var$3 @@ -15,4 +15,3 @@ (local.get $var$3) ) ) - diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt index 439515e0d71..2f14281609d 100644 --- a/test/passes/Oz_fuzz-exec_all-features.txt +++ b/test/passes/Oz_fuzz-exec_all-features.txt @@ -63,25 +63,25 @@ (type $extendedstruct (sub $struct (struct (field (mut i32)) (field f64)))) (type $int_func (func (result i32))) (import "fuzzing-support" "log-i32" (func $log (type $3) (param i32))) - (export "structs" (func $0)) - (export "arrays" (func $1)) - (export "br_on_cast" (func $2)) - (export "br_on_failed_cast-1" (func $3)) - (export "br_on_failed_cast-2" (func $4)) - (export "cast-null-anyref-to-gc" (func $5)) - (export "br-on_non_null" (func $7)) - (export "br-on_non_null-2" (func $8)) - (export "ref-as-func-of-func" (func $7)) - (export "cast-on-func" (func $11)) - (export "array-alloc-failure" (func $7)) - (export "init-array-packed" (func $13)) - (export "array-copy" (func $15)) - (export "array.new_fixed" (func $16)) - (export "array.new_fixed-packed" (func $17)) - (export "static-casts" (func $18)) - (export "static-br_on_cast" (func $2)) - (export "static-br_on_cast_fail" (func $20)) - (func $0 (type $void_func) (; has Stack IR ;) + (export "structs" (func $structs)) + (export "arrays" (func $arrays)) + (export "br_on_cast" (func $br_on_cast)) + (export "br_on_failed_cast-1" (func $br_on_failed_cast-1)) + (export "br_on_failed_cast-2" (func $br_on_failed_cast-2)) + (export "cast-null-anyref-to-gc" (func $cast-null-anyref-to-gc)) + (export "br-on_non_null" (func $br-on_non_null)) + (export "br-on_non_null-2" (func $br-on_non_null-2)) + (export "ref-as-func-of-func" (func $br-on_non_null)) + (export "cast-on-func" (func $cast-on-func)) + (export "array-alloc-failure" (func $br-on_non_null)) + (export "init-array-packed" (func $init-array-packed)) + (export "array-copy" (func $array-copy)) + (export "array.new_fixed" (func $array.new_fixed)) + (export "array.new_fixed-packed" (func $array.new_fixed-packed)) + (export "static-casts" (func $static-casts)) + (export "static-br_on_cast" (func $br_on_cast)) + (export "static-br_on_cast_fail" (func $static-br_on_cast_fail)) + (func $structs (type $void_func) (; has Stack IR ;) (local $0 i32) (call $log (i32.const 0) @@ -98,7 +98,7 @@ (i32.const 100) ) ) - (func $1 (type $void_func) (; has Stack IR ;) + (func $arrays (type $void_func) (; has Stack IR ;) (local $0 (ref $bytes)) (call $log (array.len @@ -140,12 +140,12 @@ ) ) ) - (func $2 (type $void_func) (; has Stack IR ;) + (func $br_on_cast (type $void_func) (; has Stack IR ;) (call $log (i32.const 3) ) ) - (func $3 (type $void_func) (; has Stack IR ;) + (func $br_on_failed_cast-1 (type $void_func) (; has Stack IR ;) (local $0 (ref $struct)) (local.set $0 (struct.new_default $struct) @@ -167,7 +167,7 @@ ) ) ) - (func $4 (type $void_func) (; has Stack IR ;) + (func $br_on_failed_cast-2 (type $void_func) (; has Stack IR ;) (call $log (i32.const 1) ) @@ -175,15 +175,15 @@ (i32.const 999) ) ) - (func $5 (type $void_func) (; has Stack IR ;) + (func $cast-null-anyref-to-gc (type $void_func) (; has Stack IR ;) (call $log (i32.const 0) ) ) - (func $7 (type $void_func) (; has Stack IR ;) + (func $br-on_non_null (type $void_func) (; has Stack IR ;) (nop) ) - (func $8 (type $void_func) (; has Stack IR ;) + (func $br-on_non_null-2 (type $void_func) (; has Stack IR ;) (drop (block (call $log @@ -193,7 +193,7 @@ ) ) ) - (func $11 (type $void_func) (; has Stack IR ;) + (func $cast-on-func (type $void_func) (; has Stack IR ;) (call $log (i32.const 0) ) @@ -205,7 +205,7 @@ ) (unreachable) ) - (func $13 (type $int_func) (; has Stack IR ;) (result i32) + (func $init-array-packed (type $int_func) (; has Stack IR ;) (result i32) (array.get_u $bytes (array.new $bytes (i32.const -43) @@ -214,7 +214,7 @@ (i32.const 10) ) ) - (func $15 (type $void_func) (; has Stack IR ;) + (func $array-copy (type $void_func) (; has Stack IR ;) (local $0 (ref $bytes)) (local $1 (ref $bytes)) (array.set $bytes @@ -269,7 +269,7 @@ ) ) ) - (func $16 (type $void_func) (; has Stack IR ;) + (func $array.new_fixed (type $void_func) (; has Stack IR ;) (local $0 (ref $bytes)) (call $log (array.len @@ -294,7 +294,7 @@ ) ) ) - (func $17 (type $void_func) (; has Stack IR ;) + (func $array.new_fixed-packed (type $void_func) (; has Stack IR ;) (call $log (array.get_u $bytes (array.new_fixed $bytes 1 @@ -304,7 +304,7 @@ ) ) ) - (func $18 (type $void_func) (; has Stack IR ;) + (func $static-casts (type $void_func) (; has Stack IR ;) (call $log (i32.const 1) ) @@ -324,7 +324,7 @@ (i32.const 1) ) ) - (func $20 (type $void_func) (; has Stack IR ;) + (func $static-br_on_cast_fail (type $void_func) (; has Stack IR ;) (call $log (i32.const -2) ) @@ -391,8 +391,8 @@ ignoring comparison of ExecutionResults! [host limit allocation failure] (module (type $0 (func (result i32))) - (export "foo" (func $0)) - (func $0 (type $0) (; has Stack IR ;) (result i32) + (export "foo" (func $foo)) + (func $foo (type $0) (; has Stack IR ;) (result i32) (i32.const 0) ) ) diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index 4c38c315dff..83cee56e866 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -8,7 +8,7 @@ (import "fuzzing-support" "log-i32" (func $log (param i32))) - (func "structs" + (func $structs (export "structs") (local $x (ref null $struct)) (local $y (ref null $struct)) (local.set $x @@ -42,7 +42,7 @@ (struct.get $struct 0 (local.get $y)) ) ) - (func "arrays" + (func $arrays (export "arrays") (local $x (ref null $bytes)) (local.set $x (array.new $bytes @@ -72,7 +72,7 @@ (array.get_s $bytes (local.get $x) (i32.const 20)) ) ) - (func "br_on_cast" + (func $br_on_cast (export "br_on_cast") (local $any anyref) ;; create a simple $struct, store it in an anyref (local.set $any @@ -101,7 +101,7 @@ ) (call $log (i32.const 3)) ;; we should get here ) - (func "br_on_failed_cast-1" + (func $br_on_failed_cast-1 (export "br_on_failed_cast-1") (local $any anyref) ;; create a simple $struct, store it in an anyref (local.set $any @@ -122,7 +122,7 @@ ) ) ) - (func "br_on_failed_cast-2" + (func $br_on_failed_cast-2 (export "br_on_failed_cast-2") (local $any anyref) ;; create an $extendedstruct, store it in an anyref (local.set $any @@ -143,7 +143,7 @@ ) ) ) - (func "cast-null-anyref-to-gc" + (func $cast-null-anyref-to-gc (export "cast-null-anyref-to-gc") ;; a null anyref is a literal which is not even of GC data, as it's not an ;; array or a struct, so our casting code should not assume it is. it is ok ;; to try to cast it, and the result should be 0. @@ -156,7 +156,7 @@ (func $get_struct (result structref) (struct.new_default $struct) ) - (func "br-on_non_null" + (func $br-on_non_null (export "br-on_non_null") (drop (block $non-null (result (ref any)) (br_on_non_null $non-null (ref.i31 (i32.const 0))) @@ -167,7 +167,7 @@ ) ) ) - (func "br-on_non_null-2" + (func $br-on_non_null-2 (export "br-on_non_null-2") (drop (block $non-null (result (ref any)) (br_on_non_null $non-null (ref.null any)) @@ -177,17 +177,17 @@ ) ) ) - (func "ref-as-func-of-func" + (func $ref-as-func-of-func (export "ref-as-func-of-func") (drop (ref.cast (ref func) - (ref.func $0) + (ref.func $structs) ) ) ) (func $a-void-func (call $log (i32.const 1337)) ) - (func "cast-on-func" + (func $cast-on-func (export "cast-on-func") (call $log (i32.const 0)) ;; a valid cast (call_ref $void_func @@ -201,14 +201,14 @@ ;; will never be reached (call $log (i32.const 2)) ) - (func "array-alloc-failure" + (func $array-alloc-failure (export "array-alloc-failure") (drop (array.new_default $bytes (i32.const -1) ;; un-allocatable size (4GB * sizeof(Literal)) ) ) ) - (func "init-array-packed" (result i32) + (func $init-array-packed (export "init-array-packed") (result i32) (local $x (ref null $bytes)) (local.set $x (array.new $bytes @@ -225,7 +225,7 @@ (func $call-target (param $0 eqref) (nop) ) - (func "array-copy" + (func $array-copy (export "array-copy") (local $x (ref null $bytes)) (local $y (ref null $bytes)) ;; Create an array of 10's, of size 100. @@ -271,7 +271,7 @@ (array.get_u $bytes (local.get $x) (i32.const 12)) ) ) - (func "array.new_fixed" + (func $array.new_fixed (export "array.new_fixed") (local $x (ref null $bytes)) (local.set $x (array.new_fixed $bytes 2 @@ -292,7 +292,7 @@ (array.get_u $bytes (local.get $x) (i32.const 1)) ) ) - (func "array.new_fixed-packed" + (func $array.new_fixed-packed (export "array.new_fixed-packed") (local $x (ref null $bytes)) (local.set $x (array.new_fixed $bytes 1 @@ -304,7 +304,7 @@ (array.get_u $bytes (local.get $x) (i32.const 0)) ) ) - (func "static-casts" + (func $static-casts (export "static-casts") ;; Casting null returns null. (call $log (ref.is_null (ref.cast (ref null $struct) (ref.null $struct)) @@ -341,7 +341,7 @@ ) ) ) - (func "static-br_on_cast" + (func $static-br_on_cast (export "static-br_on_cast") (local $any anyref) ;; create a simple $struct, store it in an anyref (local.set $any @@ -370,7 +370,7 @@ ) (call $log (i32.const 3)) ;; we should get here ) - (func "static-br_on_cast_fail" + (func $static-br_on_cast_fail (export "static-br_on_cast_fail") (local $any anyref) ;; create a simple $struct, store it in an anyref (local.set $any @@ -394,7 +394,7 @@ ) (module (type $[mut:i8] (array (mut i8))) - (func "foo" (result i32) + (func $foo (export "foo") (result i32) ;; before opts this will trap on failing to allocate -1 >>> 0 bytes. after ;; opts the unused value is removed so there is no trap, and a value is ;; returned, which should not confuse the fuzzer. diff --git a/test/passes/duplicate-function-elimination_all-features.txt b/test/passes/duplicate-function-elimination_all-features.txt index b5b363d42f4..6867002bf0b 100644 --- a/test/passes/duplicate-function-elimination_all-features.txt +++ b/test/passes/duplicate-function-elimination_all-features.txt @@ -22,11 +22,11 @@ (module (type $func (func (result i32))) (global $global$0 (ref $func) (ref.func $foo)) - (export "export" (func $2)) + (export "export" (func $export)) (func $foo (type $func) (result i32) (unreachable) ) - (func $2 (type $func) (result i32) + (func $export (type $func) (result i32) (call_ref $func (global.get $global$0) ) diff --git a/test/passes/duplicate-function-elimination_all-features.wast b/test/passes/duplicate-function-elimination_all-features.wast index df8d26b6f2d..2dccd051f58 100644 --- a/test/passes/duplicate-function-elimination_all-features.wast +++ b/test/passes/duplicate-function-elimination_all-features.wast @@ -33,7 +33,7 @@ (func $bar (result i32) (unreachable) ) - (func "export" (result i32) + (func $export (export "export") (result i32) (call_ref $func (global.get $global$0) ) diff --git a/test/passes/duplicate-import-elimination.txt b/test/passes/duplicate-import-elimination.txt index f54f152c671..4ea4c164433 100644 --- a/test/passes/duplicate-import-elimination.txt +++ b/test/passes/duplicate-import-elimination.txt @@ -5,9 +5,9 @@ (import "env" "waka" (func $wrong (param i32))) (table $0 2 2 funcref) (elem $0 (i32.const 0) $foo $foo) - (export "baz" (func $0)) + (export "baz" (func $baz)) (start $foo) - (func $0 + (func $baz (call $foo) (call $foo) (call $wrong diff --git a/test/passes/duplicate-import-elimination.wast b/test/passes/duplicate-import-elimination.wast index cd0c9dbf70e..a6f9846745e 100644 --- a/test/passes/duplicate-import-elimination.wast +++ b/test/passes/duplicate-import-elimination.wast @@ -5,10 +5,9 @@ (table 2 2 funcref) (elem (i32.const 0) $foo $bar) (start $bar) - (func "baz" + (func $baz (export "baz") (call $foo) (call $bar) (call $wrong (i32.const 1)) ) ) - diff --git a/test/passes/fuzz-exec_O.txt b/test/passes/fuzz-exec_O.txt index 74f92041b79..7bdf8d252d1 100644 --- a/test/passes/fuzz-exec_O.txt +++ b/test/passes/fuzz-exec_O.txt @@ -50,16 +50,16 @@ [fuzz-exec] note result: sub2 => nan:0x400000 (module (type $0 (func (result f32))) - (export "div" (func $0)) - (export "mul1" (func $0)) - (export "mul2" (func $0)) - (export "add1" (func $0)) - (export "add2" (func $0)) - (export "add3" (func $0)) - (export "add4" (func $0)) - (export "sub1" (func $0)) - (export "sub2" (func $0)) - (func $0 (; has Stack IR ;) (result f32) + (export "div" (func $div)) + (export "mul1" (func $div)) + (export "mul2" (func $div)) + (export "add1" (func $div)) + (export "add2" (func $div)) + (export "add3" (func $div)) + (export "add4" (func $div)) + (export "sub1" (func $div)) + (export "sub2" (func $div)) + (func $div (; has Stack IR ;) (result f32) (f32.const nan:0x400000) ) ) diff --git a/test/passes/fuzz-exec_O.wast b/test/passes/fuzz-exec_O.wast index b34dc2e8f7a..1fd917df213 100644 --- a/test/passes/fuzz-exec_O.wast +++ b/test/passes/fuzz-exec_O.wast @@ -21,55 +21,55 @@ ) ) (module - (func "div" (result f32) + (func $div (export "div") (result f32) (f32.div (f32.const -nan:0x23017a) (f32.const 1) ) ) - (func "mul1" (result f32) + (func $mul1 (export "mul1") (result f32) (f32.mul (f32.const -nan:0x34546d) (f32.const 1) ) ) - (func "mul2" (result f32) + (func $mul2 (export "mul2") (result f32) (f32.mul (f32.const 1) (f32.const -nan:0x34546d) ) ) - (func "add1" (result f32) + (func $add1 (export "add1") (result f32) (f32.add (f32.const -nan:0x34546d) (f32.const -0) ) ) - (func "add2" (result f32) + (func $add2 (export "add2") (result f32) (f32.add (f32.const -0) (f32.const -nan:0x34546d) ) ) - (func "add3" (result f32) + (func $add3 (export "add3") (result f32) (f32.add (f32.const -nan:0x34546d) (f32.const 0) ) ) - (func "add4" (result f32) + (func $add4 (export "add4") (result f32) (f32.add (f32.const 0) (f32.const -nan:0x34546d) ) ) - (func "sub1" (result f32) + (func $sub1 (export "sub1") (result f32) (f32.sub (f32.const -nan:0x34546d) (f32.const 0) ) ) - (func "sub2" (result f32) + (func $sub2 (export "sub2") (result f32) (f32.sub (f32.const -nan:0x34546d) (f32.const -0) diff --git a/test/passes/fuzz-exec_all-features.txt b/test/passes/fuzz-exec_all-features.txt index 43733571333..6a0ee8585c4 100644 --- a/test/passes/fuzz-exec_all-features.txt +++ b/test/passes/fuzz-exec_all-features.txt @@ -76,34 +76,34 @@ (type $3 (func)) (import "fuzzing-support" "log-i32" (func $fimport$0 (type $1) (param i32))) (memory $0 (shared 1 1)) - (export "unaligned_load" (func $0)) - (export "unaligned_load_offset" (func $1)) - (export "aligned_for_size" (func $2)) - (export "unaligned_notify" (func $3)) - (export "wrap_cmpxchg" (func $4)) - (export "oob_notify" (func $5)) - (func $0 (type $0) (result i32) + (export "unaligned_load" (func $unaligned_load)) + (export "unaligned_load_offset" (func $unaligned_load_offset)) + (export "aligned_for_size" (func $aligned_for_size)) + (export "unaligned_notify" (func $unaligned_notify)) + (export "wrap_cmpxchg" (func $wrap_cmpxchg)) + (export "oob_notify" (func $oob_notify)) + (func $unaligned_load (type $0) (result i32) (i32.atomic.load (i32.const 1) ) ) - (func $1 (type $0) (result i32) + (func $unaligned_load_offset (type $0) (result i32) (i32.atomic.load offset=1 (i32.const 0) ) ) - (func $2 (type $0) (result i32) + (func $aligned_for_size (type $0) (result i32) (i32.atomic.load16_u offset=2 (i32.const 0) ) ) - (func $3 (type $0) (result i32) + (func $unaligned_notify (type $0) (result i32) (memory.atomic.notify (i32.const 1) (i32.const 1) ) ) - (func $4 (type $2) (param $0 i32) (param $1 i32) + (func $wrap_cmpxchg (type $2) (param $0 i32) (param $1 i32) (drop (i32.atomic.rmw8.cmpxchg_u (i32.const 0) @@ -117,7 +117,7 @@ ) ) ) - (func $5 (type $3) + (func $oob_notify (type $3) (drop (memory.atomic.notify offset=22 (i32.const -104) @@ -150,8 +150,8 @@ (type $0 (func (result i32))) (memory $0 (shared 1 1)) (data $0 (i32.const 0) "\ff\ff") - (export "unsigned_2_bytes" (func $0)) - (func $0 (type $0) (result i32) + (export "unsigned_2_bytes" (func $unsigned_2_bytes)) + (func $unsigned_2_bytes (type $0) (result i32) (i32.atomic.rmw16.xor_u (i32.const 0) (i32.const 0) @@ -168,8 +168,8 @@ (type $1 (func)) (import "fuzzing-support" "log-i32" (func $fimport$0 (type $0) (param i32))) (memory $0 (shared 1 1)) - (export "rmw-reads-modifies-and-writes" (func $0)) - (func $0 (type $1) + (export "rmw-reads-modifies-and-writes" (func $rmw-reads-modifies-and-writes)) + (func $rmw-reads-modifies-and-writes (type $1) (drop (i64.atomic.rmw16.and_u offset=4 (i32.const 0) @@ -193,8 +193,8 @@ (type $1 (func)) (import "fuzzing-support" "log-i32" (func $fimport$0 (type $0) (param i32))) (memory $0 (shared 1 1)) - (export "rmw-reads-modifies-and-writes-asymmetrical" (func $0)) - (func $0 (type $1) + (export "rmw-reads-modifies-and-writes-asymmetrical" (func $rmw-reads-modifies-and-writes-asymmetrical)) + (func $rmw-reads-modifies-and-writes-asymmetrical (type $1) (drop (i32.atomic.rmw8.sub_u (i32.const 3) diff --git a/test/passes/fuzz-exec_all-features.wast b/test/passes/fuzz-exec_all-features.wast index 960990a33fd..2c9d95d16c9 100644 --- a/test/passes/fuzz-exec_all-features.wast +++ b/test/passes/fuzz-exec_all-features.wast @@ -33,30 +33,30 @@ (module (import "fuzzing-support" "log-i32" (func $fimport$0 (param i32))) (memory $0 (shared 1 1)) - (func "unaligned_load" (result i32) + (func $unaligned_load (export "unaligned_load") (result i32) (i32.atomic.load (i32.const 1) ;; unaligned ptr (i32.const 1) ) ) - (func "unaligned_load_offset" (result i32) + (func $unaligned_load_offset (export "unaligned_load_offset") (result i32) (i32.atomic.load offset=1 ;; unaligned with offset (i32.const 0) (i32.const 1) ) ) - (func "aligned_for_size" (result i32) + (func $aligned_for_size (export "aligned_for_size") (result i32) (i32.atomic.load16_u offset=2 ;; just 2 bytes loaded, so size is ok (i32.const 0) ) ) - (func "unaligned_notify" (result i32) + (func $unaligned_notify (export "unaligned_notify") (result i32) (memory.atomic.notify (i32.const 1) ;; unaligned (i32.const 1) ) ) - (func "wrap_cmpxchg" (param $0 i32) (param $1 i32) + (func $wrap_cmpxchg (export "wrap_cmpxchg") (param $0 i32) (param $1 i32) (drop (i32.atomic.rmw8.cmpxchg_u (i32.const 0) @@ -68,7 +68,7 @@ (i32.load (i32.const 0)) ) ) - (func "oob_notify" + (func $oob_notify (export "oob_notify") (drop (memory.atomic.notify offset=22 (i32.const -104) ;; illegal address @@ -80,7 +80,7 @@ (module (memory $0 (shared 1 1)) (data (i32.const 0) "\ff\ff") - (func "unsigned_2_bytes" (result i32) + (func $unsigned_2_bytes (export "unsigned_2_bytes") (result i32) (i32.atomic.rmw16.xor_u ;; should be unsigned (i32.const 0) (i32.const 0) @@ -90,7 +90,7 @@ (module (import "fuzzing-support" "log-i32" (func $fimport$0 (param i32))) (memory $0 (shared 1 1)) - (func "rmw-reads-modifies-and-writes" + (func $rmw-reads-modifies-and-writes (export "rmw-reads-modifies-and-writes") (drop (i64.atomic.rmw16.and_u offset=4 (i32.const 0) @@ -107,7 +107,7 @@ (module (import "fuzzing-support" "log-i32" (func $fimport$0 (param i32))) (memory $0 (shared 1 1)) - (func "rmw-reads-modifies-and-writes-asymmetrical" + (func $rmw-reads-modifies-and-writes-asymmetrical (export "rmw-reads-modifies-and-writes-asymmetrical") (drop (i32.atomic.rmw8.sub_u (i32.const 3) diff --git a/test/passes/optimize-instructions_fuzz-exec.txt b/test/passes/optimize-instructions_fuzz-exec.txt index de4aaa9bcbc..4b552c0606d 100644 --- a/test/passes/optimize-instructions_fuzz-exec.txt +++ b/test/passes/optimize-instructions_fuzz-exec.txt @@ -32,11 +32,11 @@ (type $2 (func (param f64))) (import "fuzzing-support" "log-f32" (func $logf32 (param f32))) (import "fuzzing-support" "log-f64" (func $logf64 (param f64))) - (export "test32" (func $0)) - (export "test64" (func $1)) - (export "just-one-nan" (func $2)) - (export "ignore" (func $3)) - (func $0 + (export "test32" (func $test32)) + (export "test64" (func $test64)) + (export "just-one-nan" (func $just-one-nan)) + (export "ignore" (func $ignore)) + (func $test32 (call $logf32 (f32.const nan:0x400000) ) @@ -69,7 +69,7 @@ (f32.const nan:0x400000) ) ) - (func $1 + (func $test64 (call $logf64 (f64.const nan:0x8000000000000) ) @@ -102,7 +102,7 @@ (f64.const nan:0x8000000000000) ) ) - (func $2 + (func $just-one-nan (call $logf32 (f32.const nan:0x400000) ) @@ -131,7 +131,7 @@ ) ) ) - (func $3 + (func $ignore (call $logf32 (f32.div (f32.const -0) @@ -206,10 +206,10 @@ (type $2 (func (param i32) (result i32))) (type $3 (func (result i32))) (import "fuzzing-support" "log-i32" (func $log (param i32))) - (export "foo" (func $1)) - (export "do-shift" (func $3)) - (export "call-compare-maybe-signed-eq" (func $5)) - (export "call-compare-maybe-signed-ne" (func $7)) + (export "foo" (func $foo)) + (export "do-shift" (func $do-shift)) + (export "call-compare-maybe-signed-eq" (func $call-compare-maybe-signed-eq)) + (export "call-compare-maybe-signed-ne" (func $call-compare-maybe-signed-ne)) (func $signed-comparison-to-unsigned (call $log (block (result i32) @@ -236,7 +236,7 @@ ) ) ) - (func $1 (param $0 i32) + (func $foo (param $0 i32) (call $log (i32.le_s (i32.sub @@ -271,7 +271,7 @@ ) ) ) - (func $3 + (func $do-shift (call $shift (i32.const 65419) ) @@ -282,7 +282,7 @@ ) (i32.const 0) ) - (func $5 (result i32) + (func $call-compare-maybe-signed-eq (result i32) (call $compare-maybe-signed-eq (i32.const 128) ) @@ -293,7 +293,7 @@ ) (i32.const 1) ) - (func $7 (result i32) + (func $call-compare-maybe-signed-ne (result i32) (call $compare-maybe-signed-ne (i32.const 128) ) diff --git a/test/passes/optimize-instructions_fuzz-exec.wast b/test/passes/optimize-instructions_fuzz-exec.wast index 87b6eb5947b..f047e3ac2b8 100644 --- a/test/passes/optimize-instructions_fuzz-exec.wast +++ b/test/passes/optimize-instructions_fuzz-exec.wast @@ -1,7 +1,7 @@ (module (import "fuzzing-support" "log-f32" (func $logf32 (param f32))) (import "fuzzing-support" "log-f64" (func $logf64 (param f64))) - (func "test32" + (func $test32 (export "test32") (call $logf32 (f32.add (f32.const -nan:0xffff82) @@ -59,7 +59,7 @@ ) ) ) - (func "test64" + (func $test64 (export "test64") (call $logf64 (f64.add (f64.const -nan:0xfffffffffff82) @@ -117,7 +117,7 @@ ) ) ) - (func "just-one-nan" + (func $just-one-nan (export "just-one-nan") (call $logf32 (f32.add (f32.const 0) @@ -167,7 +167,7 @@ ) ) ) - (func "ignore" + (func $ignore (export "ignore") ;; none of these are nan inputs, so the interpreter must not change the sign (call $logf32 (f32.div @@ -246,7 +246,7 @@ ) ) ) - (func "foo" (param $0 i32) + (func $foo (export "foo") (param $0 i32) ;; 8 - 0x80000000 < 0 ;; ;; is not the same as @@ -307,7 +307,7 @@ ) ) ) - (func "do-shift" + (func $do-shift (export "do-shift") (call $shift (i32.const 65419) ) @@ -326,7 +326,7 @@ (i32.const 128) ) ) - (func "call-compare-maybe-signed-eq" (result i32) + (func $call-compare-maybe-signed-eq (export "call-compare-maybe-signed-eq") (result i32) (call $compare-maybe-signed-eq (i32.const 128) ) @@ -344,7 +344,7 @@ (i32.const 128) ) ) - (func "call-compare-maybe-signed-ne" (result i32) + (func $call-compare-maybe-signed-ne (export "call-compare-maybe-signed-ne") (result i32) (call $compare-maybe-signed-ne (i32.const 128) ) diff --git a/test/passes/roundtrip.txt b/test/passes/roundtrip.txt index 85d07977d41..84e95488787 100644 --- a/test/passes/roundtrip.txt +++ b/test/passes/roundtrip.txt @@ -1,7 +1,7 @@ (module (type $0 (func)) - (export "foo" (func $0)) - (func $0 + (export "foo" (func $foo)) + (func $foo (unreachable) ) ) diff --git a/test/passes/roundtrip.wast b/test/passes/roundtrip.wast index 7d1eb174bbf..aec07657fe7 100644 --- a/test/passes/roundtrip.wast +++ b/test/passes/roundtrip.wast @@ -1,5 +1,5 @@ (module - (func "foo" + (func $foo (export "foo") ;; binaryen skips unreachable code while reading the binary format (unreachable) (nop) diff --git a/test/passes/simplify-globals_all-features_fuzz-exec.txt b/test/passes/simplify-globals_all-features_fuzz-exec.txt index 5c3bf0a157b..fbbcc30c491 100644 --- a/test/passes/simplify-globals_all-features_fuzz-exec.txt +++ b/test/passes/simplify-globals_all-features_fuzz-exec.txt @@ -5,11 +5,11 @@ (type $1 (func (result funcref))) (global $global$0 (mut funcref) (ref.null nofunc)) (elem declare func $0) - (export "export" (func $1)) + (export "export" (func $export)) (func $0 (type $0) (param $0 f32) (param $1 i31ref) (param $2 i64) (param $3 f64) (param $4 funcref) (nop) ) - (func $1 (type $1) (result funcref) + (func $export (type $1) (result funcref) (global.set $global$0 (ref.func $0) ) diff --git a/test/passes/simplify-globals_all-features_fuzz-exec.wast b/test/passes/simplify-globals_all-features_fuzz-exec.wast index ff2200ea98e..59a12a71ef6 100644 --- a/test/passes/simplify-globals_all-features_fuzz-exec.wast +++ b/test/passes/simplify-globals_all-features_fuzz-exec.wast @@ -3,7 +3,7 @@ (func $0 (param $0 f32) (param $1 i31ref) (param $2 i64) (param $3 f64) (param $4 funcref) (nop) ) - (func "export" (result funcref) + (func $export (export "export") (result funcref) ;; this set's value will be applied to the get right after it. we should carry ;; over the specific typed function reference type properly while doing so. (global.set $global$0 diff --git a/test/passes/simplify-locals_all-features.txt b/test/passes/simplify-locals_all-features.txt index f6726a37781..5e5478ddf34 100644 --- a/test/passes/simplify-locals_all-features.txt +++ b/test/passes/simplify-locals_all-features.txt @@ -1886,8 +1886,8 @@ (type $0 (func (result i32))) (memory $0 (shared 1 1)) (data $0 "data") - (export "foo" (func $0)) - (func $0 (type $0) (result i32) + (export "foo" (func $foo)) + (func $foo (type $0) (result i32) (local $0 i32) (local.set $0 (i32.rem_u @@ -1901,8 +1901,8 @@ ) (module (type $0 (func (param eqref i31ref) (result i32))) - (export "test" (func $0)) - (func $0 (type $0) (param $0 eqref) (param $1 i31ref) (result i32) + (export "test" (func $test)) + (func $test (type $0) (param $0 eqref) (param $1 i31ref) (result i32) (local $2 eqref) (local $3 i31ref) (local.set $2 diff --git a/test/passes/simplify-locals_all-features.wast b/test/passes/simplify-locals_all-features.wast index ff70a27744c..a2868b45dd9 100644 --- a/test/passes/simplify-locals_all-features.wast +++ b/test/passes/simplify-locals_all-features.wast @@ -1675,7 +1675,7 @@ (module (memory $0 (shared 1 1)) (data "data") - (func "foo" (result i32) + (func $foo (export "foo") (result i32) (local $0 i32) (block (result i32) (local.set $0 @@ -1693,7 +1693,7 @@ ;; it is no longer equivalent ;; (see https://github.com/WebAssembly/binaryen/issues/3266) (module - (func "test" (param $0 eqref) (param $1 (ref null i31)) (result i32) + (func $test (export "test") (param $0 eqref) (param $1 (ref null i31)) (result i32) (local $2 eqref) (local $3 (ref null i31)) (local.set $2 diff --git a/test/passes/stack-check_enable-mutable-globals.txt b/test/passes/stack-check_enable-mutable-globals.txt index 8b4ac19cd2a..a2d7f374de9 100644 --- a/test/passes/stack-check_enable-mutable-globals.txt +++ b/test/passes/stack-check_enable-mutable-globals.txt @@ -4,9 +4,9 @@ (import "env" "__stack_pointer" (global $sp (mut i32))) (global $__stack_base (mut i32) (i32.const 0)) (global $__stack_limit (mut i32) (i32.const 0)) - (export "use_stack" (func $0)) + (export "use_stack" (func $use_stack)) (export "__set_stack_limits" (func $__set_stack_limits)) - (func $0 (result i32) + (func $use_stack (result i32) (local $0 i32) (block (if diff --git a/test/passes/stack-check_enable-mutable-globals.wast b/test/passes/stack-check_enable-mutable-globals.wast index c3583cd2c9f..4ca78c67b95 100644 --- a/test/passes/stack-check_enable-mutable-globals.wast +++ b/test/passes/stack-check_enable-mutable-globals.wast @@ -1,6 +1,6 @@ (module (import "env" "__stack_pointer" (global $sp (mut i32))) - (func "use_stack" (result i32) + (func $use_stack (export "use_stack") (result i32) (global.set $sp (i32.const 42)) (global.get $sp) ) diff --git a/test/reduce/atomics-and-bulk-memory.wast b/test/reduce/atomics-and-bulk-memory.wast index c43914bd836..83d90e6dea6 100644 --- a/test/reduce/atomics-and-bulk-memory.wast +++ b/test/reduce/atomics-and-bulk-memory.wast @@ -2,7 +2,7 @@ (memory 1 1) ;; this can be removed destructively (data "some-data") - (func "foo" (result i32) + (func $foo (export "foo") (result i32) ;; this can be removed destructively (memory.init 0 (i32.const 3) diff --git a/test/unit/input/asyncify-coroutine.wat b/test/unit/input/asyncify-coroutine.wat index ace97c6e681..1d46c1269b8 100644 --- a/test/unit/input/asyncify-coroutine.wat +++ b/test/unit/input/asyncify-coroutine.wat @@ -5,7 +5,7 @@ (import "env" "yield" (func $yield (param i32))) (export "memory" (memory 0)) ;; simple linear progression in a loop - (func "linear" (result i32) + (func $linear (export "linear") (result i32) (local $x i32) (loop $l (call $yield (local.get $x)) @@ -16,7 +16,7 @@ ) ) ;; exponential in a loop - (func "exponential" (result i32) + (func $exponential (export "exponential") (result i32) (local $x i32) (local.set $x (i32.const 1) @@ -30,7 +30,7 @@ ) ) ;; just some weird numbers, no loop - (func "weird" (result i32) + (func $weird (export "weird") (result i32) (call $yield (i32.const 42)) (call $yield (i32.const 1337)) (call $yield (i32.const 0)) @@ -41,4 +41,3 @@ (unreachable) ) ) - diff --git a/test/unit/input/asyncify-sleep.wat b/test/unit/input/asyncify-sleep.wat index 91fb5a327b1..6d54f5c075f 100644 --- a/test/unit/input/asyncify-sleep.wat +++ b/test/unit/input/asyncify-sleep.wat @@ -8,17 +8,17 @@ (global $temp (mut i32) (i32.const 0)) (table 10 funcref) (elem (i32.const 5) $tablefunc) - (func "minimal" (result i32) + (func $minimal (export "minimal") (result i32) (call $sleep) (i32.const 21) ) - (func "repeat" (result i32) + (func $repeat (export "repeat") (result i32) ;; sleep twice, then return 42 (call $sleep) (call $sleep) (i32.const 42) ) - (func "local" (result i32) + (func $local (export "local") (result i32) (local $x i32) (local.set $x (i32.load (i32.const 0))) ;; a zero that the optimizer won't see (local.set $x @@ -27,7 +27,7 @@ (call $sleep) (local.get $x) ) - (func "local2" (result i32) + (func $local2 (export "local2") (result i32) (local $x i32) (local.set $x (i32.load (i32.const 0))) ;; a zero that the optimizer won't see (local.set $x @@ -39,7 +39,7 @@ ) (local.get $x) ) - (func "params" (param $x i32) (param $y i32) (result i32) + (func $params (export "params") (param $x i32) (param $y i32) (result i32) (local.set $x (i32.add (local.get $x) (i32.const 17)) ;; add 10 ) @@ -65,7 +65,7 @@ ) ) ) - (func "deeper" (param $x i32) (result i32) + (func $deeper (export "deeper") (param $x i32) (result i32) (call $pre) (call $inner (local.get $x)) (call $post) @@ -92,7 +92,7 @@ ) ) ) - (func "factorial-loop" (param $x i32) (result i32) + (func $factorial-loop (export "factorial-loop") (param $x i32) (result i32) (local $i i32) (local $ret i32) (local.set $ret (i32.const 1)) @@ -121,14 +121,14 @@ (br $l) ) ) - (func "end_tunnel" (param $x i32) (result i32) + (func $end_tunnel (export "end_tunnel") (param $x i32) (result i32) (local.set $x (i32.add (local.get $x) (i32.const 22)) ) (call $sleep) (i32.add (local.get $x) (i32.const 5)) ) - (func "do_tunnel" (param $x i32) (result i32) + (func $do_tunnel (export "do_tunnel") (param $x i32) (result i32) (local.set $x (i32.add (local.get $x) (i32.const 11)) ) @@ -145,7 +145,7 @@ (call $sleep) (i32.add (local.get $y) (i32.const 30)) ) - (func "call_indirect" (param $x i32) (param $y i32) (result i32) + (func $call_indirect (export "call_indirect") (param $x i32) (param $y i32) (result i32) (local.set $x (i32.add (local.get $x) (i32.const 1)) ) @@ -162,7 +162,7 @@ (call $sleep) (i32.add (local.get $y) (i32.const 300)) ;; total is 10+30+90+300=430 + y's original value ) - (func "if_else" (param $x i32) (param $y i32) (result i32) + (func $if_else (export "if_else") (param $x i32) (param $y i32) (result i32) (if (i32.eq (local.get $x) (i32.const 1)) (local.set $y (i32.add (local.get $y) (i32.const 10)) @@ -197,4 +197,3 @@ (local.get $y) ) ) - diff --git a/test/unit/input/asyncify-stackOverflow.wat b/test/unit/input/asyncify-stackOverflow.wat index a36a06b40c3..b838f23605d 100644 --- a/test/unit/input/asyncify-stackOverflow.wat +++ b/test/unit/input/asyncify-stackOverflow.wat @@ -2,7 +2,7 @@ (memory 1 2) (import "env" "sleep" (func $sleep)) (export "memory" (memory 0)) - (func "many_locals" (param $x i32) (result i32) + (func $many_locals (export "many_locals") (param $x i32) (result i32) (local $y i32) (local $z i32) (local.set $y @@ -19,4 +19,3 @@ ) ) ) - diff --git a/test/unit/input/stack_ir.wat b/test/unit/input/stack_ir.wat index 0d5d0dfc385..6969052c905 100644 --- a/test/unit/input/stack_ir.wat +++ b/test/unit/input/stack_ir.wat @@ -1,6 +1,6 @@ (module (import "env" "bar" (func $bar (param i32) (result i32))) - (func "foo1" (result i32) + (func $foo1 (export "foo1") (result i32) (local $x i32) (local.set $x (call $bar (i32.const 0))) (drop @@ -9,4 +9,3 @@ (local.get $x) ;; local2stack can help here ) ) - diff --git a/test/wasm2js/atomics_32.2asm.js b/test/wasm2js/atomics_32.2asm.js index 1fdd8916e5c..a97bf17ed26 100644 --- a/test/wasm2js/atomics_32.2asm.js +++ b/test/wasm2js/atomics_32.2asm.js @@ -110,7 +110,7 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0() { + function test() { var i64toi32_i32$0 = 0, i64toi32_i32$2 = 0, i64toi32_i32$1 = 0; Atomics.compareExchange(HEAP8, 1024, 1, 2) | 0; Atomics.compareExchange(HEAP16, 1024 >> 1, 1, 2) | 0; @@ -147,7 +147,7 @@ function asmFunc(imports) { } return { - "test": $0 + "test": test }; } diff --git a/test/wasm2js/atomics_32.2asm.js.opt b/test/wasm2js/atomics_32.2asm.js.opt index 0d7ab96f61d..deb8ce56186 100644 --- a/test/wasm2js/atomics_32.2asm.js.opt +++ b/test/wasm2js/atomics_32.2asm.js.opt @@ -110,7 +110,7 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0() { + function test() { Atomics.compareExchange(HEAP8, 1024, 1, 2) | 0; Atomics.compareExchange(HEAP16, 512, 1, 2) | 0; Atomics.compareExchange(HEAP32, 256, 1, 2) | 0; @@ -143,7 +143,7 @@ function asmFunc(imports) { } return { - "test": $0 + "test": test }; } diff --git a/test/wasm2js/atomics_32.wast b/test/wasm2js/atomics_32.wast index a4e19052d03..eeec9337631 100644 --- a/test/wasm2js/atomics_32.wast +++ b/test/wasm2js/atomics_32.wast @@ -2,7 +2,7 @@ (memory (shared 256 256)) (data "hello,") (data "world!") - (func "test" + (func $test (export "test") (local $x i32) (local $y i64) (local.set $x (i32.atomic.rmw8.cmpxchg_u (i32.const 1024) (i32.const 1) (i32.const 2))) diff --git a/test/wasm2js/br_table_hoisting.2asm.js b/test/wasm2js/br_table_hoisting.2asm.js index c814955aa28..73652c3bce8 100644 --- a/test/wasm2js/br_table_hoisting.2asm.js +++ b/test/wasm2js/br_table_hoisting.2asm.js @@ -15,7 +15,7 @@ function asmFunc(imports) { zed($0 | 0); } - function $1(x) { + function foo1(x) { x = x | 0; a : { b : { @@ -44,7 +44,7 @@ function asmFunc(imports) { zed(-10 | 0); } - function $2(x) { + function foo2(x) { x = x | 0; a : { b : { @@ -81,7 +81,7 @@ function asmFunc(imports) { zed(-10 | 0); } - function $3(x) { + function foo3(x) { x = x | 0; a : { b : { @@ -121,7 +121,7 @@ function asmFunc(imports) { zed(-10 | 0); } - function $4(x) { + function foo4(x) { x = x | 0; a : { b : { @@ -167,10 +167,10 @@ function asmFunc(imports) { } return { - "foo1": $1, - "foo2": $2, - "foo3": $3, - "foo4": $4 + "foo1": foo1, + "foo2": foo2, + "foo3": foo3, + "foo4": foo4 }; } diff --git a/test/wasm2js/br_table_hoisting.2asm.js.opt b/test/wasm2js/br_table_hoisting.2asm.js.opt index 767b126ab93..c4d825421f0 100644 --- a/test/wasm2js/br_table_hoisting.2asm.js.opt +++ b/test/wasm2js/br_table_hoisting.2asm.js.opt @@ -14,7 +14,7 @@ function asmFunc(imports) { zed($0); } - function $1($0) { + function foo1($0) { $0 = $0 | 0; a : { b : { @@ -42,7 +42,7 @@ function asmFunc(imports) { zed(-10); } - function $2($0) { + function foo2($0) { $0 = $0 | 0; a : { b : { @@ -77,7 +77,7 @@ function asmFunc(imports) { zed(-10); } - function $3($0) { + function foo3($0) { $0 = $0 | 0; a : { b : { @@ -115,7 +115,7 @@ function asmFunc(imports) { zed(-10); } - function $4($0) { + function foo4($0) { $0 = $0 | 0; a : { b : { @@ -157,10 +157,10 @@ function asmFunc(imports) { } return { - "foo1": $1, - "foo2": $2, - "foo3": $3, - "foo4": $4 + "foo1": foo1, + "foo2": foo2, + "foo3": foo3, + "foo4": foo4 }; } diff --git a/test/wasm2js/br_table_hoisting.wast b/test/wasm2js/br_table_hoisting.wast index 95afab72894..c72abc61e69 100644 --- a/test/wasm2js/br_table_hoisting.wast +++ b/test/wasm2js/br_table_hoisting.wast @@ -2,7 +2,7 @@ (func $zed (param i32) (call $zed (local.get 0)) ) - (func "foo1" (param $x i32) + (func $foo1 (export "foo1") (param $x i32) (block $a (block $b (block $c @@ -29,7 +29,7 @@ (call $zed (i32.const -9)) (call $zed (i32.const -10)) ) - (func "foo2" (param $x i32) + (func $foo2 (export "foo2") (param $x i32) (block $a (block $b (block $c @@ -56,7 +56,7 @@ (call $zed (i32.const -9)) (call $zed (i32.const -10)) ) - (func "foo3" (param $x i32) + (func $foo3 (export "foo3") (param $x i32) (block $a (block $b (block $c @@ -83,7 +83,7 @@ (call $zed (i32.const -9)) (call $zed (i32.const -10)) ) - (func "foo4" (param $x i32) + (func $foo4 (export "foo4") (param $x i32) (block $a (block $b (block $c @@ -112,4 +112,3 @@ (call $zed (i32.const -10)) ) ) - diff --git a/test/wasm2js/br_table_to_loop.2asm.js b/test/wasm2js/br_table_to_loop.2asm.js index a0844d9360f..939e60bf62b 100644 --- a/test/wasm2js/br_table_to_loop.2asm.js +++ b/test/wasm2js/br_table_to_loop.2asm.js @@ -10,7 +10,7 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0() { + function exp1() { block : { loop : while (1) switch (1 | 0) { case 1: @@ -21,7 +21,7 @@ function asmFunc(imports) { } } - function $1() { + function exp2() { block : { loop : while (1) switch (1 | 0) { case 1: @@ -33,8 +33,8 @@ function asmFunc(imports) { } return { - "exp1": $0, - "exp2": $1 + "exp1": exp1, + "exp2": exp2 }; } diff --git a/test/wasm2js/br_table_to_loop.2asm.js.opt b/test/wasm2js/br_table_to_loop.2asm.js.opt index 4c9f9731140..7215e26761e 100644 --- a/test/wasm2js/br_table_to_loop.2asm.js.opt +++ b/test/wasm2js/br_table_to_loop.2asm.js.opt @@ -10,17 +10,17 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0() { + function exp1() { while (1) continue; } - function $1() { + function exp2() { } return { - "exp1": $0, - "exp2": $1 + "exp1": exp1, + "exp2": exp2 }; } diff --git a/test/wasm2js/br_table_to_loop.wast b/test/wasm2js/br_table_to_loop.wast index a74d5ffe091..add8f3eeb67 100644 --- a/test/wasm2js/br_table_to_loop.wast +++ b/test/wasm2js/br_table_to_loop.wast @@ -1,5 +1,5 @@ (module - (func "exp1" + (func $exp1 (export "exp1") (block $block ;; An infinite loop. When optimizing, wasm2js enables ignore-implicit-traps ;; and so it can simplify this. @@ -8,7 +8,7 @@ ) ) ) - (func "exp2" + (func $exp2 (export "exp2") (block $block ;; A loop that never executes. This can be optimized into a nop. (loop $loop diff --git a/test/wasm2js/deterministic.2asm.js b/test/wasm2js/deterministic.2asm.js index fff96b5a4c8..33cb04a846e 100644 --- a/test/wasm2js/deterministic.2asm.js +++ b/test/wasm2js/deterministic.2asm.js @@ -25,7 +25,7 @@ function asmFunc(imports) { var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; var global$0 = -44; - function $0() { + function foo() { if ((global$0 >>> 0) / ((HEAP32[0 >> 2] | 0) >>> 0) | 0) { wasm2js_trap() } @@ -38,7 +38,7 @@ function asmFunc(imports) { } return { - "foo": $0 + "foo": foo }; } diff --git a/test/wasm2js/deterministic.2asm.js.opt b/test/wasm2js/deterministic.2asm.js.opt index a05554b1ab3..12ebdd8599d 100644 --- a/test/wasm2js/deterministic.2asm.js.opt +++ b/test/wasm2js/deterministic.2asm.js.opt @@ -24,7 +24,7 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0() { + function foo() { if (4294967252 / HEAPU32[0] | 0) { wasm2js_trap() } @@ -37,7 +37,7 @@ function asmFunc(imports) { } return { - "foo": $0 + "foo": foo }; } diff --git a/test/wasm2js/deterministic.wast b/test/wasm2js/deterministic.wast index d1f39ba0646..67caefbad9c 100644 --- a/test/wasm2js/deterministic.wast +++ b/test/wasm2js/deterministic.wast @@ -1,7 +1,7 @@ (module (global $global$0 (mut i32) (i32.const -44)) (import "env" "memory" (memory $0 1 1)) - (func "foo" (result i32) + (func $foo (export "foo") (result i32) (if (i32.div_u (global.get $global$0) diff --git a/test/wasm2js/dot_import.2asm.js b/test/wasm2js/dot_import.2asm.js index a35eabe9544..ddbec432bce 100644 --- a/test/wasm2js/dot_import.2asm.js +++ b/test/wasm2js/dot_import.2asm.js @@ -13,12 +13,12 @@ function asmFunc(imports) { var Math_sqrt = Math.sqrt; var mod_ule = imports["mod.ule"]; var base = mod_ule["ba.se"]; - function $0() { + function exported() { base(); } return { - "exported": $0 + "exported": exported }; } diff --git a/test/wasm2js/dot_import.2asm.js.opt b/test/wasm2js/dot_import.2asm.js.opt index a35eabe9544..ddbec432bce 100644 --- a/test/wasm2js/dot_import.2asm.js.opt +++ b/test/wasm2js/dot_import.2asm.js.opt @@ -13,12 +13,12 @@ function asmFunc(imports) { var Math_sqrt = Math.sqrt; var mod_ule = imports["mod.ule"]; var base = mod_ule["ba.se"]; - function $0() { + function exported() { base(); } return { - "exported": $0 + "exported": exported }; } diff --git a/test/wasm2js/dot_import.wast b/test/wasm2js/dot_import.wast index 46c843fdedb..4da6478ee97 100644 --- a/test/wasm2js/dot_import.wast +++ b/test/wasm2js/dot_import.wast @@ -1,6 +1,6 @@ (module (import "mod.ule" "ba.se" (func $base)) - (func "exported" + (func $exported (export "exported") (call $base) ) ) diff --git a/test/wasm2js/global_i64.2asm.js b/test/wasm2js/global_i64.2asm.js index 37c8b15facc..cccd5de1cc3 100644 --- a/test/wasm2js/global_i64.2asm.js +++ b/test/wasm2js/global_i64.2asm.js @@ -17,7 +17,7 @@ function asmFunc(imports) { $0$hi = $0$hi | 0; } - function $1() { + function exp() { var i64toi32_i32$0 = 0; i64toi32_i32$0 = f$hi; call(f | 0, i64toi32_i32$0 | 0); @@ -27,7 +27,7 @@ function asmFunc(imports) { } return { - "exp": $1 + "exp": exp }; } diff --git a/test/wasm2js/global_i64.2asm.js.opt b/test/wasm2js/global_i64.2asm.js.opt index e28ae72930b..f6cc9d9111a 100644 --- a/test/wasm2js/global_i64.2asm.js.opt +++ b/test/wasm2js/global_i64.2asm.js.opt @@ -10,12 +10,12 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $1() { + function exp() { } return { - "exp": $1 + "exp": exp }; } diff --git a/test/wasm2js/global_i64.wast b/test/wasm2js/global_i64.wast index 6ed163d79e7..71a125bf6e2 100644 --- a/test/wasm2js/global_i64.wast +++ b/test/wasm2js/global_i64.wast @@ -1,7 +1,7 @@ (module (global $f (mut i64) (i64.const 0x12345678ABCDEFAF)) (func $call (param i64)) - (func "exp" + (func $exp (export "exp") (call $call (global.get $f)) (global.set $f (i64.const 0x1122334455667788)) ) diff --git a/test/wasm2js/indirect-select.2asm.js b/test/wasm2js/indirect-select.2asm.js index a515e15560e..b1725927481 100644 --- a/test/wasm2js/indirect-select.2asm.js +++ b/test/wasm2js/indirect-select.2asm.js @@ -13,19 +13,19 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0(x) { + function foo_true(x) { x = x | 0; return FUNCTION_TABLE[(x ? 1 : 0) | 0]() | 0 | 0; } - function $1(x) { + function foo_false(x) { x = x | 0; return FUNCTION_TABLE[(x ? 0 : 1) | 0]() | 0 | 0; } return { - "foo_true": $0, - "foo_false": $1 + "foo_true": foo_true, + "foo_false": foo_false }; } diff --git a/test/wasm2js/indirect-select.2asm.js.opt b/test/wasm2js/indirect-select.2asm.js.opt index 9b79e3a636f..2d1792a53d9 100644 --- a/test/wasm2js/indirect-select.2asm.js.opt +++ b/test/wasm2js/indirect-select.2asm.js.opt @@ -13,19 +13,19 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0($0_1) { - $0_1 = $0_1 | 0; - return FUNCTION_TABLE[!!$0_1 | 0]() | 0; + function foo_true($0) { + $0 = $0 | 0; + return FUNCTION_TABLE[!!$0 | 0]() | 0; } - function $1($0_1) { - $0_1 = $0_1 | 0; - return FUNCTION_TABLE[!$0_1 | 0]() | 0; + function foo_false($0) { + $0 = $0 | 0; + return FUNCTION_TABLE[!$0 | 0]() | 0; } return { - "foo_true": $0, - "foo_false": $1 + "foo_true": foo_true, + "foo_false": foo_false }; } diff --git a/test/wasm2js/indirect-select.wast b/test/wasm2js/indirect-select.wast index fc6f4c4706e..a493ec14cfd 100644 --- a/test/wasm2js/indirect-select.wast +++ b/test/wasm2js/indirect-select.wast @@ -1,7 +1,7 @@ (module (type $none_=>_i32 (func (result i32))) (import "env" "table" (table $timport 6 funcref)) - (func "foo-true" (param $x i32) (result i32) + (func $foo-true (export "foo-true") (param $x i32) (result i32) (call_indirect (type $none_=>_i32) (select (i32.const 1) @@ -10,7 +10,7 @@ ) ) ) - (func "foo-false" (param $x i32) (result i32) + (func $foo-false (export "foo-false") (param $x i32) (result i32) (call_indirect (type $none_=>_i32) (select (i32.const 0) diff --git a/test/wasm2js/minified-memory.2asm.js b/test/wasm2js/minified-memory.2asm.js index 3e7b29b8916..1d3e8c942f8 100644 --- a/test/wasm2js/minified-memory.2asm.js +++ b/test/wasm2js/minified-memory.2asm.js @@ -22,7 +22,7 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0() { + function foo() { return HEAP32[0 >> 2] | 0 | 0; } @@ -53,7 +53,7 @@ function asmFunc(imports) { } return { - "foo": $0 + "foo": foo }; } diff --git a/test/wasm2js/minified-memory.2asm.js.opt b/test/wasm2js/minified-memory.2asm.js.opt index 9c5f51f889d..6d1dfa47d7f 100644 --- a/test/wasm2js/minified-memory.2asm.js.opt +++ b/test/wasm2js/minified-memory.2asm.js.opt @@ -22,7 +22,7 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0() { + function foo() { return HEAP32[0]; } @@ -53,7 +53,7 @@ function asmFunc(imports) { } return { - "foo": $0 + "foo": foo }; } diff --git a/test/wasm2js/minified-memory.wast b/test/wasm2js/minified-memory.wast index 0fc1e301825..fb3725aaa69 100644 --- a/test/wasm2js/minified-memory.wast +++ b/test/wasm2js/minified-memory.wast @@ -1,6 +1,6 @@ (module (import "env" "a" (memory $0 1)) - (func "foo" (result i32) + (func $foo (export "foo") (result i32) (i32.load (i32.const 0)) ) ) diff --git a/test/wasm2js/reinterpret_scratch.2asm.js b/test/wasm2js/reinterpret_scratch.2asm.js index ef53077336a..547206072a9 100644 --- a/test/wasm2js/reinterpret_scratch.2asm.js +++ b/test/wasm2js/reinterpret_scratch.2asm.js @@ -38,11 +38,11 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0() { - var i64toi32_i32$1 = 0, i64toi32_i32$0 = 0, $0_1 = Math_fround(0); + function foo() { + var i64toi32_i32$1 = 0, i64toi32_i32$0 = 0, $0 = Math_fround(0); wasm2js_scratch_store_f64(+(305419896.0)); i64toi32_i32$0 = wasm2js_scratch_load_i32(1 | 0) | 0; - i64toi32_i32$1 = (wasm2js_scratch_store_f32($0_1), wasm2js_scratch_load_i32(2)); + i64toi32_i32$1 = (wasm2js_scratch_store_f32($0), wasm2js_scratch_load_i32(2)); HEAP32[i64toi32_i32$1 >> 2] = wasm2js_scratch_load_i32(0 | 0) | 0; HEAP32[(i64toi32_i32$1 + 4 | 0) >> 2] = i64toi32_i32$0; return HEAP32[0 >> 2] | 0 | 0; @@ -54,7 +54,7 @@ function asmFunc(imports) { } return { - "foo": $0 + "foo": foo }; } diff --git a/test/wasm2js/reinterpret_scratch.2asm.js.opt b/test/wasm2js/reinterpret_scratch.2asm.js.opt index d1e01844200..bc077cdce1f 100644 --- a/test/wasm2js/reinterpret_scratch.2asm.js.opt +++ b/test/wasm2js/reinterpret_scratch.2asm.js.opt @@ -34,12 +34,12 @@ function asmFunc(imports) { var Math_ceil = Math.ceil; var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; - function $0() { - var $0_1 = 0; + function foo() { + var $0 = 0; wasm2js_scratch_store_f64(305419896.0); - $0_1 = wasm2js_scratch_load_i32(1) | 0; + $0 = wasm2js_scratch_load_i32(1) | 0; HEAP32[0] = wasm2js_scratch_load_i32(0); - HEAP32[1] = $0_1; + HEAP32[1] = $0; return HEAP32[0]; } @@ -49,7 +49,7 @@ function asmFunc(imports) { } return { - "foo": $0 + "foo": foo }; } diff --git a/test/wasm2js/reinterpret_scratch.wast b/test/wasm2js/reinterpret_scratch.wast index bfaf6838050..4741a69406c 100644 --- a/test/wasm2js/reinterpret_scratch.wast +++ b/test/wasm2js/reinterpret_scratch.wast @@ -1,6 +1,6 @@ (module (memory $0 1 1) - (func "foo" (result i32) + (func $foo (export "foo") (result i32) (local $0 f32) (i64.store align=4 (i32.reinterpret_f32 ;; i32 0 diff --git a/test/wasm2js/sign_ext.2asm.js b/test/wasm2js/sign_ext.2asm.js index 4ce98c880d1..220b2753da5 100644 --- a/test/wasm2js/sign_ext.2asm.js +++ b/test/wasm2js/sign_ext.2asm.js @@ -14,17 +14,17 @@ function asmFunc(imports) { var env = imports.env; var setTempRet0 = env.setTempRet0; var i64toi32_i32$HIGH_BITS = 0; - function $0(x) { + function test8(x) { x = x | 0; return x << 24 >> 24 | 0; } - function $1(x) { + function test16(x) { x = x | 0; return x << 16 >> 16 | 0; } - function $2(x, x$hi) { + function test8_i64(x, x$hi) { x = x | 0; x$hi = x$hi | 0; var i64toi32_i32$2 = 0, i64toi32_i32$1 = 0; @@ -34,7 +34,7 @@ function asmFunc(imports) { return i64toi32_i32$2 | 0; } - function $3(x, x$hi) { + function test16_i64(x, x$hi) { x = x | 0; x$hi = x$hi | 0; var i64toi32_i32$2 = 0, i64toi32_i32$1 = 0; @@ -44,7 +44,7 @@ function asmFunc(imports) { return i64toi32_i32$2 | 0; } - function $4(x, x$hi) { + function test32_i64(x, x$hi) { x = x | 0; x$hi = x$hi | 0; var i64toi32_i32$2 = 0, i64toi32_i32$1 = 0; @@ -54,15 +54,15 @@ function asmFunc(imports) { return i64toi32_i32$2 | 0; } - function legalstub$2($0_1, $1_1) { - $0_1 = $0_1 | 0; - $1_1 = $1_1 | 0; - var i64toi32_i32$2 = 0, i64toi32_i32$4 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $12 = 0, $13 = 0, $4_1 = 0, $4$hi = 0, $7$hi = 0, $2_1 = 0, $2$hi = 0; + function legalstub$test8_i64($0, $1) { + $0 = $0 | 0; + $1 = $1 | 0; + var i64toi32_i32$2 = 0, i64toi32_i32$4 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $12 = 0, $13 = 0, $4 = 0, $4$hi = 0, $7$hi = 0, $2 = 0, $2$hi = 0; i64toi32_i32$0 = 0; - $4_1 = $0_1; + $4 = $0; $4$hi = i64toi32_i32$0; i64toi32_i32$0 = 0; - i64toi32_i32$2 = $1_1; + i64toi32_i32$2 = $1; i64toi32_i32$1 = 0; i64toi32_i32$3 = 32; i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0; @@ -75,13 +75,13 @@ function asmFunc(imports) { } $7$hi = i64toi32_i32$1; i64toi32_i32$1 = $4$hi; - i64toi32_i32$0 = $4_1; + i64toi32_i32$0 = $4; i64toi32_i32$2 = $7$hi; i64toi32_i32$3 = $12; i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2 | 0; - i64toi32_i32$2 = $2(i64toi32_i32$0 | i64toi32_i32$3 | 0 | 0, i64toi32_i32$2 | 0) | 0; + i64toi32_i32$2 = test8_i64(i64toi32_i32$0 | i64toi32_i32$3 | 0 | 0, i64toi32_i32$2 | 0) | 0; i64toi32_i32$0 = i64toi32_i32$HIGH_BITS; - $2_1 = i64toi32_i32$2; + $2 = i64toi32_i32$2; $2$hi = i64toi32_i32$0; i64toi32_i32$1 = i64toi32_i32$2; i64toi32_i32$2 = 0; @@ -96,18 +96,18 @@ function asmFunc(imports) { } setTempRet0($13 | 0); i64toi32_i32$2 = $2$hi; - return $2_1 | 0; + return $2 | 0; } - function legalstub$3($0_1, $1_1) { - $0_1 = $0_1 | 0; - $1_1 = $1_1 | 0; - var i64toi32_i32$2 = 0, i64toi32_i32$4 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $12 = 0, $13 = 0, $4_1 = 0, $4$hi = 0, $7$hi = 0, $2_1 = 0, $2$hi = 0; + function legalstub$test16_i64($0, $1) { + $0 = $0 | 0; + $1 = $1 | 0; + var i64toi32_i32$2 = 0, i64toi32_i32$4 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $12 = 0, $13 = 0, $4 = 0, $4$hi = 0, $7$hi = 0, $2 = 0, $2$hi = 0; i64toi32_i32$0 = 0; - $4_1 = $0_1; + $4 = $0; $4$hi = i64toi32_i32$0; i64toi32_i32$0 = 0; - i64toi32_i32$2 = $1_1; + i64toi32_i32$2 = $1; i64toi32_i32$1 = 0; i64toi32_i32$3 = 32; i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0; @@ -120,13 +120,13 @@ function asmFunc(imports) { } $7$hi = i64toi32_i32$1; i64toi32_i32$1 = $4$hi; - i64toi32_i32$0 = $4_1; + i64toi32_i32$0 = $4; i64toi32_i32$2 = $7$hi; i64toi32_i32$3 = $12; i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2 | 0; - i64toi32_i32$2 = $3(i64toi32_i32$0 | i64toi32_i32$3 | 0 | 0, i64toi32_i32$2 | 0) | 0; + i64toi32_i32$2 = test16_i64(i64toi32_i32$0 | i64toi32_i32$3 | 0 | 0, i64toi32_i32$2 | 0) | 0; i64toi32_i32$0 = i64toi32_i32$HIGH_BITS; - $2_1 = i64toi32_i32$2; + $2 = i64toi32_i32$2; $2$hi = i64toi32_i32$0; i64toi32_i32$1 = i64toi32_i32$2; i64toi32_i32$2 = 0; @@ -141,18 +141,18 @@ function asmFunc(imports) { } setTempRet0($13 | 0); i64toi32_i32$2 = $2$hi; - return $2_1 | 0; + return $2 | 0; } - function legalstub$4($0_1, $1_1) { - $0_1 = $0_1 | 0; - $1_1 = $1_1 | 0; - var i64toi32_i32$2 = 0, i64toi32_i32$4 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $12 = 0, $13 = 0, $4_1 = 0, $4$hi = 0, $7$hi = 0, $2_1 = 0, $2$hi = 0; + function legalstub$test32_i64($0, $1) { + $0 = $0 | 0; + $1 = $1 | 0; + var i64toi32_i32$2 = 0, i64toi32_i32$4 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $12 = 0, $13 = 0, $4 = 0, $4$hi = 0, $7$hi = 0, $2 = 0, $2$hi = 0; i64toi32_i32$0 = 0; - $4_1 = $0_1; + $4 = $0; $4$hi = i64toi32_i32$0; i64toi32_i32$0 = 0; - i64toi32_i32$2 = $1_1; + i64toi32_i32$2 = $1; i64toi32_i32$1 = 0; i64toi32_i32$3 = 32; i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0; @@ -165,13 +165,13 @@ function asmFunc(imports) { } $7$hi = i64toi32_i32$1; i64toi32_i32$1 = $4$hi; - i64toi32_i32$0 = $4_1; + i64toi32_i32$0 = $4; i64toi32_i32$2 = $7$hi; i64toi32_i32$3 = $12; i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2 | 0; - i64toi32_i32$2 = $4(i64toi32_i32$0 | i64toi32_i32$3 | 0 | 0, i64toi32_i32$2 | 0) | 0; + i64toi32_i32$2 = test32_i64(i64toi32_i32$0 | i64toi32_i32$3 | 0 | 0, i64toi32_i32$2 | 0) | 0; i64toi32_i32$0 = i64toi32_i32$HIGH_BITS; - $2_1 = i64toi32_i32$2; + $2 = i64toi32_i32$2; $2$hi = i64toi32_i32$0; i64toi32_i32$1 = i64toi32_i32$2; i64toi32_i32$2 = 0; @@ -186,15 +186,15 @@ function asmFunc(imports) { } setTempRet0($13 | 0); i64toi32_i32$2 = $2$hi; - return $2_1 | 0; + return $2 | 0; } return { - "test8": $0, - "test16": $1, - "test8_i64": legalstub$2, - "test16_i64": legalstub$3, - "test32_i64": legalstub$4 + "test8": test8, + "test16": test16, + "test8_i64": legalstub$test8_i64, + "test16_i64": legalstub$test16_i64, + "test32_i64": legalstub$test32_i64 }; } diff --git a/test/wasm2js/sign_ext.2asm.js.opt b/test/wasm2js/sign_ext.2asm.js.opt index 41f79ecc58a..650b1c320b6 100644 --- a/test/wasm2js/sign_ext.2asm.js.opt +++ b/test/wasm2js/sign_ext.2asm.js.opt @@ -14,42 +14,42 @@ function asmFunc(imports) { var env = imports.env; var setTempRet0 = env.setTempRet0; var i64toi32_i32$HIGH_BITS = 0; - function $0($0_1) { - $0_1 = $0_1 | 0; - return $0_1 << 24 >> 24; + function test8($0) { + $0 = $0 | 0; + return $0 << 24 >> 24; } - function $1($0_1) { - $0_1 = $0_1 | 0; - return $0_1 << 16 >> 16; + function test16($0) { + $0 = $0 | 0; + return $0 << 16 >> 16; } - function legalstub$2($0_1, $1_1) { - $0_1 = $0_1 << 24 >> 24; - i64toi32_i32$HIGH_BITS = $0_1 >> 31; + function legalstub$test8_i64($0, $1) { + $0 = $0 << 24 >> 24; + i64toi32_i32$HIGH_BITS = $0 >> 31; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $0; } - function legalstub$3($0_1, $1_1) { - $0_1 = $0_1 << 16 >> 16; - i64toi32_i32$HIGH_BITS = $0_1 >> 31; + function legalstub$test16_i64($0, $1) { + $0 = $0 << 16 >> 16; + i64toi32_i32$HIGH_BITS = $0 >> 31; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $0; } - function legalstub$4($0_1, $1_1) { - i64toi32_i32$HIGH_BITS = $0_1 >> 31; + function legalstub$test32_i64($0, $1) { + i64toi32_i32$HIGH_BITS = $0 >> 31; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $0; } return { - "test8": $0, - "test16": $1, - "test8_i64": legalstub$2, - "test16_i64": legalstub$3, - "test32_i64": legalstub$4 + "test8": test8, + "test16": test16, + "test8_i64": legalstub$test8_i64, + "test16_i64": legalstub$test16_i64, + "test32_i64": legalstub$test32_i64 }; } diff --git a/test/wasm2js/sign_ext.wast b/test/wasm2js/sign_ext.wast index 825502a3f35..6a3f91515f5 100644 --- a/test/wasm2js/sign_ext.wast +++ b/test/wasm2js/sign_ext.wast @@ -1,17 +1,17 @@ (module - (func "test8" (param $x i32) (result i32) + (func $test8 (export "test8") (param $x i32) (result i32) (i32.extend8_s (local.get $x)) ) - (func "test16" (param $x i32) (result i32) + (func $test16 (export "test16") (param $x i32) (result i32) (i32.extend16_s (local.get $x)) ) - (func "test8_i64" (param $x i64) (result i64) + (func $test8_i64 (export "test8_i64") (param $x i64) (result i64) (i64.extend8_s (local.get $x)) ) - (func "test16_i64" (param $x i64) (result i64) + (func $test16_i64 (export "test16_i64") (param $x i64) (result i64) (i64.extend16_s (local.get $x)) ) - (func "test32_i64" (param $x i64) (result i64) + (func $test32_i64 (export "test32_i64") (param $x i64) (result i64) (i64.extend32_s (local.get $x)) ) )