diff options
-rwxr-xr-x | scripts/update_lit_checks.py | 58 | ||||
-rw-r--r-- | test/lit/forward-declared-types.wast | 1 | ||||
-rw-r--r-- | test/lit/lub-bug-3843.wast | 3 | ||||
-rw-r--r-- | test/lit/nominal-chain.wast | 1 | ||||
-rw-r--r-- | test/lit/passes/coalesce-locals-eh.wast | 1 | ||||
-rw-r--r-- | test/lit/passes/dce-eh.wast | 1 | ||||
-rw-r--r-- | test/lit/passes/heap2local.wast | 2 | ||||
-rw-r--r-- | test/lit/passes/optimize-instructions-eh.wast | 1 | ||||
-rw-r--r-- | test/lit/passes/optimize-instructions-gc.wast | 2 | ||||
-rw-r--r-- | test/lit/passes/poppify-globals.wast | 29 | ||||
-rw-r--r-- | test/lit/passes/precompute-gc.wast | 2 | ||||
-rw-r--r-- | test/lit/passes/roundtrip-gc-types.wast | 1 | ||||
-rw-r--r-- | test/lit/recursive-types.wast | 48 |
13 files changed, 105 insertions, 45 deletions
diff --git a/scripts/update_lit_checks.py b/scripts/update_lit_checks.py index bd3fbe208..083298f57 100755 --- a/scripts/update_lit_checks.py +++ b/scripts/update_lit_checks.py @@ -29,9 +29,9 @@ import tempfile script_name = os.path.basename(__file__) -NOTICE = (f';; NOTE: Assertions have been generated by {script_name} and ' + - 'should not be edited.') +NOTICE = (';; NOTE: Assertions have been generated by {script} and should not' + + ' be edited.') RUN_LINE_RE = re.compile(r'^\s*;;\s*RUN:\s*(.*)$') CHECK_PREFIX_RE = re.compile(r'.*--check-prefix[= ](\S+).*') @@ -123,6 +123,10 @@ def main(): ' directory. Default: bin/ of current directory (i.e. assume an' ' in-tree build).')) parser.add_argument( + '--all-items', action='store_true', + help=('Emit checks for all module items, even those that do not appear' + ' in the input.')) + parser.add_argument( '-f', '--force', action='store_true', help=('Generate FileCheck patterns even for test files whose existing ' 'patterns were not generated by this script.')) @@ -137,6 +141,14 @@ def main(): tmp = tempfile.mktemp() for test, lines in itertests(args): + all_items = args.all_items + if lines and script_name in lines[0]: + # Apply previously used options for this file + if '--all-items' in lines[0]: + all_items = True + # Skip the notice if it is already in the output + lines = lines[1:] + # List of (prefix, command) run_list = [] for line in find_run_lines(test, lines): @@ -156,7 +168,7 @@ def main(): run_list.append((check_prefix, commands[0])) - # Map check prefixes to lists of ((kind, name), [lines]) + # Map check prefixes to lists of ((kind, name), [line]) output_modules = {} for prefix, command, in run_list: output = run_command(args, test, tmp, command) @@ -166,16 +178,16 @@ def main(): any_prefix = '|'.join(output_modules.keys()) check_line_re = re.compile(r'^\s*;;\s*(' + any_prefix + r')(?:-NEXT|-LABEL|-NOT)?:.*$') - output_lines = [NOTICE] - def emit_checks(indent, prefix, lines): - output_lines.append(f'{indent};; {prefix}: {lines[0]}') - for line in lines[1:]: - output_lines.append(f'{indent};; {prefix}-NEXT:{line}') - - # Skip the notice if it is already in the output - if lines and script_name in lines[0]: - lines = lines[1:] + # Filter out whitespace between check blocks + if lines: + filtered = [lines[0]] + for i in range(1, len(lines) - 1): + if lines[i] or not check_line_re.match(lines[i - 1]) or \ + not check_line_re.match(lines[i + 1]): + filtered.append(lines[i]) + filtered.append(lines[-1]) + lines = filtered named_items = [] for line in lines: @@ -184,6 +196,16 @@ def main(): kind, name = match[2], match[3] named_items.append((kind, name)) + script = script_name + if all_items: + script += ' --all-items' + output_lines = [NOTICE.format(script=script)] + + def emit_checks(indent, prefix, lines): + output_lines.append(f'{indent};; {prefix}: {lines[0]}') + for line in lines[1:]: + output_lines.append(f'{indent};; {prefix}-NEXT:{line}') + for line in lines: # Skip pre-existing check lines; we will regenerate them. if check_line_re.match(line): @@ -201,17 +223,25 @@ def main(): has_item = True break if has_item: + first = True while True: kind_name, lines = items.pop(0) - if kind_name in named_items: + if all_items or kind_name in named_items: + if not first: + output_lines.append('') + first = False emit_checks(indent, prefix, lines) if name and (kind, name) == kind_name: break output_lines.append(line) # Output any remaining checks for each prefix + first = True for prefix, items in output_modules.items(): for kind_name, lines in items: - if kind_name in named_items: + if all_items or kind_name in named_items: + if not first: + output_lines.append('') + first = False emit_checks('', prefix, lines) if args.dry_run: diff --git a/test/lit/forward-declared-types.wast b/test/lit/forward-declared-types.wast index 876ebefd8..215838621 100644 --- a/test/lit/forward-declared-types.wast +++ b/test/lit/forward-declared-types.wast @@ -5,6 +5,7 @@ (module ;; CHECK: (type $func (func)) + ;; CHECK: (type $struct (struct (field (ref $array)) (field (ref null $func)))) (type $struct (struct (field (ref $array)) diff --git a/test/lit/lub-bug-3843.wast b/test/lit/lub-bug-3843.wast index 37206edc7..897149502 100644 --- a/test/lit/lub-bug-3843.wast +++ b/test/lit/lub-bug-3843.wast @@ -8,9 +8,12 @@ (module ;; CHECK: (type $A (struct (field (ref null $C)))) (type $A (struct (field (ref null $C)))) + ;; CHECK: (type $B (struct (field (ref null $D)))) (type $B (struct (field (ref null $D)))) + ;; CHECK: (type $D (struct (field (mut (ref $A))) (field (mut (ref $A))))) + ;; CHECK: (type $C (struct (field (mut (ref $A))))) (type $C (struct (field (mut (ref $A))))) (type $D (struct (field (mut (ref $A))) (field (mut (ref $A))))) diff --git a/test/lit/nominal-chain.wast b/test/lit/nominal-chain.wast index 5c5807a15..bf190d878 100644 --- a/test/lit/nominal-chain.wast +++ b/test/lit/nominal-chain.wast @@ -8,6 +8,7 @@ (module ;; CHECK: (type $root (struct )) + ;; CHECK: (type $leaf (struct (field i32) (field i64) (field f32) (field f64)) (extends $twig)) (type $leaf (struct i32 i64 f32 f64) (extends $twig)) diff --git a/test/lit/passes/coalesce-locals-eh.wast b/test/lit/passes/coalesce-locals-eh.wast index 20c1d3152..9a3289776 100644 --- a/test/lit/passes/coalesce-locals-eh.wast +++ b/test/lit/passes/coalesce-locals-eh.wast @@ -3,6 +3,7 @@ (module ;; CHECK: (tag $e (param)) + ;; CHECK: (func $bar (result i32) ;; CHECK-NEXT: (i32.const 1984) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/dce-eh.wast b/test/lit/passes/dce-eh.wast index e2268f87b..336246225 100644 --- a/test/lit/passes/dce-eh.wast +++ b/test/lit/passes/dce-eh.wast @@ -5,6 +5,7 @@ ;; reachable (module ;; CHECK: (tag $e (param)) + ;; CHECK: (func $foo ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/heap2local.wast b/test/lit/passes/heap2local.wast index efca63028..f7120906e 100644 --- a/test/lit/passes/heap2local.wast +++ b/test/lit/passes/heap2local.wast @@ -7,7 +7,9 @@ (type $struct.A (struct (field (mut i32)) (field (mut f64)))) ;; CHECK: (type $struct.recursive (struct (field (mut (ref null $struct.recursive))))) + ;; CHECK: (type $struct.nonnullable (struct (field (ref $struct.A)))) + ;; CHECK: (type $struct.packed (struct (field (mut i8)))) (type $struct.packed (struct (field (mut i8)))) diff --git a/test/lit/passes/optimize-instructions-eh.wast b/test/lit/passes/optimize-instructions-eh.wast index 92a2dd37c..7fd871c15 100644 --- a/test/lit/passes/optimize-instructions-eh.wast +++ b/test/lit/passes/optimize-instructions-eh.wast @@ -4,6 +4,7 @@ (module ;; CHECK: (tag $e (param i32)) + ;; CHECK: (func $dummy ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast index 3f8c21bfc..9e4ec450c 100644 --- a/test/lit/passes/optimize-instructions-gc.wast +++ b/test/lit/passes/optimize-instructions-gc.wast @@ -4,7 +4,9 @@ (module ;; CHECK: (type $struct (struct (field $i8 (mut i8)) (field $i16 (mut i16)) (field $i32 (mut i32)) (field $i64 (mut i64)))) + ;; CHECK: (type $array (array (mut i8))) + ;; CHECK: (import "env" "get-i32" (func $get-i32 (result i32))) (import "env" "get-i32" (func $get-i32 (result i32))) diff --git a/test/lit/passes/poppify-globals.wast b/test/lit/passes/poppify-globals.wast index ccdb025c0..869015cb7 100644 --- a/test/lit/passes/poppify-globals.wast +++ b/test/lit/passes/poppify-globals.wast @@ -1,26 +1,37 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. ;; TODO: enable validation ;; RUN: wasm-opt %s --poppify --no-validation -all -S -o - | filecheck %s (module - ;; CHECK: (global $foo (mut i32) (i32.const 0)) + ;; CHECK: (type $none_=>_i32_i64_f32 (func (result i32 i64 f32))) + + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (global $foo (mut i32) (i32.const 0)) (global $foo (mut i32) (i32.const 0)) - ;; CHECK: (global $tuple$1 f64 (f64.const 0)) + ;; CHECK: (global $tuple$1 f64 (f64.const 0)) (global $tuple$1 f64 (f64.const 0)) ;; interfering name! - ;; CHECK: (global $tuple$2 (mut f32) (f32.const 2)) - ;; CHECK: (global $tuple$1_0 (mut i64) (i64.const 1)) - ;; CHECK: (global $tuple$0 (mut i32) (global.get $foo)) (global $tuple (mut (i32 i64 f32)) (tuple.make (global.get $foo) (i64.const 1) (f32.const 2)) ) - ;; CHECK: (global $other-tuple$2 f32 (global.get $tuple$2)) - ;; CHECK: (global $other-tuple$1 i64 (global.get $tuple$1_0)) - ;; CHECK: (global $other-tuple$0 i32 (global.get $tuple$0)) (global $other-tuple (i32 i64 f32) (global.get $tuple)) - ;; CHECK: (func $global-get-tuple + ;; CHECK: (global $tuple$2 (mut f32) (f32.const 2)) + + ;; CHECK: (global $tuple$1_0 (mut i64) (i64.const 1)) + + ;; CHECK: (global $tuple$0 (mut i32) (global.get $foo)) + + ;; CHECK: (global $other-tuple$2 f32 (global.get $tuple$2)) + + ;; CHECK: (global $other-tuple$1 i64 (global.get $tuple$1_0)) + + ;; CHECK: (global $other-tuple$0 i32 (global.get $tuple$0)) + + ;; CHECK: (func $global-get-tuple (result i32 i64 f32) ;; CHECK-NEXT: (global.get $tuple$0) ;; CHECK-NEXT: (global.get $tuple$1_0) ;; CHECK-NEXT: (global.get $tuple$2) diff --git a/test/lit/passes/precompute-gc.wast b/test/lit/passes/precompute-gc.wast index b6c526e7b..c27433e98 100644 --- a/test/lit/passes/precompute-gc.wast +++ b/test/lit/passes/precompute-gc.wast @@ -6,7 +6,9 @@ ;; CHECK: (type $struct (struct (field (mut i32)))) (type $struct (struct (mut i32))) ;; CHECK: (type $B (struct (field (mut f64)))) + ;; CHECK: (type $func-return-i32 (func (result i32))) + ;; CHECK: (type $empty (struct )) (type $empty (struct)) diff --git a/test/lit/passes/roundtrip-gc-types.wast b/test/lit/passes/roundtrip-gc-types.wast index 85914fd79..6a96fd915 100644 --- a/test/lit/passes/roundtrip-gc-types.wast +++ b/test/lit/passes/roundtrip-gc-types.wast @@ -10,6 +10,7 @@ ;; CHECK: (type $A (struct (field (ref $C)))) (type $A (struct (field (ref $C)))) ;; CHECK: (type $C (struct (field (mut (ref $B))))) + ;; CHECK: (type $B (func (param (ref $A)) (result (ref $B)))) (type $B (func (param (ref $A)) (result (ref $B)))) (type $C (struct (field (mut (ref $B))))) diff --git a/test/lit/recursive-types.wast b/test/lit/recursive-types.wast index a5d301006..ced89612d 100644 --- a/test/lit/recursive-types.wast +++ b/test/lit/recursive-types.wast @@ -1,25 +1,7 @@ -;; Test a trivial recursive type works properly - -;; RUN: wasm-opt %s -all -S -o - | filecheck %s - -;; CHECK: (module -;; CHECK-NEXT: (type $ref?|...0|_=>_ref?|...0| (func (param (ref null $ref?|...0|_=>_ref?|...0|)) (result (ref null $ref?|...0|_=>_ref?|...0|)))) -;; CHECK-NEXT: (func $foo (param $0 (ref null $ref?|...0|_=>_ref?|...0|)) (result (ref null $ref?|...0|_=>_ref?|...0|)) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (func $bar (param $0 (ref null $ref?|...0|_=>_ref?|...0|)) (result (ref null $ref?|...0|_=>_ref?|...0|)) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (func $baz (param $0 (ref null $ref?|...0|_=>_ref?|...0|)) (result (ref null $ref?|...0|_=>_ref?|...0|)) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (func $qux (param $0 (ref null $ref?|...0|_=>_ref?|...0|)) (result (ref null $ref?|...0|_=>_ref?|...0|)) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (func $quux (param $0 (ref null $ref?|...0|_=>_ref?|...0|)) (result (ref null $ref?|...0|_=>_ref?|...0|)) -;; CHECK-NEXT: (unreachable) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; Test that a trivial recursive type works properly + +;; RUN: wasm-opt %s -all --name-types -S -o - | filecheck %s (module (type (func (param (ref null 0)) (result (ref null 0)))) @@ -27,18 +9,40 @@ (type (func (param (ref null 0)) (result (ref null 1)))) (type (func (param (ref null 3)) (result (ref null 4)))) (type (func (param (ref null 4)) (result (ref null 3)))) + + ;; CHECK: (type $type$0 (func (param (ref null $type$0)) (result (ref null $type$0)))) + + ;; CHECK: (func $foo (param $0 (ref null $type$0)) (result (ref null $type$0)) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) (func $foo (type 0) (unreachable) ) + + ;; CHECK: (func $bar (param $0 (ref null $type$0)) (result (ref null $type$0)) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) (func $bar (type 1) (unreachable) ) + + ;; CHECK: (func $baz (param $0 (ref null $type$0)) (result (ref null $type$0)) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) (func $baz (type 2) (unreachable) ) + + ;; CHECK: (func $qux (param $0 (ref null $type$0)) (result (ref null $type$0)) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) (func $qux (type 3) (unreachable) ) + + ;; CHECK: (func $quux (param $0 (ref null $type$0)) (result (ref null $type$0)) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) (func $quux (type 4) (unreachable) ) |