diff options
-rw-r--r-- | src/ir/module-utils.cpp | 3 | ||||
-rw-r--r-- | test/lit/passes/gufa-vs-cfp.wast | 4 | ||||
-rw-r--r-- | test/lit/select-gc.wat | 26 |
3 files changed, 31 insertions, 2 deletions
diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index a6d2633ff..a2abcd5b5 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -63,6 +63,9 @@ struct CodeScanner counts.note(call->target->type); } else if (curr->is<RefNull>()) { counts.note(curr->type); + } else if (curr->is<Select>() && curr->type.isRef()) { + // This select will be annotated in the binary, so note it. + counts.note(curr->type); } else if (curr->is<StructNew>()) { counts.note(curr->type); } else if (curr->is<ArrayNew>()) { diff --git a/test/lit/passes/gufa-vs-cfp.wast b/test/lit/passes/gufa-vs-cfp.wast index 0a678af4f..a2fb8f5df 100644 --- a/test/lit/passes/gufa-vs-cfp.wast +++ b/test/lit/passes/gufa-vs-cfp.wast @@ -679,12 +679,12 @@ ;; Subtyping: Create both a subtype and a supertype, with identical constants ;; for the shared field, and get the supertype. (module + ;; CHECK: (type $struct (struct (field i32))) + (type $struct (struct i32)) ;; CHECK: (type $none_=>_i32 (func (result i32))) ;; CHECK: (type $none_=>_none (func)) - ;; CHECK: (type $struct (struct (field i32))) - (type $struct (struct i32)) ;; CHECK: (type $substruct (struct_subtype (field i32) (field f64) $struct)) (type $substruct (struct_subtype i32 f64 $struct)) diff --git a/test/lit/select-gc.wat b/test/lit/select-gc.wat new file mode 100644 index 000000000..8cc1d4ca7 --- /dev/null +++ b/test/lit/select-gc.wat @@ -0,0 +1,26 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. + +;; RUN: wasm-opt -all --roundtrip %s -S -o - | filecheck %s + +;; Check that annotated select is propery roundtripped, even if the type is +;; only used in that one place in the whole module. + +(module + ;; CHECK: (type $struct (struct )) + (type $struct (struct)) + + ;; CHECK: (func $foo (type $none_=>_anyref) (result anyref) + ;; CHECK-NEXT: (select (result (ref null $struct)) + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $foo (result anyref) + (select (result (ref null $struct)) + (ref.null any) + (ref.null eq) + (i32.const 1) + ) + ) +) |