From 2ba16964d4f8e574a5b2229fbcbcdf1a012af67a Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 20 Dec 2023 12:34:36 -0800 Subject: [PATCH 1/2] Match names more precisely in update_lit_checks.py Previously the lit test update script interpreted module names as the names of import items and export names as the names of export items, but it is more precise to use the actual identifiers of the imported or exported items as the names instead. Update update_lit_checks.py to use a more correct regex to match names and to correctly use the identifiers of import and export items as their names. In some cases this can improve the readability of test output. --- scripts/update_lit_checks.py | 20 ++++--- test/lit/basic/empty_imported_table.wast | 9 ++-- test/lit/basic/export-import.wast | 19 ++++--- test/lit/basic/hello_world.wat | 3 +- test/lit/basic/imported_memory.wast | 11 ++-- test/lit/basic/imported_memory_growth.wast | 11 ++-- test/lit/basic/memory-import.wast | 3 +- test/lit/basic/memory-import64.wast | 3 +- test/lit/basic/min.wast | 3 +- test/lit/basic/multi-memories-basics.wast | 11 ++-- test/lit/basic/multi-table.wast | 7 +-- test/lit/basic/mutable-global.wast | 3 +- test/lit/basic/newsyntax.wast | 25 +++++---- test/lit/basic/polymorphic_stack.wast | 33 ++++++------ test/lit/basic/reference-types.wast | 10 ++-- test/lit/basic/table-import.wast | 9 ++-- test/lit/basic/tags.wast | 37 ++++++------- test/lit/basic/unit.wat | 24 +++++---- .../ctor-eval/ctor_after_serialization.wat | 28 +++++----- test/lit/ctor-eval/extern.wast | 45 ++++++++-------- test/lit/ctor-eval/table.wat | 11 ++-- test/lit/ctor-eval/v128.wast | 3 +- .../generate-dyncalls_all-features.wast | 3 +- test/lit/passes/gufa.wast | 23 ++++---- .../inlining-optimizing_optimize-level=3.wast | 52 +++++++++--------- test/lit/passes/jspi-args.wast | 8 +-- test/lit/passes/jspi-table.wast | 3 +- test/lit/passes/jspi.wast | 32 ++++++----- ...egalize-js-interface-exported-helpers.wast | 9 ++-- .../legalize-js-interface-minimally.wast | 6 ++- .../legalize-js-interface_all-features.wast | 21 +++++--- ...egalize-js-interface-export-originals.wast | 4 +- .../remove-unused-module-elements-refs.wast | 40 ++++++++------ ...e-unused-module-elements_all-features.wast | 53 ++++++++++++------- .../lit/wasm-split/jspi-secondary-export.wast | 43 +++++++-------- test/lit/wasm-split/jspi.wast | 4 +- .../multi-memory-lowering-export.wast | 15 +++--- .../multi-memory-lowering-import.wast | 11 ++-- test/lit/wat-kitchen-sink.wast | 15 +++--- 39 files changed, 392 insertions(+), 278 deletions(-) diff --git a/scripts/update_lit_checks.py b/scripts/update_lit_checks.py index 79af92ab986..b1d89bc3305 100755 --- a/scripts/update_lit_checks.py +++ b/scripts/update_lit_checks.py @@ -37,12 +37,15 @@ CHECK_PREFIX_RE = re.compile(r'.*--check-prefix[= ](\S+).*') MODULE_RE = re.compile(r'^\(module.*$', re.MULTILINE) -ALL_ITEMS = '|'.join(['type', 'import', 'global', 'memory', 'data', 'table', - 'elem', 'tag', 'export', 'start', 'func']) +DECL_ITEMS = '|'.join(['type', 'global', 'memory', 'data', 'table', + 'elem', 'tag', 'start', 'func']) +IMPORT_ITEM = r'import\s*"[^"]*"\s*"[^"]*"\s*\((?:' + DECL_ITEMS + ')' +EXPORT_ITEM = f'export\s*"[^"]*"\s*\((?:' + DECL_ITEMS + ')' +ALL_ITEMS = DECL_ITEMS + '|' + IMPORT_ITEM + '|' + EXPORT_ITEM # Regular names as well as the "declare" in (elem declare ... to get declarative # segments included in the output. -ITEM_NAME = r'\$[^\s()]*|"[^\s()]*"|declare' +ITEM_NAME = r'\$[^\s()]*|\$"[^"]*"|declare' # FIXME: This does not handle nested string contents. For example, # (data (i32.const 10) "hello(") @@ -55,6 +58,11 @@ FUZZ_EXEC_FUNC = re.compile(r'^\[fuzz-exec\] calling (?P\S*)$') +def indentKindName(match): + # Return the indent, kind, and name from an ITEM_RE match + return (match[1], match[2].split()[0], match[3]) + + def warn(msg): print(f'warning: {msg}', file=sys.stderr) @@ -141,7 +149,7 @@ def parse_output_modules(text): for module in split_modules(text): items = [] for match in ITEM_RE.finditer(module): - kind, name = match[2], match[3] + _, kind, name = indentKindName(match) end = find_end(module, match.end(1)) lines = module[match.start():end].split('\n') items.append(((kind, name), lines)) @@ -247,7 +255,7 @@ def update_test(args, test, lines, tmp): for line in lines: match = ITEM_RE.match(line) if match: - kind, name = match[2], match[3] + _, kind, name = indentKindName(match) named_items.append((kind, name)) script = script_name @@ -286,7 +294,7 @@ def pad(line): output_lines.append(line) continue - indent, kind, name = match.groups() + indent, kind, name = indentKindName(match) for prefix, items in output.items(): # If the output for this prefix contains an item with this diff --git a/test/lit/basic/empty_imported_table.wast b/test/lit/basic/empty_imported_table.wast index 1a874dc0835..5cc6d178ca0 100644 --- a/test/lit/basic/empty_imported_table.wast +++ b/test/lit/basic/empty_imported_table.wast @@ -10,12 +10,15 @@ ;; RUN: cat %t.bin.nodebug.wast | filecheck %s --check-prefix=CHECK-BIN-NODEBUG (module - ;; CHECK-TEXT: (import "env" "table" (table $timport$0 0 0 funcref)) - ;; CHECK-BIN: (import "env" "table" (table $timport$0 0 0 funcref)) - ;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 0 0 funcref)) (import "env" "table" (table 0 0 funcref)) + ;; CHECK-TEXT: (import "env" "table" (table $timport$0 0 0 funcref)) + ;; CHECK-TEXT: (memory $0 0) + ;; CHECK-BIN: (import "env" "table" (table $timport$0 0 0 funcref)) + ;; CHECK-BIN: (memory $0 0) + ;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 0 0 funcref)) + ;; CHECK-BIN-NODEBUG: (memory $0 0) (memory $0 0) ) diff --git a/test/lit/basic/export-import.wast b/test/lit/basic/export-import.wast index 853e1d93a7b..717681138b4 100644 --- a/test/lit/basic/export-import.wast +++ b/test/lit/basic/export-import.wast @@ -14,21 +14,26 @@ ;; CHECK-BIN: (type $v (func)) (type $v (func)) ;; CHECK-TEXT: (import "env" "test2" (global $test2 i32)) - ;; CHECK-BIN: (import "env" "test2" (global $test2 i32)) - ;; CHECK-BIN-NODEBUG: (type $0 (func)) - ;; CHECK-BIN-NODEBUG: (import "env" "test2" (global $gimport$0 i32)) - (import "env" "test1" (func $test1)) ;; CHECK-TEXT: (import "env" "test1" (func $test1 (type $v))) + ;; CHECK-BIN: (import "env" "test2" (global $test2 i32)) + ;; CHECK-BIN: (import "env" "test1" (func $test1 (type $v))) - ;; CHECK-BIN-NODEBUG: (import "env" "test1" (func $fimport$0 (type $0))) + (import "env" "test1" (func $test1)) (import "env" "test2" (global $test2 i32)) ;; CHECK-TEXT: (export "test1" (func $test1)) ;; CHECK-BIN: (export "test1" (func $test1)) - ;; CHECK-BIN-NODEBUG: (export "test1" (func $fimport$0)) (export "test1" (func $test1)) ;; CHECK-TEXT: (export "test2" (global $test2)) ;; CHECK-BIN: (export "test2" (global $test2)) - ;; CHECK-BIN-NODEBUG: (export "test2" (global $gimport$0)) (export "test2" (global $test2)) ) +;; CHECK-BIN-NODEBUG: (type $0 (func)) + +;; CHECK-BIN-NODEBUG: (import "env" "test2" (global $gimport$0 i32)) + +;; CHECK-BIN-NODEBUG: (import "env" "test1" (func $fimport$0 (type $0))) + +;; CHECK-BIN-NODEBUG: (export "test1" (func $fimport$0)) + +;; CHECK-BIN-NODEBUG: (export "test2" (global $gimport$0)) diff --git a/test/lit/basic/hello_world.wat b/test/lit/basic/hello_world.wat index 5ddb3012845..1ba2f901285 100644 --- a/test/lit/basic/hello_world.wat +++ b/test/lit/basic/hello_world.wat @@ -21,7 +21,6 @@ (memory $0 256 256) ;; CHECK-TEXT: (export "add" (func $add)) ;; CHECK-BIN: (export "add" (func $add)) - ;; CHECK-BIN-NODEBUG: (export "add" (func $0)) (export "add" (func $add)) ;; CHECK-TEXT: (func $add (type $i32_i32_=>_i32) (param $x i32) (param $y i32) (result i32) ;; CHECK-TEXT-NEXT: (i32.add @@ -42,6 +41,8 @@ ) ) ) +;; CHECK-BIN-NODEBUG: (export "add" (func $0)) + ;; CHECK-BIN-NODEBUG: (func $0 (type $0) (param $0 i32) (param $1 i32) (result i32) ;; CHECK-BIN-NODEBUG-NEXT: (i32.add ;; CHECK-BIN-NODEBUG-NEXT: (local.get $0) diff --git a/test/lit/basic/imported_memory.wast b/test/lit/basic/imported_memory.wast index 52eccce7f07..1fa9aaa3840 100644 --- a/test/lit/basic/imported_memory.wast +++ b/test/lit/basic/imported_memory.wast @@ -12,10 +12,13 @@ (module ;; CHECK-TEXT: (import "env" "memory" (memory $0 256 256)) ;; CHECK-BIN: (import "env" "memory" (memory $0 256 256)) - ;; CHECK-BIN-NODEBUG: (import "env" "memory" (memory $mimport$0 256 256)) (import "env" "memory" (memory $0 256 256)) - ;; CHECK-TEXT: (import "env" "table" (table $timport$0 256 256 funcref)) - ;; CHECK-BIN: (import "env" "table" (table $timport$0 256 256 funcref)) - ;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 256 256 funcref)) (import "env" "table" (table 256 256 funcref)) ) +;; CHECK-TEXT: (import "env" "table" (table $timport$0 256 256 funcref)) + +;; CHECK-BIN: (import "env" "table" (table $timport$0 256 256 funcref)) + +;; CHECK-BIN-NODEBUG: (import "env" "memory" (memory $mimport$0 256 256)) + +;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 256 256 funcref)) diff --git a/test/lit/basic/imported_memory_growth.wast b/test/lit/basic/imported_memory_growth.wast index d1d62c2d985..aa5d02d4760 100644 --- a/test/lit/basic/imported_memory_growth.wast +++ b/test/lit/basic/imported_memory_growth.wast @@ -12,10 +12,13 @@ (module ;; CHECK-TEXT: (import "env" "memory" (memory $0 256)) ;; CHECK-BIN: (import "env" "memory" (memory $0 256)) - ;; CHECK-BIN-NODEBUG: (import "env" "memory" (memory $mimport$0 256)) (import "env" "memory" (memory $0 256)) - ;; CHECK-TEXT: (import "env" "table" (table $timport$0 256 funcref)) - ;; CHECK-BIN: (import "env" "table" (table $timport$0 256 funcref)) - ;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 256 funcref)) (import "env" "table" (table 256 funcref)) ) +;; CHECK-TEXT: (import "env" "table" (table $timport$0 256 funcref)) + +;; CHECK-BIN: (import "env" "table" (table $timport$0 256 funcref)) + +;; CHECK-BIN-NODEBUG: (import "env" "memory" (memory $mimport$0 256)) + +;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 256 funcref)) diff --git a/test/lit/basic/memory-import.wast b/test/lit/basic/memory-import.wast index fb6a3d62317..ce761653ddd 100644 --- a/test/lit/basic/memory-import.wast +++ b/test/lit/basic/memory-import.wast @@ -16,7 +16,6 @@ (type $0 (func (result i32))) ;; CHECK-TEXT: (import "env" "memory" (memory $0 1 1)) ;; CHECK-BIN: (import "env" "memory" (memory $0 1 1)) - ;; CHECK-BIN-NODEBUG: (import "env" "memory" (memory $mimport$0 1 1)) (import "env" "memory" (memory $0 1 1)) ;; CHECK-TEXT: (func $foo (type $0) (result i32) @@ -35,6 +34,8 @@ ) ) ) +;; CHECK-BIN-NODEBUG: (import "env" "memory" (memory $mimport$0 1 1)) + ;; CHECK-BIN-NODEBUG: (func $0 (type $0) (result i32) ;; CHECK-BIN-NODEBUG-NEXT: (i32.load offset=13 ;; CHECK-BIN-NODEBUG-NEXT: (i32.const 37) diff --git a/test/lit/basic/memory-import64.wast b/test/lit/basic/memory-import64.wast index 7794d6b5fd5..38362d6b2d1 100644 --- a/test/lit/basic/memory-import64.wast +++ b/test/lit/basic/memory-import64.wast @@ -16,7 +16,6 @@ (type $0 (func (result i32))) ;; CHECK-TEXT: (import "env" "memory" (memory $0 i64 1 1)) ;; CHECK-BIN: (import "env" "memory" (memory $0 i64 1 1)) - ;; CHECK-BIN-NODEBUG: (import "env" "memory" (memory $mimport$0 i64 1 1)) (import "env" "memory" (memory $0 i64 1 1)) ;; CHECK-TEXT: (func $foo (type $0) (result i32) @@ -35,6 +34,8 @@ ) ) ) +;; CHECK-BIN-NODEBUG: (import "env" "memory" (memory $mimport$0 i64 1 1)) + ;; CHECK-BIN-NODEBUG: (func $0 (type $0) (result i32) ;; CHECK-BIN-NODEBUG-NEXT: (i32.load offset=13 ;; CHECK-BIN-NODEBUG-NEXT: (i64.const 37) diff --git a/test/lit/basic/min.wast b/test/lit/basic/min.wast index 74898f59fe5..44928cd832f 100644 --- a/test/lit/basic/min.wast +++ b/test/lit/basic/min.wast @@ -32,7 +32,6 @@ (memory $0 256 256) ;; CHECK-TEXT: (export "floats" (func $floats)) ;; CHECK-BIN: (export "floats" (func $floats)) - ;; CHECK-BIN-NODEBUG: (export "floats" (func $0)) (export "floats" (func $floats)) ;; CHECK-TEXT: (func $floats (type $0) (param $f f32) (result f32) @@ -183,6 +182,8 @@ ) ) ) +;; CHECK-BIN-NODEBUG: (export "floats" (func $0)) + ;; CHECK-BIN-NODEBUG: (func $0 (type $0) (param $0 f32) (result f32) ;; CHECK-BIN-NODEBUG-NEXT: (local $1 f32) ;; CHECK-BIN-NODEBUG-NEXT: (f32.add diff --git a/test/lit/basic/multi-memories-basics.wast b/test/lit/basic/multi-memories-basics.wast index c9e4d6c7ed8..3f023079d78 100644 --- a/test/lit/basic/multi-memories-basics.wast +++ b/test/lit/basic/multi-memories-basics.wast @@ -18,11 +18,6 @@ (type $none_=>_i32 (func (result i32))) ;; CHECK-TEXT: (import "env" "memory" (memory $importedMemory 1 1)) ;; CHECK-BIN: (import "env" "memory" (memory $importedMemory 1 1)) - ;; CHECK-BIN-NODEBUG: (type $0 (func)) - - ;; CHECK-BIN-NODEBUG: (type $1 (func (result i32))) - - ;; CHECK-BIN-NODEBUG: (import "env" "memory" (memory $mimport$0 1 1)) (import "env" "memory" (memory $importedMemory 1 1)) ;; CHECK-TEXT: (memory $memory1 1 500) ;; CHECK-BIN: (memory $memory1 1 500) @@ -367,6 +362,12 @@ ) ) ) +;; CHECK-BIN-NODEBUG: (type $0 (func)) + +;; CHECK-BIN-NODEBUG: (type $1 (func (result i32))) + +;; CHECK-BIN-NODEBUG: (import "env" "memory" (memory $mimport$0 1 1)) + ;; CHECK-BIN-NODEBUG: (memory $0 1 500) ;; CHECK-BIN-NODEBUG: (memory $1 1 800) diff --git a/test/lit/basic/multi-table.wast b/test/lit/basic/multi-table.wast index d5c7b10aa83..b856f8494c5 100644 --- a/test/lit/basic/multi-table.wast +++ b/test/lit/basic/multi-table.wast @@ -25,9 +25,6 @@ ;; CHECK-BIN: (global $g2 i32 (i32.const 0)) (global $g2 i32 (i32.const 0)) - ;; CHECK-BIN-NODEBUG: (type $0 (func)) - - ;; CHECK-BIN-NODEBUG: (import "a" "b" (table $timport$0 1 10 funcref)) (import "a" "b" (table $t1 1 10 funcref)) ;; CHECK-TEXT: (table $t2 3 3 funcref) ;; CHECK-BIN: (table $t2 3 3 funcref) @@ -116,6 +113,10 @@ ;; CHECK-BIN-NEXT: ) (func $h) ) +;; CHECK-BIN-NODEBUG: (type $0 (func)) + +;; CHECK-BIN-NODEBUG: (import "a" "b" (table $timport$0 1 10 funcref)) + ;; CHECK-BIN-NODEBUG: (global $global$0 (ref null $0) (ref.func $0)) ;; CHECK-BIN-NODEBUG: (global $global$1 i32 (i32.const 0)) diff --git a/test/lit/basic/mutable-global.wast b/test/lit/basic/mutable-global.wast index 154a40a191f..fff5d8d5b60 100644 --- a/test/lit/basic/mutable-global.wast +++ b/test/lit/basic/mutable-global.wast @@ -16,7 +16,6 @@ (type $0 (func)) ;; CHECK-TEXT: (import "env" "global-mut" (global $global-mut (mut i32))) ;; CHECK-BIN: (import "env" "global-mut" (global $global-mut (mut i32))) - ;; CHECK-BIN-NODEBUG: (import "env" "global-mut" (global $gimport$0 (mut i32))) (import "env" "global-mut" (global $global-mut (mut i32))) ;; CHECK-TEXT: (func $foo (type $0) @@ -44,6 +43,8 @@ ) ) ) +;; CHECK-BIN-NODEBUG: (import "env" "global-mut" (global $gimport$0 (mut i32))) + ;; CHECK-BIN-NODEBUG: (func $0 (type $0) ;; CHECK-BIN-NODEBUG-NEXT: (global.set $gimport$0 ;; CHECK-BIN-NODEBUG-NEXT: (i32.add diff --git a/test/lit/basic/newsyntax.wast b/test/lit/basic/newsyntax.wast index 204bed3ab08..33d805c3122 100644 --- a/test/lit/basic/newsyntax.wast +++ b/test/lit/basic/newsyntax.wast @@ -10,22 +10,13 @@ ;; RUN: cat %t.bin.nodebug.wast | filecheck %s --check-prefix=CHECK-BIN-NODEBUG (module + (import "env" "table" (table 9 9 funcref)) + ;; CHECK-TEXT: (type $0 (func)) ;; CHECK-TEXT: (type $1 (func (param i32 f64) (result i32))) ;; CHECK-TEXT: (import "env" "table" (table $timport$0 9 9 funcref)) - ;; CHECK-BIN: (type $0 (func)) - - ;; CHECK-BIN: (type $1 (func (param i32 f64) (result i32))) - - ;; CHECK-BIN: (import "env" "table" (table $timport$0 9 9 funcref)) - ;; CHECK-BIN-NODEBUG: (type $0 (func)) - - ;; CHECK-BIN-NODEBUG: (type $1 (func (param i32 f64) (result i32))) - - ;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 9 9 funcref)) - (import "env" "table" (table 9 9 funcref)) ;; CHECK-TEXT: (export "call_indirect" (func $call_indirect)) @@ -41,6 +32,12 @@ ;; CHECK-TEXT-NEXT: (i32.const 1) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) + ;; CHECK-BIN: (type $0 (func)) + + ;; CHECK-BIN: (type $1 (func (param i32 f64) (result i32))) + + ;; CHECK-BIN: (import "env" "table" (table $timport$0 9 9 funcref)) + ;; CHECK-BIN: (export "call_indirect" (func $call_indirect)) ;; CHECK-BIN: (func $call_indirect (type $0) @@ -62,6 +59,12 @@ (call_indirect (i32.const 1)) ) ) +;; CHECK-BIN-NODEBUG: (type $0 (func)) + +;; CHECK-BIN-NODEBUG: (type $1 (func (param i32 f64) (result i32))) + +;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 9 9 funcref)) + ;; CHECK-BIN-NODEBUG: (export "call_indirect" (func $0)) ;; CHECK-BIN-NODEBUG: (func $0 (type $0) diff --git a/test/lit/basic/polymorphic_stack.wast b/test/lit/basic/polymorphic_stack.wast index f91847817e6..d51117e16f9 100644 --- a/test/lit/basic/polymorphic_stack.wast +++ b/test/lit/basic/polymorphic_stack.wast @@ -17,26 +17,13 @@ ;; CHECK-BIN: (type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$ii (func (param i32) (result i32))) + (import "env" "table" (table 9 9 funcref)) + ;; CHECK-TEXT: (type $2 (func)) ;; CHECK-TEXT: (type $3 (func (param i32))) ;; CHECK-TEXT: (import "env" "table" (table $timport$0 9 9 funcref)) - ;; CHECK-BIN: (type $2 (func)) - - ;; CHECK-BIN: (type $3 (func (param i32))) - - ;; CHECK-BIN: (import "env" "table" (table $timport$0 9 9 funcref)) - ;; CHECK-BIN-NODEBUG: (type $0 (func (result i32))) - - ;; CHECK-BIN-NODEBUG: (type $1 (func (param i32) (result i32))) - - ;; CHECK-BIN-NODEBUG: (type $2 (func)) - - ;; CHECK-BIN-NODEBUG: (type $3 (func (param i32))) - - ;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 9 9 funcref)) - (import "env" "table" (table 9 9 funcref)) ;; CHECK-TEXT: (func $break-and-binary (type $0) (result i32) ;; CHECK-TEXT-NEXT: (block $x (result i32) @@ -53,6 +40,12 @@ ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) + ;; CHECK-BIN: (type $2 (func)) + + ;; CHECK-BIN: (type $3 (func (param i32))) + + ;; CHECK-BIN: (import "env" "table" (table $timport$0 9 9 funcref)) + ;; CHECK-BIN: (func $break-and-binary (type $0) (result i32) ;; CHECK-BIN-NEXT: (block $label$1 (result i32) ;; CHECK-BIN-NEXT: (unreachable) @@ -371,6 +364,16 @@ ) ) ) +;; CHECK-BIN-NODEBUG: (type $0 (func (result i32))) + +;; CHECK-BIN-NODEBUG: (type $1 (func (param i32) (result i32))) + +;; CHECK-BIN-NODEBUG: (type $2 (func)) + +;; CHECK-BIN-NODEBUG: (type $3 (func (param i32))) + +;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 9 9 funcref)) + ;; CHECK-BIN-NODEBUG: (func $0 (type $0) (result i32) ;; CHECK-BIN-NODEBUG-NEXT: (block $label$1 (result i32) ;; CHECK-BIN-NODEBUG-NEXT: (unreachable) diff --git a/test/lit/basic/reference-types.wast b/test/lit/basic/reference-types.wast index 9a3a5c663c9..2b502d78939 100644 --- a/test/lit/basic/reference-types.wast +++ b/test/lit/basic/reference-types.wast @@ -174,11 +174,7 @@ (import "env" "import_func" (func $import_func (param eqref) (result funcref))) (import "env" "import_global" (global $import_global eqref)) - ;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32)) - - ;; CHECK-BIN-NODEBUG: (export "export_func" (func $fimport$0)) (export "export_func" (func $import_func (param eqref) (result funcref))) - ;; CHECK-BIN-NODEBUG: (export "export_global" (global $gimport$0)) (export "export_global" (global $import_global)) ;; Test global initializer expressions @@ -1846,6 +1842,12 @@ ;; CHECK-BIN-NEXT: ) (func $ref-taken-but-not-in-table) ) +;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32)) + +;; CHECK-BIN-NODEBUG: (export "export_func" (func $fimport$0)) + +;; CHECK-BIN-NODEBUG: (export "export_global" (global $gimport$0)) + ;; CHECK-BIN-NODEBUG: (func $0 (type $4) (param $0 eqref) ;; CHECK-BIN-NODEBUG-NEXT: (nop) ;; CHECK-BIN-NODEBUG-NEXT: ) diff --git a/test/lit/basic/table-import.wast b/test/lit/basic/table-import.wast index 347da5634ff..79e6f6eeb79 100644 --- a/test/lit/basic/table-import.wast +++ b/test/lit/basic/table-import.wast @@ -14,13 +14,16 @@ ;; CHECK-BIN: (type $0 (func)) ;; CHECK-BIN-NODEBUG: (type $0 (func)) (type $0 (func)) - ;; CHECK-TEXT: (import "env" "table" (table $timport$0 1 1 funcref)) - ;; CHECK-BIN: (import "env" "table" (table $timport$0 1 1 funcref)) - ;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 1 1 funcref)) (import "env" "table" (table 1 1 funcref)) (elem (i32.const 0) $foo) + ;; CHECK-TEXT: (import "env" "table" (table $timport$0 1 1 funcref)) + ;; CHECK-TEXT: (memory $0 0) + ;; CHECK-BIN: (import "env" "table" (table $timport$0 1 1 funcref)) + ;; CHECK-BIN: (memory $0 0) + ;; CHECK-BIN-NODEBUG: (import "env" "table" (table $timport$0 1 1 funcref)) + ;; CHECK-BIN-NODEBUG: (memory $0 0) (memory $0 0) diff --git a/test/lit/basic/tags.wast b/test/lit/basic/tags.wast index e6c5d2ccc50..5fbc0b81106 100644 --- a/test/lit/basic/tags.wast +++ b/test/lit/basic/tags.wast @@ -56,13 +56,6 @@ (tag $e-export (export "ex0") (param i32)) (tag $e-import (import "env" "im0") (param i32)) - ;; CHECK-BIN-NODEBUG: (type $0 (func (param i32 f32))) - - ;; CHECK-BIN-NODEBUG: (type $1 (func (param i32))) - - ;; CHECK-BIN-NODEBUG: (type $2 (func)) - - ;; CHECK-BIN-NODEBUG: (import "env" "im0" (tag $eimport$0 (param i32))) (import "env" "im1" (tag (param i32 f32))) ;; CHECK-TEXT: (export "ex0" (tag $e-export)) @@ -70,22 +63,30 @@ ;; CHECK-BIN: (export "ex0" (tag $e-export)) ;; CHECK-BIN: (export "ex1" (tag $e)) - ;; CHECK-BIN-NODEBUG: (import "env" "im1" (tag $eimport$1 (param i32 f32))) + (export "ex1" (tag $e)) +) +;; CHECK-BIN-NODEBUG: (type $0 (func (param i32 f32))) - ;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32)) +;; CHECK-BIN-NODEBUG: (type $1 (func (param i32))) - ;; CHECK-BIN-NODEBUG: (tag $tag$1 (param i32 f32)) +;; CHECK-BIN-NODEBUG: (type $2 (func)) - ;; CHECK-BIN-NODEBUG: (tag $tag$2) +;; CHECK-BIN-NODEBUG: (import "env" "im0" (tag $eimport$0 (param i32))) - ;; CHECK-BIN-NODEBUG: (tag $tag$3 (param i32 f32)) +;; CHECK-BIN-NODEBUG: (import "env" "im1" (tag $eimport$1 (param i32 f32))) - ;; CHECK-BIN-NODEBUG: (tag $tag$4 (param i32 f32)) +;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32)) - ;; CHECK-BIN-NODEBUG: (tag $tag$5 (param i32)) +;; CHECK-BIN-NODEBUG: (tag $tag$1 (param i32 f32)) - ;; CHECK-BIN-NODEBUG: (export "ex0" (tag $tag$5)) +;; CHECK-BIN-NODEBUG: (tag $tag$2) - ;; CHECK-BIN-NODEBUG: (export "ex1" (tag $tag$1)) - (export "ex1" (tag $e)) -) +;; CHECK-BIN-NODEBUG: (tag $tag$3 (param i32 f32)) + +;; CHECK-BIN-NODEBUG: (tag $tag$4 (param i32 f32)) + +;; CHECK-BIN-NODEBUG: (tag $tag$5 (param i32)) + +;; CHECK-BIN-NODEBUG: (export "ex0" (tag $tag$5)) + +;; CHECK-BIN-NODEBUG: (export "ex1" (tag $tag$1)) diff --git a/test/lit/basic/unit.wat b/test/lit/basic/unit.wat index 8392a226948..4fc36b3b7ea 100644 --- a/test/lit/basic/unit.wat +++ b/test/lit/basic/unit.wat @@ -64,20 +64,23 @@ (type $9 (func (param i32 i64))) ;; CHECK-TEXT: (import "env" "_emscripten_asm_const_vi" (func $_emscripten_asm_const_vi (type $FUNCSIG$v))) ;; CHECK-BIN: (import "env" "_emscripten_asm_const_vi" (func $_emscripten_asm_const_vi (type $FUNCSIG$v))) - ;; CHECK-BIN-NODEBUG: (import "env" "_emscripten_asm_const_vi" (func $fimport$0 (type $1))) (import "env" "_emscripten_asm_const_vi" (func $_emscripten_asm_const_vi)) ;; CHECK-TEXT: (import "asm2wasm" "f64-to-int" (func $f64-to-int (type $FUNCSIG$id) (param f64) (result i32))) ;; CHECK-BIN: (import "asm2wasm" "f64-to-int" (func $f64-to-int (type $FUNCSIG$id) (param f64) (result i32))) - ;; CHECK-BIN-NODEBUG: (import "asm2wasm" "f64-to-int" (func $fimport$1 (type $5) (param f64) (result i32))) (import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32))) ;; CHECK-TEXT: (import "asm2wasm" "f64-rem" (func $f64-rem (type $FUNCSIG$ddd) (param f64 f64) (result f64))) ;; CHECK-BIN: (import "asm2wasm" "f64-rem" (func $f64-rem (type $FUNCSIG$ddd) (param f64 f64) (result f64))) - ;; CHECK-BIN-NODEBUG: (import "asm2wasm" "f64-rem" (func $fimport$2 (type $4) (param f64 f64) (result f64))) (import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64))) (table 10 funcref) (elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) ;; CHECK-TEXT: (memory $0 4096 4096) ;; CHECK-BIN: (memory $0 4096 4096) + ;; CHECK-BIN-NODEBUG: (import "env" "_emscripten_asm_const_vi" (func $fimport$0 (type $1))) + + ;; CHECK-BIN-NODEBUG: (import "asm2wasm" "f64-to-int" (func $fimport$1 (type $5) (param f64) (result i32))) + + ;; CHECK-BIN-NODEBUG: (import "asm2wasm" "f64-rem" (func $fimport$2 (type $4) (param f64 f64) (result f64))) + ;; CHECK-BIN-NODEBUG: (memory $0 4096 4096) (memory $0 4096 4096) (data (i32.const 1026) "\14\00") @@ -95,13 +98,6 @@ ;; CHECK-BIN: (elem $0 (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) ;; CHECK-BIN: (export "big_negative" (func $big_negative)) - ;; CHECK-BIN-NODEBUG: (data $0 (i32.const 1026) "\14\00") - - ;; CHECK-BIN-NODEBUG: (table $0 10 funcref) - - ;; CHECK-BIN-NODEBUG: (elem $0 (i32.const 0) $17 $0 $17 $17 $18 $18 $1 $18 $17 $15) - - ;; CHECK-BIN-NODEBUG: (export "big_negative" (func $0)) (export "big_negative" (func $big_negative)) ;; CHECK-TEXT: (func $big_negative (type $FUNCSIG$v) ;; CHECK-TEXT-NEXT: (local $temp f64) @@ -1743,6 +1739,14 @@ ) ) ) +;; CHECK-BIN-NODEBUG: (data $0 (i32.const 1026) "\14\00") + +;; CHECK-BIN-NODEBUG: (table $0 10 funcref) + +;; CHECK-BIN-NODEBUG: (elem $0 (i32.const 0) $17 $0 $17 $17 $18 $18 $1 $18 $17 $15) + +;; CHECK-BIN-NODEBUG: (export "big_negative" (func $0)) + ;; CHECK-BIN-NODEBUG: (func $0 (type $1) ;; CHECK-BIN-NODEBUG-NEXT: (local $0 f64) ;; CHECK-BIN-NODEBUG-NEXT: (local.set $0 diff --git a/test/lit/ctor-eval/ctor_after_serialization.wat b/test/lit/ctor-eval/ctor_after_serialization.wat index 45e811804fa..df37f7e8bb6 100644 --- a/test/lit/ctor-eval/ctor_after_serialization.wat +++ b/test/lit/ctor-eval/ctor_after_serialization.wat @@ -10,15 +10,7 @@ ;; CHECK: (type $A (struct )) (type $A (struct)) - ;; CHECK: (type $1 (func (result (ref any)))) - - ;; CHECK: (type $2 (func)) - - ;; CHECK: (global $ctor-eval$global (ref $A) (struct.new_default $A)) - - ;; CHECK: (export "new" (func $new_2)) (export "new" (func $new)) - ;; CHECK: (export "nop" (func $nop_3)) (export "nop" (func $nop)) (func $new (result (ref any)) @@ -30,6 +22,16 @@ ) ) +;; CHECK: (type $1 (func (result (ref any)))) + +;; CHECK: (type $2 (func)) + +;; CHECK: (global $ctor-eval$global (ref $A) (struct.new_default $A)) + +;; CHECK: (export "new" (func $new_2)) + +;; CHECK: (export "nop" (func $nop_3)) + ;; CHECK: (func $new_2 (type $1) (result (ref any)) ;; CHECK-NEXT: (global.get $ctor-eval$global) ;; CHECK-NEXT: ) @@ -53,11 +55,7 @@ (struct.new_default $A) ) - ;; CHECK: (global $ctor-eval$global_1 (ref $A) (struct.new_default $A)) - - ;; CHECK: (export "new" (func $new_2)) (export "new" (func $new)) - ;; CHECK: (export "nop" (func $nop_3)) (export "nop" (func $nop)) (func $new (result (ref any)) @@ -69,6 +67,12 @@ (global.get $ctor-eval$global) ) ) +;; CHECK: (global $ctor-eval$global_1 (ref $A) (struct.new_default $A)) + +;; CHECK: (export "new" (func $new_2)) + +;; CHECK: (export "nop" (func $nop_3)) + ;; CHECK: (func $new_2 (type $1) (result (ref any)) ;; CHECK-NEXT: (global.get $ctor-eval$global_1) ;; CHECK-NEXT: ) diff --git a/test/lit/ctor-eval/extern.wast b/test/lit/ctor-eval/extern.wast index 5bb5c8cbc53..9a8779abfea 100644 --- a/test/lit/ctor-eval/extern.wast +++ b/test/lit/ctor-eval/extern.wast @@ -8,29 +8,8 @@ ;; CHECK: (type $struct (struct (field externref))) (type $struct (struct (field externref))) - ;; CHECK: (type $2 (func (result externref))) - - ;; CHECK: (type $3 (func (result anyref))) - - ;; CHECK: (global $ctor-eval$global (ref $array) (array.new_fixed $array 3 - ;; CHECK-NEXT: (i32.const 1) - ;; CHECK-NEXT: (i32.const 2) - ;; CHECK-NEXT: (i32.const 3) - ;; CHECK-NEXT: )) - - ;; CHECK: (global $ctor-eval$global_1 (ref $struct) (struct.new $struct - ;; CHECK-NEXT: (extern.externalize - ;; CHECK-NEXT: (ref.i31 - ;; CHECK-NEXT: (i32.const 1) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: )) - - ;; CHECK: (export "test1" (func $test1_3)) (export "test1" (func $test1)) - ;; CHECK: (export "test2" (func $test2_4)) (export "test2" (func $test2)) - ;; CHECK: (export "test3" (func $test3_5)) (export "test3" (func $test3)) (func $test1 (result externref) @@ -70,6 +49,30 @@ ) ) +;; CHECK: (type $2 (func (result externref))) + +;; CHECK: (type $3 (func (result anyref))) + +;; CHECK: (global $ctor-eval$global (ref $array) (array.new_fixed $array 3 +;; CHECK-NEXT: (i32.const 1) +;; CHECK-NEXT: (i32.const 2) +;; CHECK-NEXT: (i32.const 3) +;; CHECK-NEXT: )) + +;; CHECK: (global $ctor-eval$global_1 (ref $struct) (struct.new $struct +;; CHECK-NEXT: (extern.externalize +;; CHECK-NEXT: (ref.i31 +;; CHECK-NEXT: (i32.const 1) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: )) + +;; CHECK: (export "test1" (func $test1_3)) + +;; CHECK: (export "test2" (func $test2_4)) + +;; CHECK: (export "test3" (func $test3_5)) + ;; CHECK: (func $test1_3 (type $2) (result externref) ;; CHECK-NEXT: (extern.externalize ;; CHECK-NEXT: (ref.i31 diff --git a/test/lit/ctor-eval/table.wat b/test/lit/ctor-eval/table.wat index 73534f59b0d..0954faeea7d 100644 --- a/test/lit/ctor-eval/table.wat +++ b/test/lit/ctor-eval/table.wat @@ -10,11 +10,6 @@ (elem (i32.const 0) $nop) - ;; CHECK: (elem $0 (i32.const 0) $nop) - - ;; CHECK: (elem declare func $trap) - - ;; CHECK: (export "run" (func $run_3)) (export "run" (func $run)) (func $run (type $none_=>_none) @@ -35,6 +30,12 @@ ) ) + ;; CHECK: (elem $0 (i32.const 0) $nop) + + ;; CHECK: (elem declare func $trap) + + ;; CHECK: (export "run" (func $run_3)) + ;; CHECK: (func $nop (type $none_=>_none) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) diff --git a/test/lit/ctor-eval/v128.wast b/test/lit/ctor-eval/v128.wast index 03a7bb9d851..009ef57f25c 100644 --- a/test/lit/ctor-eval/v128.wast +++ b/test/lit/ctor-eval/v128.wast @@ -9,10 +9,11 @@ ;; CHECK: (memory $0 (shared 16 17)) (memory $0 (shared 16 17)) + (export "v128" (func $v128)) ;; CHECK: (data $0 (i32.const 23) "\e0\ff\c0N\8e\00\00\fe\01\00\12\81\85\fd\ff\90") ;; CHECK: (export "v128" (func $v128_2)) - (export "v128" (func $v128)) + ;; CHECK: (export "keepalive" (func $keepalive)) (export "keepalive" (func $keepalive)) diff --git a/test/lit/passes/generate-dyncalls_all-features.wast b/test/lit/passes/generate-dyncalls_all-features.wast index 34c387b0844..99611727b2a 100644 --- a/test/lit/passes/generate-dyncalls_all-features.wast +++ b/test/lit/passes/generate-dyncalls_all-features.wast @@ -73,8 +73,9 @@ ;; CHECK: (type $3 (func (param i32 i32))) ;; CHECK: (import "env" "table" (table $timport$0 1 1 funcref)) - (import "env" "invoke_vii" (func $invoke_vii (param i32 i32 i32))) + ;; CHECK: (import "env" "invoke_vii" (func $invoke_vii (type $0) (param i32 i32 i32))) + (import "env" "invoke_vii" (func $invoke_vii (param i32 i32 i32))) (import "env" "table" (table 1 1 funcref)) (elem (i32.const 0) $f) ;; CHECK: (elem $0 (i32.const 0) $f) diff --git a/test/lit/passes/gufa.wast b/test/lit/passes/gufa.wast index 58166cd4651..b97e620ab62 100644 --- a/test/lit/passes/gufa.wast +++ b/test/lit/passes/gufa.wast @@ -583,6 +583,8 @@ (ref.func $reffed) ) + (export "table" (table 0)) + ;; CHECK: (type $1 (func)) ;; CHECK: (table $0 10 funcref) @@ -590,7 +592,6 @@ ;; CHECK: (elem $0 (i32.const 0) $reffed) ;; CHECK: (export "table" (table $0)) - (export "table" (table 0)) ;; CHECK: (func $reffed (type $i) (param $x i32) ;; CHECK-NEXT: (drop @@ -924,6 +925,12 @@ ;; CHECK: (type $A (func (param i32))) (type $A (func (param i32))) + (import "binaryen-intrinsics" "call.without.effects" + (func $call-without-effects (param i32 funcref))) + + (import "other" "import" + (func $other-import (param funcref))) + ;; CHECK: (type $1 (func (param i32 funcref))) ;; CHECK: (type $2 (func (param funcref))) @@ -931,12 +938,8 @@ ;; CHECK: (type $3 (func)) ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param i32 funcref))) - (import "binaryen-intrinsics" "call.without.effects" - (func $call-without-effects (param i32 funcref))) ;; CHECK: (import "other" "import" (func $other-import (type $2) (param funcref))) - (import "other" "import" - (func $other-import (param funcref))) ;; CHECK: (elem declare func $target-drop $target-keep) @@ -994,6 +997,12 @@ ;; CHECK: (type $A (func (param i32))) (type $A (func (param i32))) + (import "binaryen-intrinsics" "call.without.effects" + (func $call-without-effects (param i32 funcref))) + + (import "other" "import" + (func $other-import (param funcref))) + ;; CHECK: (type $1 (func (param i32 funcref))) ;; CHECK: (type $2 (func (param funcref))) @@ -1001,12 +1010,8 @@ ;; CHECK: (type $3 (func (param (ref null $A)))) ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param i32 funcref))) - (import "binaryen-intrinsics" "call.without.effects" - (func $call-without-effects (param i32 funcref))) ;; CHECK: (import "other" "import" (func $other-import (type $2) (param funcref))) - (import "other" "import" - (func $other-import (param funcref))) ;; CHECK: (elem declare func $target-keep $target-keep-2) diff --git a/test/lit/passes/inlining-optimizing_optimize-level=3.wast b/test/lit/passes/inlining-optimizing_optimize-level=3.wast index dfdbed53376..a0e320bd640 100644 --- a/test/lit/passes/inlining-optimizing_optimize-level=3.wast +++ b/test/lit/passes/inlining-optimizing_optimize-level=3.wast @@ -33,54 +33,58 @@ ;; CHECK: (type $11 (func (param i32 i32 i32 i32 i32))) ;; CHECK: (import "env" "memory" (memory $0 256 256)) - (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) + ;; CHECK: (import "env" "table" (table $timport$0 18 18 funcref)) - (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) + ;; CHECK: (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) - (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32)) + (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) ;; CHECK: (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) - (import "env" "abort" (func $abort)) + (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) ;; CHECK: (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32)) - (import "env" "nullFunc_ii" (func $nullFunc_ii (param i32))) + (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32)) ;; CHECK: (import "env" "memoryBase" (global $memoryBase i32)) - (import "env" "nullFunc_iiii" (func $nullFunc_iiii (param i32))) + ;; CHECK: (import "env" "tableBase" (global $tableBase i32)) - (import "env" "nullFunc_vi" (func $nullFunc_vi (param i32))) + ;; CHECK: (import "env" "abort" (func $abort)) - (import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32))) + (import "env" "abort" (func $abort)) ;; CHECK: (import "env" "nullFunc_ii" (func $nullFunc_ii (param i32))) - (import "env" "___lock" (func $___lock (param i32))) + (import "env" "nullFunc_ii" (func $nullFunc_ii (param i32))) ;; CHECK: (import "env" "nullFunc_iiii" (func $nullFunc_iiii (param i32))) - (import "env" "_pthread_self" (func $_pthread_self (result i32))) + (import "env" "nullFunc_iiii" (func $nullFunc_iiii (param i32))) ;; CHECK: (import "env" "nullFunc_vi" (func $nullFunc_vi (param i32))) - (import "env" "_abort" (func $_abort)) + (import "env" "nullFunc_vi" (func $nullFunc_vi (param i32))) ;; CHECK: (import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32))) - (import "env" "___syscall6" (func $___syscall6 (param i32 i32) (result i32))) + (import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32))) ;; CHECK: (import "env" "___lock" (func $___lock (param i32))) - (import "env" "_sbrk" (func $_sbrk (param i32) (result i32))) + (import "env" "___lock" (func $___lock (param i32))) ;; CHECK: (import "env" "_pthread_self" (func $_pthread_self (result i32))) - (import "env" "_time" (func $_time (param i32) (result i32))) + (import "env" "_pthread_self" (func $_pthread_self (result i32))) ;; CHECK: (import "env" "_abort" (func $_abort)) - (import "env" "_emscripten_memcpy_big" (func $_emscripten_memcpy_big (param i32 i32 i32) (result i32))) + (import "env" "_abort" (func $_abort)) ;; CHECK: (import "env" "___syscall6" (func $___syscall6 (param i32 i32) (result i32))) - (import "env" "___syscall54" (func $___syscall54 (param i32 i32) (result i32))) + (import "env" "___syscall6" (func $___syscall6 (param i32 i32) (result i32))) ;; CHECK: (import "env" "_sbrk" (func $_sbrk (param i32) (result i32))) - (import "env" "___unlock" (func $___unlock (param i32))) + (import "env" "_sbrk" (func $_sbrk (param i32) (result i32))) ;; CHECK: (import "env" "_time" (func $_time (param i32) (result i32))) - (import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32))) + (import "env" "_time" (func $_time (param i32) (result i32))) ;; CHECK: (import "env" "_emscripten_memcpy_big" (func $_emscripten_memcpy_big (param i32 i32 i32) (result i32))) - (import "env" "_pthread_cleanup_push" (func $_pthread_cleanup_push (param i32 i32))) + (import "env" "_emscripten_memcpy_big" (func $_emscripten_memcpy_big (param i32 i32 i32) (result i32))) ;; CHECK: (import "env" "___syscall54" (func $___syscall54 (param i32 i32) (result i32))) - (import "env" "_sysconf" (func $_sysconf (param i32) (result i32))) + (import "env" "___syscall54" (func $___syscall54 (param i32 i32) (result i32))) ;; CHECK: (import "env" "___unlock" (func $___unlock (param i32))) - (import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32))) + (import "env" "___unlock" (func $___unlock (param i32))) ;; CHECK: (import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32))) - (import "env" "memory" (memory $0 256 256)) + (import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32))) ;; CHECK: (import "env" "_pthread_cleanup_push" (func $_pthread_cleanup_push (param i32 i32))) - (import "env" "table" (table 18 18 funcref)) + (import "env" "_pthread_cleanup_push" (func $_pthread_cleanup_push (param i32 i32))) ;; CHECK: (import "env" "_sysconf" (func $_sysconf (param i32) (result i32))) - (import "env" "memoryBase" (global $memoryBase i32)) + (import "env" "_sysconf" (func $_sysconf (param i32) (result i32))) ;; CHECK: (import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32))) + (import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32))) + (import "env" "memory" (memory $0 256 256)) + (import "env" "table" (table 18 18 funcref)) + (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) ;; CHECK: (global $STACKTOP (mut i32) (global.get $STACKTOP$asm2wasm$import)) (global $STACKTOP (mut i32) (global.get $STACKTOP$asm2wasm$import)) diff --git a/test/lit/passes/jspi-args.wast b/test/lit/passes/jspi-args.wast index 1a23c171699..8229e34e971 100644 --- a/test/lit/passes/jspi-args.wast +++ b/test/lit/passes/jspi-args.wast @@ -3,18 +3,20 @@ (module ;; sleep_async should have a wrapper function built. + (import "js" "sleep_async" (func $sleep_async (param f64) (result i32))) ;; CHECK: (type $0 (func (param f64) (result i32))) ;; CHECK: (type $1 (func (param externref f64) (result i32))) ;; CHECK: (import "js" "sleep_sync" (func $sleep_sync (type $0) (param f64) (result i32))) - (import "js" "sleep_async" (func $sleep_async (param f64) (result i32))) - ;; CHECK: (import "js" "sleep_async" (func $import$sleep_async (type $1) (param externref f64) (result i32))) (import "js" "sleep_sync" (func $sleep_sync (param f64) (result i32))) + (export "update_state_async" (func $update_state_async)) + ;; CHECK: (import "js" "sleep_async" (func $import$sleep_async (type $1) (param externref f64) (result i32))) + ;; CHECK: (global $suspender (mut externref) (ref.null noextern)) ;; CHECK: (export "update_state_async" (func $export$update_state_async)) - (export "update_state_async" (func $update_state_async)) + ;; CHECK: (export "update_state_sync" (func $update_state_sync)) (export "update_state_sync" (func $update_state_sync)) ;; This function calls an async sleep so a wrapper should be created for it. diff --git a/test/lit/passes/jspi-table.wast b/test/lit/passes/jspi-table.wast index 526b0a4b7e2..c702357c014 100644 --- a/test/lit/passes/jspi-table.wast +++ b/test/lit/passes/jspi-table.wast @@ -12,10 +12,11 @@ ;; CHECK: (table $0 1 1 funcref) (table $0 1 1 funcref) (elem (i32.const 1) func $update_state) + (export "update_state" (func $update_state)) + ;; CHECK: (elem $0 (i32.const 1) $export$update_state) ;; CHECK: (export "update_state" (func $export$update_state)) - (export "update_state" (func $update_state)) ;; CHECK: (func $update_state (type $0) (param $param f64) (result i32) ;; CHECK-NEXT: (i32.const 42) diff --git a/test/lit/passes/jspi.wast b/test/lit/passes/jspi.wast index 780a54ccbe4..12396cc6d71 100644 --- a/test/lit/passes/jspi.wast +++ b/test/lit/passes/jspi.wast @@ -4,6 +4,19 @@ (module + (import "js" "compute_delta" (func $compute_delta (param f64) (result i32))) + (import "js" "import_and_export" (func $import_and_export (param i32) (result i32))) + (import "js" "import_void_return" (func $import_void_return (param i32))) + (export "update_state_void" (func $update_state_void)) + (export "update_state" (func $update_state)) + ;; Test duplicating an export. + (export "update_state_again" (func $update_state)) + ;; Test that a name collision on the parameters is handled. + (export "update_state_param_collision" (func $update_state_param_collision)) + ;; Test function that is imported and exported. + (export "import_and_export" (func $import_and_export)) + + ;; CHECK: (type $0 (func (param externref f64) (result i32))) ;; CHECK: (type $1 (func (param f64) (result i32))) @@ -19,27 +32,22 @@ ;; CHECK: (type $6 (func (param externref i32))) ;; CHECK: (import "js" "compute_delta" (func $import$compute_delta (type $0) (param externref f64) (result i32))) - (import "js" "compute_delta" (func $compute_delta (param f64) (result i32))) + ;; CHECK: (import "js" "import_and_export" (func $import$import_and_export (type $2) (param externref i32) (result i32))) - (import "js" "import_and_export" (func $import_and_export (param i32) (result i32))) + ;; CHECK: (import "js" "import_void_return" (func $import$import_void_return (type $6) (param externref i32))) - (import "js" "import_void_return" (func $import_void_return (param i32))) + ;; CHECK: (global $suspender (mut externref) (ref.null noextern)) ;; CHECK: (export "update_state_void" (func $export$update_state_void)) - (export "update_state_void" (func $update_state_void)) + ;; CHECK: (export "update_state" (func $export$update_state)) - (export "update_state" (func $update_state)) - ;; Test duplicating an export. + ;; CHECK: (export "update_state_again" (func $export$update_state)) - (export "update_state_again" (func $update_state)) - ;; Test that a name collision on the parameters is handled. + ;; CHECK: (export "update_state_param_collision" (func $export$update_state_param_collision)) - (export "update_state_param_collision" (func $update_state_param_collision)) - ;; Test function that is imported and exported. - ;; CHECK: (export "import_and_export" (func $export$import_and_export)) - (export "import_and_export" (func $import_and_export)) + ;; CHECK: (export "import_and_export" (func $export$import_and_export)) ;; CHECK: (func $update_state (type $1) (param $param f64) (result i32) ;; CHECK-NEXT: (call $compute_delta diff --git a/test/lit/passes/legalize-js-interface-exported-helpers.wast b/test/lit/passes/legalize-js-interface-exported-helpers.wast index 35271ee8420..707cbe5c9b1 100644 --- a/test/lit/passes/legalize-js-interface-exported-helpers.wast +++ b/test/lit/passes/legalize-js-interface-exported-helpers.wast @@ -6,6 +6,10 @@ ;; RUN: wasm-opt %s --legalize-js-interface --pass-arg=legalize-js-interface-exported-helpers -S -o - | filecheck %s (module + (export "get_i64" (func $get_i64)) + (import "env" "imported" (func $imported (result i64))) + (export "__set_temp_ret" (func $__set_temp_ret)) + (export "__get_temp_ret" (func $__get_temp_ret)) ;; CHECK: (type $0 (func (result i32))) ;; CHECK: (type $1 (func (result i64))) @@ -15,10 +19,7 @@ ;; CHECK: (import "env" "imported" (func $legalimport$imported (result i32))) ;; CHECK: (export "get_i64" (func $legalstub$get_i64)) - (export "get_i64" (func $get_i64)) - (import "env" "imported" (func $imported (result i64))) - (export "__set_temp_ret" (func $__set_temp_ret)) - (export "__get_temp_ret" (func $__get_temp_ret)) + ;; CHECK: (func $get_i64 (result i64) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $legalfunc$imported) diff --git a/test/lit/passes/legalize-js-interface-minimally.wast b/test/lit/passes/legalize-js-interface-minimally.wast index 76bed505c30..664b024b39f 100644 --- a/test/lit/passes/legalize-js-interface-minimally.wast +++ b/test/lit/passes/legalize-js-interface-minimally.wast @@ -16,14 +16,16 @@ ;; CHECK: (import "env" "imported" (func $imported (result i64))) (import "env" "imported" (func $imported (result i64))) - ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (param i32))) (import "env" "invoke_vj" (func $invoke_vj (param i64))) + ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (param i32))) + ;; CHECK: (import "env" "invoke_vj" (func $legalimport$invoke_vj (param i32 i32))) ;; CHECK: (export "func" (func $func)) (export "func" (func $func)) - ;; CHECK: (export "dynCall_foo" (func $legalstub$dyn)) (export "dynCall_foo" (func $dyn)) + ;; CHECK: (export "dynCall_foo" (func $legalstub$dyn)) + ;; CHECK: (func $func (result i64) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $imported) diff --git a/test/lit/passes/legalize-js-interface_all-features.wast b/test/lit/passes/legalize-js-interface_all-features.wast index 6afd2bc20e4..611a58da791 100644 --- a/test/lit/passes/legalize-js-interface_all-features.wast +++ b/test/lit/passes/legalize-js-interface_all-features.wast @@ -4,6 +4,10 @@ ;; RUN: foreach %s %t wasm-opt --legalize-js-interface --all-features -S -o - | filecheck %s (module + (import "env" "imported" (func $imported (result i64))) + (import "env" "other" (func $other (param i32) (param i64) (param i64))) + (import "env" "ref-func-arg" (func $ref-func-arg (result i64))) + (export "func" (func $func)) ;; CHECK: (type $0 (func (result i32))) ;; CHECK: (type $1 (func (result i64))) @@ -17,11 +21,11 @@ ;; CHECK: (type $5 (func (param i32 i64 i64))) ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (type $4) (param i32))) - (import "env" "imported" (func $imported (result i64))) + ;; CHECK: (import "env" "getTempRet0" (func $getTempRet0 (type $0) (result i32))) - (import "env" "other" (func $other (param i32) (param i64) (param i64))) + ;; CHECK: (import "env" "imported" (func $legalimport$imported (type $0) (result i32))) - (import "env" "ref-func-arg" (func $ref-func-arg (result i64))) + ;; CHECK: (import "env" "other" (func $legalimport$other (type $2) (param i32 i32 i32 i32 i32))) ;; CHECK: (import "env" "ref-func-arg" (func $legalimport$ref-func-arg (type $0) (result i32))) @@ -29,15 +33,18 @@ ;; CHECK: (elem declare func $legalfunc$ref-func-arg) ;; CHECK: (export "func" (func $legalstub$func)) - (export "func" (func $func)) + ;; CHECK: (export "ref-func-test" (func $ref-func-test)) (export "ref-func-test" (func $ref-func-test)) - ;; CHECK: (export "imported" (func $legalstub$imported)) (export "imported" (func $imported)) - ;; CHECK: (export "imported_again" (func $legalstub$imported)) (export "imported_again" (func $imported)) - ;; CHECK: (export "other" (func $legalstub$other)) (export "other" (func $other)) + ;; CHECK: (export "imported" (func $legalstub$imported)) + + ;; CHECK: (export "imported_again" (func $legalstub$imported)) + + ;; CHECK: (export "other" (func $legalstub$other)) + ;; CHECK: (func $func (type $1) (result i64) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $legalfunc$imported) diff --git a/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast b/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast index ba9db7ee5a7..f56db7982c2 100644 --- a/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast +++ b/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast @@ -13,9 +13,9 @@ ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (param i32))) ;; CHECK: (export "func" (func $legalstub$func)) - (export "func" (func $func)) - ;; CHECK: (export "orig$func" (func $func)) + ;; CHECK: (export "orig$func" (func $func)) + (export "func" (func $func)) ;; CHECK: (func $func (result i64) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/remove-unused-module-elements-refs.wast b/test/lit/passes/remove-unused-module-elements-refs.wast index 00ea9767fc5..44c87fefcd6 100644 --- a/test/lit/passes/remove-unused-module-elements-refs.wast +++ b/test/lit/passes/remove-unused-module-elements-refs.wast @@ -469,20 +469,18 @@ ;; OPEN_WORLD: (type $A (func)) (type $A (func)) - ;; CHECK: (type $1 (func (param funcref))) - - ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) - ;; OPEN_WORLD: (type $1 (func (param funcref))) - - ;; OPEN_WORLD: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (param funcref))) - ;; CHECK: (import "other" "import" (func $other-import (type $1) (param funcref))) - ;; OPEN_WORLD: (import "other" "import" (func $other-import (type $1) (param funcref))) (import "other" "import" (func $other-import (param funcref))) + ;; CHECK: (type $1 (func (param funcref))) + + ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) + + ;; CHECK: (import "other" "import" (func $other-import (type $1) (param funcref))) + ;; CHECK: (elem declare func $target-drop $target-keep) ;; CHECK: (export "foo" (func $foo)) @@ -495,6 +493,12 @@ ;; CHECK-NEXT: (ref.func $target-drop) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) + ;; OPEN_WORLD: (type $1 (func (param funcref))) + + ;; OPEN_WORLD: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) + + ;; OPEN_WORLD: (import "other" "import" (func $other-import (type $1) (param funcref))) + ;; OPEN_WORLD: (elem declare func $target-drop $target-keep) ;; OPEN_WORLD: (export "foo" (func $foo)) @@ -546,20 +550,18 @@ ;; OPEN_WORLD: (type $A (func)) (type $A (func)) - ;; CHECK: (type $1 (func (param funcref))) - - ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) - ;; OPEN_WORLD: (type $1 (func (param funcref))) - - ;; OPEN_WORLD: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (param funcref))) - ;; CHECK: (import "other" "import" (func $other-import (type $1) (param funcref))) - ;; OPEN_WORLD: (import "other" "import" (func $other-import (type $1) (param funcref))) (import "other" "import" (func $other-import (param funcref))) + ;; CHECK: (type $1 (func (param funcref))) + + ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) + + ;; CHECK: (import "other" "import" (func $other-import (type $1) (param funcref))) + ;; CHECK: (elem declare func $target-keep $target-keep-2) ;; CHECK: (export "foo" (func $foo)) @@ -576,6 +578,12 @@ ;; CHECK-NEXT: (ref.func $target-keep-2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) + ;; OPEN_WORLD: (type $1 (func (param funcref))) + + ;; OPEN_WORLD: (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref))) + + ;; OPEN_WORLD: (import "other" "import" (func $other-import (type $1) (param funcref))) + ;; OPEN_WORLD: (elem declare func $target-keep $target-keep-2) ;; OPEN_WORLD: (export "foo" (func $foo)) diff --git a/test/lit/passes/remove-unused-module-elements_all-features.wast b/test/lit/passes/remove-unused-module-elements_all-features.wast index 385433189db..15a843064b7 100644 --- a/test/lit/passes/remove-unused-module-elements_all-features.wast +++ b/test/lit/passes/remove-unused-module-elements_all-features.wast @@ -175,11 +175,11 @@ (elem (table $1) (offset (i32.const 1)) func) ) (module ;; remove the first table and memory, but not the second one + (import "env" "memory" (memory $0 256)) + (import "env" "table" (table 0 funcref)) ;; CHECK: (type $0 (func)) ;; CHECK: (import "env" "table2" (table $1 1 1 funcref)) - (import "env" "memory" (memory $0 256)) - (import "env" "table" (table 0 funcref)) (import "env" "table2" (table $1 1 1 funcref)) (elem (table $1) (offset (i32.const 0)) func) (elem (table $1) (offset (i32.const 0)) func $f) @@ -203,22 +203,25 @@ (module ;; but not when exported ;; CHECK: (import "env" "memory" (memory $0 256)) (import "env" "memory" (memory $0 256)) - ;; CHECK: (import "env" "table" (table $timport$0 1 funcref)) (import "env" "table" (table 1 funcref)) - ;; CHECK: (export "mem" (memory $0)) (export "mem" (memory 0)) - ;; CHECK: (export "tab" (table $timport$0)) (export "tab" (table 0)) ) +;; CHECK: (import "env" "table" (table $timport$0 1 funcref)) + +;; CHECK: (export "mem" (memory $0)) + +;; CHECK: (export "tab" (table $timport$0)) (module ;; and not when there are segments ;; CHECK: (type $0 (func)) ;; CHECK: (import "env" "memory" (memory $0 256)) (import "env" "memory" (memory $0 256)) - ;; CHECK: (import "env" "table" (table $timport$0 1 funcref)) (import "env" "table" (table 1 funcref)) (data (i32.const 1) "hello, world!") (elem (i32.const 0) $waka) + ;; CHECK: (import "env" "table" (table $timport$0 1 funcref)) + ;; CHECK: (data $0 (i32.const 1) "hello, world!") ;; CHECK: (elem $0 (i32.const 0) $waka) @@ -233,10 +236,12 @@ (type $0 (func)) ;; CHECK: (import "env" "memory" (memory $0 256)) (import "env" "memory" (memory $0 256)) - ;; CHECK: (import "env" "table" (table $timport$0 0 funcref)) (import "env" "table" (table 0 funcref)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (import "env" "table" (table $timport$0 0 funcref)) + + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.load @@ -257,8 +262,9 @@ ;; CHECK: (memory $0 (shared 23 256)) (memory $0 (shared 23 256)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.const 0) @@ -274,8 +280,9 @@ ;; CHECK: (memory $0 (shared 23 256)) (memory $0 (shared 23 256)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) (result i32) ;; CHECK-NEXT: (i32.atomic.rmw.add ;; CHECK-NEXT: (i32.const 0) @@ -291,8 +298,9 @@ ;; CHECK: (memory $0 (shared 23 256)) (memory $0 (shared 23 256)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) (result i32) ;; CHECK-NEXT: (i32.atomic.rmw8.cmpxchg_u ;; CHECK-NEXT: (i32.const 0) @@ -309,8 +317,9 @@ ;; CHECK: (memory $0 (shared 23 256)) (memory $0 (shared 23 256)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local $1 i64) @@ -339,8 +348,9 @@ ;; CHECK: (memory $0 (shared 23 256)) (memory $0 (shared 23 256)) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) (result i32) ;; CHECK-NEXT: (memory.atomic.notify ;; CHECK-NEXT: (i32.const 0) @@ -354,12 +364,13 @@ (module ;; atomic.fence and data.drop do not use a memory, so should not keep the memory alive. (memory $0 (shared 1 1)) (data "") + (export "fake-user" $user) ;; CHECK: (type $0 (func)) ;; CHECK: (data $0 "") ;; CHECK: (export "fake-user" (func $user)) - (export "fake-user" $user) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (atomic.fence) ;; CHECK-NEXT: (data.drop $0) @@ -378,8 +389,9 @@ (memory $1 23 256) (memory $unused 1 1) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (memory.grow $0 @@ -402,8 +414,9 @@ ;; CHECK: (memory $0 23 256) (memory $0 23 256) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) (result i32) ;; CHECK-NEXT: (memory.size) ;; CHECK-NEXT: ) @@ -419,8 +432,9 @@ ;; CHECK: (memory $1 1 1) (memory $1 1 1) (memory $unused 1 1) - ;; CHECK: (export "user" (func $user)) (export "user" $user) + ;; CHECK: (export "user" (func $user)) + ;; CHECK: (func $user (type $0) ;; CHECK-NEXT: (memory.copy $0 $1 ;; CHECK-NEXT: (i32.const 0) @@ -441,8 +455,9 @@ ;; CHECK: (import "env" "memory" (memory $0 256)) (import "env" "memory" (memory $0 256)) - ;; CHECK: (import "env" "table" (table $timport$0 0 funcref)) (import "env" "table" (table 0 funcref)) + ;; CHECK: (import "env" "table" (table $timport$0 0 funcref)) + ;; CHECK: (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "memoryBase" (global $memoryBase i32)) ;; used in init ;; CHECK: (import "env" "tableBase" (global $tableBase i32)) @@ -467,8 +482,8 @@ ;; CHECK: (import "env" "imported" (global $imported i32)) (import "env" "imported" (global $imported i32)) - ;; CHECK: (import "env" "_puts" (func $_puts (type $2) (param i32) (result i32))) (import "env" "forgetme" (global $forgetme i32)) + ;; CHECK: (import "env" "_puts" (func $_puts (type $2) (param i32) (result i32))) (import "env" "_puts" (func $_puts (param i32) (result i32))) (import "env" "forget_puts" (func $forget_puts (param i32) (result i32))) ;; CHECK: (global $int (mut i32) (global.get $imported)) diff --git a/test/lit/wasm-split/jspi-secondary-export.wast b/test/lit/wasm-split/jspi-secondary-export.wast index 6bb388fecca..57fe849a9af 100644 --- a/test/lit/wasm-split/jspi-secondary-export.wast +++ b/test/lit/wasm-split/jspi-secondary-export.wast @@ -8,27 +8,6 @@ ;; enabled. (module - ;; PRIMARY: (type $0 (func (param i32) (result i32))) - - ;; PRIMARY: (type $3 (func (param externref))) - - ;; PRIMARY: (type $1 (func (param externref i32) (result i32))) - - ;; PRIMARY: (type $2 (func)) - - ;; PRIMARY: (import "env" "__load_secondary_module" (func $import$__load_secondary_module (param externref))) - - ;; PRIMARY: (import "placeholder" "0" (func $placeholder_0 (param i32) (result i32))) - - ;; PRIMARY: (global $suspender (mut externref) (ref.null noextern)) - - ;; PRIMARY: (global $global$1 (mut i32) (i32.const 0)) - - ;; PRIMARY: (table $0 1 funcref) - - ;; PRIMARY: (elem $0 (i32.const 0) $placeholder_0) - - ;; PRIMARY: (export "foo" (func $export$foo)) (export "foo" (func $foo)) ;; SECONDARY: (type $0 (func (param i32) (result i32))) @@ -47,6 +26,28 @@ (i32.const 0) ) ) +;; PRIMARY: (type $0 (func (param i32) (result i32))) + +;; PRIMARY: (type $3 (func (param externref))) + +;; PRIMARY: (type $1 (func (param externref i32) (result i32))) + +;; PRIMARY: (type $2 (func)) + +;; PRIMARY: (import "env" "__load_secondary_module" (func $import$__load_secondary_module (param externref))) + +;; PRIMARY: (import "placeholder" "0" (func $placeholder_0 (param i32) (result i32))) + +;; PRIMARY: (global $suspender (mut externref) (ref.null noextern)) + +;; PRIMARY: (global $global$1 (mut i32) (i32.const 0)) + +;; PRIMARY: (table $0 1 funcref) + +;; PRIMARY: (elem $0 (i32.const 0) $placeholder_0) + +;; PRIMARY: (export "foo" (func $export$foo)) + ;; PRIMARY: (export "load_secondary_module_status" (global $global$1)) ;; PRIMARY: (export "%table" (table $0)) diff --git a/test/lit/wasm-split/jspi.wast b/test/lit/wasm-split/jspi.wast index b1f1b56f36b..340b2acec79 100644 --- a/test/lit/wasm-split/jspi.wast +++ b/test/lit/wasm-split/jspi.wast @@ -29,11 +29,11 @@ ;; PRIMARY: (elem $0 (i32.const 0) $placeholder_0) ;; PRIMARY: (export "foo" (func $export$foo)) - (export "foo" (func $foo)) + ;; PRIMARY: (export "load_secondary_module_status" (global $global$1)) ;; PRIMARY: (export "%foo" (func $foo)) - + (export "foo" (func $foo)) ;; PRIMARY: (export "%table" (table $0)) ;; PRIMARY: (export "%global" (global $suspender)) diff --git a/test/lit/wasm-split/multi-memory-lowering-export.wast b/test/lit/wasm-split/multi-memory-lowering-export.wast index 156ac2efe1e..0721ba2a462 100644 --- a/test/lit/wasm-split/multi-memory-lowering-export.wast +++ b/test/lit/wasm-split/multi-memory-lowering-export.wast @@ -5,17 +5,18 @@ (module (memory $memory1 1) (memory $memory2 1 1) - ;; CHECK: (type $0 (func (result i32))) + (export "mem" (memory $memory1)) +) - ;; CHECK: (type $1 (func (param i32) (result i32))) +;; CHECK: (type $0 (func (result i32))) - ;; CHECK: (global $memory2_byte_offset (mut i32) (i32.const 65536)) +;; CHECK: (type $1 (func (param i32) (result i32))) - ;; CHECK: (memory $combined_memory 1 1) +;; CHECK: (global $memory2_byte_offset (mut i32) (i32.const 65536)) - ;; CHECK: (export "mem" (memory $combined_memory)) - (export "mem" (memory $memory1)) -) +;; CHECK: (memory $combined_memory 1 1) + +;; CHECK: (export "mem" (memory $combined_memory)) ;; CHECK: (func $memory1_size (type $0) (result i32) ;; CHECK-NEXT: (return diff --git a/test/lit/wasm-split/multi-memory-lowering-import.wast b/test/lit/wasm-split/multi-memory-lowering-import.wast index e00c137990f..d62609108c2 100644 --- a/test/lit/wasm-split/multi-memory-lowering-import.wast +++ b/test/lit/wasm-split/multi-memory-lowering-import.wast @@ -3,15 +3,16 @@ ;; RUN: wasm-opt %s --multi-memory-lowering -all -S -o - | filecheck %s (module - ;; CHECK: (type $0 (func (result i32))) - - ;; CHECK: (type $1 (func (param i32) (result i32))) - - ;; CHECK: (import "env" "mem" (memory $combined_memory 2 2)) (import "env" "mem" (memory $memory1 1 1)) (memory $memory2 1 1) ) +;; CHECK: (type $0 (func (result i32))) + +;; CHECK: (type $1 (func (param i32) (result i32))) + +;; CHECK: (import "env" "mem" (memory $combined_memory 2 2)) + ;; CHECK: (global $memory2_byte_offset (mut i32) (i32.const 65536)) ;; CHECK: (func $memory1_size (type $0) (result i32) diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast index af2fbffc5f5..a45ef7e9c17 100644 --- a/test/lit/wat-kitchen-sink.wast +++ b/test/lit/wat-kitchen-sink.wast @@ -354,6 +354,7 @@ (tag $tag-pair (param i32 i64)) ;; explicit exports + (export "exported-func" (func 0)) ;; CHECK: (export "g1" (global $g1)) ;; CHECK: (export "g1.1" (global $g1)) @@ -375,19 +376,21 @@ ;; CHECK: (export "t0.1" (tag $imported)) ;; CHECK: (export "exported-func" (func $fimport$0)) - (export "exported-func" (func 0)) - ;; CHECK: (export "exported-table" (table $timport$0)) - (export "exported-table" (table 0)) - ;; CHECK: (export "exported-memory" (memory $mimport$0)) + + ;; CHECK: (export "exported-table" (table $funcs)) + (export "exported-table" (table $funcs)) (export "exported-memory" (memory 0)) + ;; CHECK: (export "exported-memory" (memory $mimport$0)) + ;; CHECK: (export "exported-global" (global $g1)) - (export "exported-global" (global 0)) - ;; CHECK: (export "exported-tag" (tag $imported)) + (export "exported-global" (global $g1)) (export "exported-tag" (tag 0)) ;; functions (func) + ;; CHECK: (export "exported-tag" (tag $imported)) + ;; CHECK: (func $1 (type $void) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) From b5a1ed85c445d7620994ef4833f76aa612cc2bec Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Tue, 2 Jan 2024 11:00:09 -0800 Subject: [PATCH 2/2] fix string prefix --- scripts/update_lit_checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_lit_checks.py b/scripts/update_lit_checks.py index b1d89bc3305..345ff39d0c6 100755 --- a/scripts/update_lit_checks.py +++ b/scripts/update_lit_checks.py @@ -40,7 +40,7 @@ DECL_ITEMS = '|'.join(['type', 'global', 'memory', 'data', 'table', 'elem', 'tag', 'start', 'func']) IMPORT_ITEM = r'import\s*"[^"]*"\s*"[^"]*"\s*\((?:' + DECL_ITEMS + ')' -EXPORT_ITEM = f'export\s*"[^"]*"\s*\((?:' + DECL_ITEMS + ')' +EXPORT_ITEM = r'export\s*"[^"]*"\s*\((?:' + DECL_ITEMS + ')' ALL_ITEMS = DECL_ITEMS + '|' + IMPORT_ITEM + '|' + EXPORT_ITEM # Regular names as well as the "declare" in (elem declare ... to get declarative