From dc8f514bfa4617861b51b6cef23af73464d3b650 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 3 Mar 2023 08:05:03 -0800 Subject: getHeapTypeCounts() must note select types for references (#5540) Without this we hit an assertion on trying to write the binary, on a missing heap type. --- test/lit/passes/gufa-vs-cfp.wast | 4 ++-- test/lit/select-gc.wat | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 test/lit/select-gc.wat (limited to 'test/lit') 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) + ) + ) +) -- cgit v1.2.3