diff options
-rw-r--r-- | src/ir/module-utils.cpp | 3 | ||||
-rw-r--r-- | test/heap-types.wast.fromBinary | 2 | ||||
-rw-r--r-- | test/heap-types.wast.fromBinary.noDebugInfo | 2 | ||||
-rw-r--r-- | test/lit/global-only.wast | 13 | ||||
-rw-r--r-- | test/lit/passes/dae_all-features.wast | 4 | ||||
-rw-r--r-- | test/lit/passes/precompute-gc-immutable.wast | 3 | ||||
-rw-r--r-- | test/lit/passes/roundtrip-gc-types.wast | 6 | ||||
-rw-r--r-- | test/passes/Oz_fuzz-exec_all-features.txt | 2 |
8 files changed, 26 insertions, 9 deletions
diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index bf1a45205..38bb6f3d9 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -104,6 +104,9 @@ Counts getHeapTypeCounts(Module& wasm) { // Collect module-level info. Counts counts; CodeScanner(wasm, counts).walkModuleCode(&wasm); + for (auto& curr : wasm.globals) { + counts.note(curr->type); + } for (auto& curr : wasm.tags) { counts.note(curr->sig); } diff --git a/test/heap-types.wast.fromBinary b/test/heap-types.wast.fromBinary index f6b364b14..2f1cac1c5 100644 --- a/test/heap-types.wast.fromBinary +++ b/test/heap-types.wast.fromBinary @@ -5,9 +5,9 @@ (type $none_=>_none (func)) (type $grandchild (struct (field i32) (field i64))) (type $matrix (array (mut (ref null $vector)))) - (type $struct.C (struct (field $named-mut (mut f32)))) (type $parent (struct )) (type $child (struct (field i32))) + (type $struct.C (struct (field $named-mut (mut f32)))) (type $bytes (array (mut i8))) (type $anyref_=>_none (func (param anyref))) (type $nested-child-struct (struct (field (mut (ref $child))))) diff --git a/test/heap-types.wast.fromBinary.noDebugInfo b/test/heap-types.wast.fromBinary.noDebugInfo index c33ba0cc8..6e5e5e06d 100644 --- a/test/heap-types.wast.fromBinary.noDebugInfo +++ b/test/heap-types.wast.fromBinary.noDebugInfo @@ -5,9 +5,9 @@ (type $none_=>_none (func)) (type ${i32_i64} (struct (field i32) (field i64))) (type $[mut:ref?|[mut:f64]|] (array (mut (ref null $[mut:f64])))) - (type ${mut:f32} (struct (field (mut f32)))) (type ${} (struct )) (type ${i32} (struct (field i32))) + (type ${mut:f32} (struct (field (mut f32)))) (type $[mut:i8] (array (mut i8))) (type $anyref_=>_none (func (param anyref))) (type ${mut:ref|{i32}|} (struct (field (mut (ref ${i32}))))) diff --git a/test/lit/global-only.wast b/test/lit/global-only.wast new file mode 100644 index 000000000..6dce13d6d --- /dev/null +++ b/test/lit/global-only.wast @@ -0,0 +1,13 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; Regression test for a bug where types on globals were not collected, so if +;; they weren't used anywhere else they were not emitted in the output. + +;; RUN: wasm-opt -all %s -S -o - | filecheck %s + +(module $parse + ;; CHECK: (type $t (struct )) + (type $t (struct)) + ;; CHECK: (global $g (ref null $t) (ref.null $t)) + (global $g (ref null $t) (ref.null $t)) +) diff --git a/test/lit/passes/dae_all-features.wast b/test/lit/passes/dae_all-features.wast index 41655d849..92268dbbc 100644 --- a/test/lit/passes/dae_all-features.wast +++ b/test/lit/passes/dae_all-features.wast @@ -479,10 +479,10 @@ ;; CHECK-NEXT: (ref.func $0) ;; CHECK-NEXT: ) (module - ;; CHECK: (type $none_=>_none (func)) - ;; CHECK: (type $i64 (func (param i64))) (type $i64 (func (param i64))) + ;; CHECK: (type $none_=>_none (func)) + ;; CHECK: (global $global$0 (ref $i64) (ref.func $0)) (global $global$0 (ref $i64) (ref.func $0)) ;; CHECK: (export "even" (func $1)) diff --git a/test/lit/passes/precompute-gc-immutable.wast b/test/lit/passes/precompute-gc-immutable.wast index 0fd4e822d..8b5f28597 100644 --- a/test/lit/passes/precompute-gc-immutable.wast +++ b/test/lit/passes/precompute-gc-immutable.wast @@ -664,10 +664,9 @@ ;; Create an immutable vtable in an immutable global, but using an array ;; instead of a struct. - ;; CHECK: (type $object (struct_subtype (field (ref $vtable)) data)) - ;; CHECK: (type $vtable (array_subtype funcref data)) (type $vtable (array_subtype funcref data)) + ;; CHECK: (type $object (struct_subtype (field (ref $vtable)) data)) (type $object (struct_subtype (ref $vtable) data)) ;; CHECK: (global $vtable (ref $vtable) (array.init_static $vtable diff --git a/test/lit/passes/roundtrip-gc-types.wast b/test/lit/passes/roundtrip-gc-types.wast index d14415f3b..24d0ef40c 100644 --- a/test/lit/passes/roundtrip-gc-types.wast +++ b/test/lit/passes/roundtrip-gc-types.wast @@ -10,16 +10,18 @@ ;; CHECK: (type $A (struct (field (ref $C)))) ;; NOMNL: (type $A (struct_subtype (field (ref $C)) data)) (type $A (struct (field (ref $C)))) + ;; CHECK: (type $D (struct (field (ref $C)) (field (ref $A)))) + ;; CHECK: (type $C (struct (field (mut (ref $B))))) ;; CHECK: (type $B (func (param (ref $A)) (result (ref $B)))) + ;; NOMNL: (type $D (struct_subtype (field (ref $C)) (field (ref $A)) $A)) + ;; NOMNL: (type $C (struct_subtype (field (mut (ref $B))) data)) ;; NOMNL: (type $B (func_subtype (param (ref $A)) (result (ref $B)) func)) (type $B (func (param (ref $A)) (result (ref $B)))) (type $C (struct (field (mut (ref $B))))) - ;; CHECK: (type $D (struct (field (ref $C)) (field (ref $A)))) - ;; NOMNL: (type $D (struct_subtype (field (ref $C)) (field (ref $A)) $A)) (type $D (struct_subtype (field (ref $C)) (field (ref $A)) $A)) ;; CHECK: (global $g0 (rtt 0 $A) (rtt.canon $A)) ;; NOMNL: (global $g0 (rtt 0 $A) (rtt.canon $A)) diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt index a7c327d1e..14ef78a8c 100644 --- a/test/passes/Oz_fuzz-exec_all-features.txt +++ b/test/passes/Oz_fuzz-exec_all-features.txt @@ -87,8 +87,8 @@ (module (type $void_func (func)) (type $bytes (array (mut i8))) - (type $struct (struct (field (mut i32)))) (type $extendedstruct (struct (field (mut i32)) (field f64))) + (type $struct (struct (field (mut i32)))) (type $i32_=>_none (func (param i32))) (type $anyref_=>_none (func (param anyref))) (type $int_func (func (result i32))) |