diff options
author | Thomas Lively <tlively@google.com> | 2023-09-08 20:08:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-09 01:08:33 +0000 |
commit | 4e58466b40b65cda399b4749105f0ce10f48f62b (patch) | |
tree | 9e34ae5ed464d87d75683603171e7b2645015568 | |
parent | 90571051b3d6f89eab184df3d4dd716472a6cd7c (diff) | |
download | binaryen-4e58466b40b65cda399b4749105f0ce10f48f62b.tar.gz binaryen-4e58466b40b65cda399b4749105f0ce10f48f62b.tar.bz2 binaryen-4e58466b40b65cda399b4749105f0ce10f48f62b.zip |
Make final types the default (#5918)
Match the spec and parse the shorthand binary and text formats as final and emit
final types without supertypes using the shorthands as well. This is a
potentially-breaking change, since the text and binary shorthands can no longer
be used to define types that have subtypes.
Also make TypeBuilder entries final by default to better match the spec and
update the internal APIs to use the "open" terminology rather than "final"
terminology. Future changes will update the text format to use the standard "sub
open" rather than the current "sub final" keywords. The exception is the new wat
parser, which supporst "sub open" as of this change, since it didn't support
final types at all previously.
79 files changed, 729 insertions, 730 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 50072ebb3..a6db554e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ Current Trunk and as a convenience. - The nonstandard, experimental gc-nn-locals feature has been removed now that standard non-nullable locals are supported. +- Heap types are now final by default and openness must be opted into both in + the text and binary formats as well as in the TypeBuilder API. v114 ---- diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 59b01032d..fd00c25c0 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -6413,6 +6413,9 @@ void TypeBuilderSetSubType(TypeBuilderRef builder, BinaryenHeapType superType) { ((TypeBuilder*)builder)->setSubType(index, HeapType(superType)); } +void TypeBuilderSetOpen(TypeBuilderRef builder, BinaryenIndex index) { + ((TypeBuilder*)builder)->setOpen(index); +} void TypeBuilderCreateRecGroup(TypeBuilderRef builder, BinaryenIndex index, BinaryenIndex length) { diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 2288eb5ca..f4f4f2d74 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -3572,6 +3572,9 @@ BINARYEN_API BinaryenType TypeBuilderGetTempRefType(TypeBuilderRef builder, BINARYEN_API void TypeBuilderSetSubType(TypeBuilderRef builder, BinaryenIndex index, BinaryenHeapType superType); +// Sets the type at `index` to be open (i.e. non-final). +BINARYEN_API void TypeBuilderSetOpen(TypeBuilderRef builder, + BinaryenIndex index); // Creates a new recursion group in the range `index` inclusive to `index + // length` exclusive. Recursion groups must not overlap. BINARYEN_API void TypeBuilderCreateRecGroup(TypeBuilderRef builder, diff --git a/src/ir/type-updating.cpp b/src/ir/type-updating.cpp index 0bc14763b..cca0d2360 100644 --- a/src/ir/type-updating.cpp +++ b/src/ir/type-updating.cpp @@ -72,7 +72,7 @@ GlobalTypeRewriter::TypeMap GlobalTypeRewriter::rebuildTypes() { // Create the temporary heap types. i = 0; for (auto [type, _] : typeIndices) { - typeBuilder[i].setFinal(type.isFinal()); + typeBuilder[i].setOpen(type.isOpen()); if (type.isSignature()) { auto sig = type.getSignature(); TypeList newParams, newResults; diff --git a/src/passes/TypeMerging.cpp b/src/passes/TypeMerging.cpp index ea1fa7916..3d7a032b5 100644 --- a/src/passes/TypeMerging.cpp +++ b/src/passes/TypeMerging.cpp @@ -538,7 +538,7 @@ bool shapeEq(HeapType a, HeapType b) { // Check whether `a` and `b` have the same top-level structure, including the // position and identity of any children that are not included as transitions // in the DFA, i.e. any children that are not nontrivial references. - if (a.isFinal() != b.isFinal()) { + if (a.isOpen() != b.isOpen()) { return false; } if (a.isStruct() && b.isStruct()) { @@ -554,7 +554,7 @@ bool shapeEq(HeapType a, HeapType b) { } size_t shapeHash(HeapType a) { - size_t digest = hash(a.isFinal()); + size_t digest = hash(a.isOpen()); if (a.isStruct()) { rehash(digest, 0); hash_combine(digest, shapeHash(a.getStruct())); diff --git a/src/passes/TypeSSA.cpp b/src/passes/TypeSSA.cpp index f44df96e1..cb8f0f049 100644 --- a/src/passes/TypeSSA.cpp +++ b/src/passes/TypeSSA.cpp @@ -110,7 +110,7 @@ std::vector<HeapType> ensureTypesAreInNewRecGroup(RecGroup recGroup, if (auto super = type.getSuperType()) { builder[i].subTypeOf(*super); } - builder[i].setFinal(type.isFinal()); + builder[i].setOpen(type.isOpen()); } // Implement the hash as a struct with "random" fields, and add it. @@ -255,6 +255,7 @@ struct TypeSSA : public Pass { builder[i] = oldType.getArray(); } builder[i].subTypeOf(oldType); + builder[i].setOpen(); } builder.createRecGroup(0, num); auto result = builder.build(); @@ -311,7 +312,7 @@ struct TypeSSA : public Pass { return false; } - if (curr->type.getHeapType().isFinal()) { + if (!curr->type.getHeapType().isOpen()) { // We can't create new subtypes of a final type anyway. return false; } diff --git a/src/tools/fuzzing/heap-types.cpp b/src/tools/fuzzing/heap-types.cpp index 2f77c5765..c8980cbe8 100644 --- a/src/tools/fuzzing/heap-types.cpp +++ b/src/tools/fuzzing/heap-types.cpp @@ -87,9 +87,7 @@ struct HeapTypeGeneratorImpl { // Types without nontrivial subtypes may be marked final. for (Index i = 0; i < builder.size(); ++i) { - if (subtypeIndices[i].size() == 1 && rand.oneIn(2)) { - builder[i].setFinal(); - } + builder[i].setOpen(subtypeIndices[i].size() > 1 || rand.oneIn(2)); } // Initialize the recursion groups. @@ -894,7 +892,7 @@ std::vector<HeapType> Inhabitator::build() { builder[i].subTypeOf(*super); } } - builder[i].setFinal(types[i].isFinal()); + builder[i].setOpen(types[i].isOpen()); } auto built = builder.build(); diff --git a/src/tools/wasm-fuzz-types.cpp b/src/tools/wasm-fuzz-types.cpp index 50f1e1e3c..2be8aa5e7 100644 --- a/src/tools/wasm-fuzz-types.cpp +++ b/src/tools/wasm-fuzz-types.cpp @@ -264,7 +264,7 @@ void Fuzzer::checkCanonicalization() { // Set finality for (size_t i = 0; i < types.size(); ++i) { - builder[i].setFinal(types[i].isFinal()); + builder[i].setOpen(types[i].isOpen()); } // Set up recursion groups and record group ends to ensure we only select diff --git a/src/wasm-type.h b/src/wasm-type.h index 0d41d0cc2..927e37845 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -361,7 +361,7 @@ public: bool isArray() const; bool isString() const; bool isBottom() const; - bool isFinal() const; + bool isOpen() const; Signature getSignature() const; const Struct& getStruct() const; @@ -587,7 +587,7 @@ struct TypeBuilder { // not overlap or go out of bounds. void createRecGroup(size_t i, size_t length); - void setFinal(size_t i, bool final = true); + void setOpen(size_t i, bool open = true); enum class ErrorReason { // There is a cycle in the supertype relation. @@ -650,8 +650,8 @@ struct TypeBuilder { builder.setSubType(index, other); return *this; } - Entry& setFinal(bool final = true) { - builder.setFinal(index, final); + Entry& setOpen(bool open = true) { + builder.setOpen(index, open); return *this; } }; diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 51325e7dd..d43640e26 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -265,13 +265,11 @@ void WasmBinaryWriter::writeTypes() { // Emit the type definition. BYN_TRACE("write " << type << std::endl); auto super = type.getSuperType(); - // TODO: Use the binary shorthand for final types once we parse MVP - // signatures as final. - if (type.isFinal() || super || hasSubtypes[i]) { - if (type.isFinal()) { - o << S32LEB(BinaryConsts::EncodedType::SubFinal); - } else { + if (super || type.isOpen()) { + if (type.isOpen()) { o << S32LEB(BinaryConsts::EncodedType::Sub); + } else { + o << S32LEB(BinaryConsts::EncodedType::SubFinal); } if (super) { o << U32LEB(1); @@ -2268,9 +2266,8 @@ void WasmBinaryReader::readTypes() { std::optional<uint32_t> superIndex; if (form == BinaryConsts::EncodedType::Sub || form == BinaryConsts::EncodedType::SubFinal) { - if (form == BinaryConsts::EncodedType::SubFinal) { - // TODO: Interpret type definitions without any `sub` as final as well. - builder[i].setFinal(); + if (form == BinaryConsts::EncodedType::Sub) { + builder[i].setOpen(); } uint32_t supers = getU32LEB(); if (supers > 0) { diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index b6b9a40fb..e30901c5b 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -929,8 +929,9 @@ void SExpressionWasmBuilder::preParseHeapTypes(Element& module) { if (kind == SUB) { Index i = 1; if (*def[i] == FINAL) { - builder[index].setFinal(); ++i; + } else { + builder[index].setOpen(); } if (def[i]->dollared()) { super = def[i]; @@ -959,6 +960,7 @@ void SExpressionWasmBuilder::preParseHeapTypes(Element& module) { if (kind == FUNC) { builder[index] = parseSignatureDef(def, 0); } else if (kind == FUNC_SUBTYPE) { + builder[index].setOpen(); builder[index] = parseSignatureDef(def, 1); super = def[def.size() - 1]; if (!super->dollared() && super->str() == FUNC) { @@ -968,6 +970,7 @@ void SExpressionWasmBuilder::preParseHeapTypes(Element& module) { } else if (kind == STRUCT) { builder[index] = parseStructDef(def, index, 0); } else if (kind == STRUCT_SUBTYPE) { + builder[index].setOpen(); builder[index] = parseStructDef(def, index, 1); super = def[def.size() - 1]; if (!super->dollared() && super->str() == DATA) { @@ -977,6 +980,7 @@ void SExpressionWasmBuilder::preParseHeapTypes(Element& module) { } else if (kind == ARRAY) { builder[index] = parseArrayDef(def); } else if (kind == ARRAY_SUBTYPE) { + builder[index].setOpen(); builder[index] = parseArrayDef(def); super = def[def.size() - 1]; if (!super->dollared() && super->str() == DATA) { @@ -993,6 +997,7 @@ void SExpressionWasmBuilder::preParseHeapTypes(Element& module) { } } else if (elementStartsWith(elem[elem.size() - 1], EXTENDS)) { // '(' 'extends' $supertype ')' + builder[index].setOpen(); Element& extends = *elem[elem.size() - 1]; super = extends[1]; } diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 0c4e7b049..ba38231b6 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -85,7 +85,7 @@ struct HeapTypeInfo { // Used in assertions to ensure that temporary types don't leak into the // global store. bool isTemp = false; - bool isFinal = false; + bool isOpen = false; // The supertype of this HeapType, if it exists. HeapTypeInfo* supertype = nullptr; // The recursion group of this type or null if the recursion group is trivial @@ -1180,11 +1180,11 @@ bool HeapType::isBottom() const { return false; } -bool HeapType::isFinal() const { +bool HeapType::isOpen() const { if (isBasic()) { return false; } else { - return getHeapTypeInfo(*this)->isFinal; + return getHeapTypeInfo(*this)->isOpen; } } @@ -1771,13 +1771,12 @@ std::ostream& TypePrinter::print(HeapType type) { os << "(; temp ;) "; } - // TODO: Use shorthand for final types once we parse MVP signatures as final. bool useSub = false; auto super = type.getSuperType(); - if (super || type.isFinal()) { + if (super || type.isOpen()) { useSub = true; os << "(sub "; - if (type.isFinal()) { + if (!type.isOpen()) { os << "final "; } if (super) { @@ -1946,7 +1945,7 @@ size_t RecGroupHasher::hash(const HeapTypeInfo& info) const { if (info.supertype) { hash_combine(digest, hash(HeapType(uintptr_t(info.supertype)))); } - wasm::rehash(digest, info.isFinal); + wasm::rehash(digest, info.isOpen); wasm::rehash(digest, info.kind); switch (info.kind) { case HeapTypeInfo::SignatureKind: @@ -2069,7 +2068,7 @@ bool RecGroupEquator::eq(const HeapTypeInfo& a, const HeapTypeInfo& b) const { return false; } } - if (a.isFinal != b.isFinal) { + if (a.isOpen != b.isOpen) { return false; } if (a.kind != b.kind) { @@ -2325,15 +2324,15 @@ void TypeBuilder::createRecGroup(size_t index, size_t length) { {RecGroup(uintptr_t(groupInfo.get())), std::move(groupInfo)}); } -void TypeBuilder::setFinal(size_t i, bool final) { +void TypeBuilder::setOpen(size_t i, bool open) { assert(i < size() && "index out of bounds"); - impl->entries[i].info->isFinal = final; + impl->entries[i].info->isOpen = open; } namespace { bool isValidSupertype(const HeapTypeInfo& sub, const HeapTypeInfo& super) { - if (super.isFinal) { + if (!super.isOpen) { return false; } if (sub.kind != super.kind) { diff --git a/src/wasm/wat-parser.cpp b/src/wasm/wat-parser.cpp index 3961cbb7f..bdd1af0d8 100644 --- a/src/wasm/wat-parser.cpp +++ b/src/wasm/wat-parser.cpp @@ -849,6 +849,7 @@ struct ParseDeclsCtx : NullTypeParserCtx, NullInstrParserCtx { void addFuncType(SignatureT) {} void addStructType(StructT) {} void addArrayType(ArrayT) {} + void setOpen() {} Result<> addSubtype(Index) { return Ok{}; } void finishSubtype(Name name, Index pos) { subtypeDefs.push_back({name, pos, Index(subtypeDefs.size())}); @@ -1078,6 +1079,8 @@ struct ParseTypeDefsCtx : TypeParserCtx<ParseTypeDefsCtx> { void addArrayType(ArrayT& type) { builder[index] = type; } + void setOpen() { builder[index].setOpen(); } + Result<> addSubtype(Index super) { if (super >= builder.size()) { return in.err("supertype index out of bounds"); @@ -3463,6 +3466,9 @@ template<typename Ctx> MaybeResult<> subtype(Ctx& ctx) { } if (ctx.in.takeSExprStart("sub"sv)) { + if (ctx.in.takeKeyword("open"sv)) { + ctx.setOpen(); + } if (auto super = maybeTypeidx(ctx)) { CHECK_ERR(super); CHECK_ERR(ctx.addSubtype(*super)); diff --git a/test/ctor-eval/gc-2.wast.out b/test/ctor-eval/gc-2.wast.out index 22b68c33d..cec7f9430 100644 --- a/test/ctor-eval/gc-2.wast.out +++ b/test/ctor-eval/gc-2.wast.out @@ -1,5 +1,5 @@ (module - (type $struct (struct (field i32))) + (type $struct (sub (struct (field i32)))) (type $1 (func (result i32))) (global $ctor-eval$global_4 (ref $struct) (struct.new $struct (i32.const 9999) diff --git a/test/ctor-eval/gc.wast.out b/test/ctor-eval/gc.wast.out index 783d27f73..8999d4756 100644 --- a/test/ctor-eval/gc.wast.out +++ b/test/ctor-eval/gc.wast.out @@ -1,5 +1,5 @@ (module - (type $struct (struct (field i32))) + (type $struct (sub (struct (field i32)))) (type $1 (func (param anyref))) (type $2 (func (result i32))) (type $3 (func)) diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 36e6776f7..c2c5d6e31 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -2160,6 +2160,7 @@ void test_typebuilder() { tempArrayType, BinaryenPackedTypeNotPacked(), true); + TypeBuilderSetOpen(builder, tempArrayIndex); // Create a recursive struct with a field of its own type const BinaryenIndex tempStructIndex = 1; @@ -2173,6 +2174,7 @@ void test_typebuilder() { bool fieldMutables[] = {true}; TypeBuilderSetStructType( builder, tempStructIndex, fieldTypes, fieldPackedTypes, fieldMutables, 1); + TypeBuilderSetOpen(builder, tempStructIndex); } // Create a recursive signature with parameter and result including its own @@ -2189,6 +2191,7 @@ void test_typebuilder() { tempSignatureIndex, TypeBuilderGetTempTupleType(builder, (BinaryenType*)¶mTypes, 2), tempSignatureType); + TypeBuilderSetOpen(builder, tempSignatureIndex); } // Create a subtype (with an additional immutable packed field) @@ -2209,11 +2212,10 @@ void test_typebuilder() { fieldPackedTypes, fieldMutables, 2); + TypeBuilderSetOpen(builder, tempSubStructIndex); } TypeBuilderSetSubType(builder, tempSubStructIndex, tempStructHeapType); - // TODO: Rtts (post-MVP?) - // Build the type hierarchy and dispose the builder BinaryenHeapType heapTypes[4]; BinaryenIndex errorIndex; diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index cde0e0279..d84e9c888 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -3166,9 +3166,9 @@ TypeBuilderErrorReasonForwardSupertypeReference: 2 TypeBuilderErrorReasonForwardChildReference: 3 module with recursive GC types: (module - (type $SomeArray (array (mut (ref null $SomeArray)))) - (type $SomeSignature (func (param (ref null $SomeSignature) (ref null $SomeArray)) (result (ref null $SomeSignature)))) - (type $SomeStruct (struct (field $SomeField (mut (ref null $SomeStruct))))) + (type $SomeArray (sub (array (mut (ref null $SomeArray))))) + (type $SomeSignature (sub (func (param (ref null $SomeSignature) (ref null $SomeArray)) (result (ref null $SomeSignature))))) + (type $SomeStruct (sub (struct (field $SomeField (mut (ref null $SomeStruct)))))) (type $3 (func)) (type $SomeSubStruct (sub $SomeStruct (struct (field $SomeField (mut (ref null $SomeStruct))) (field $SomePackedField i8)))) (func $test (type $3) diff --git a/test/gtest/possible-contents.cpp b/test/gtest/possible-contents.cpp index 1092a825b..1838ad3ab 100644 --- a/test/gtest/possible-contents.cpp +++ b/test/gtest/possible-contents.cpp @@ -539,14 +539,11 @@ TEST_F(PossibleContentsTest, TestStructCones) { */ TypeBuilder builder(5); builder.createRecGroup(0, 5); - builder.setHeapType(0, Struct(FieldList{})); - builder.setHeapType(1, Struct(FieldList{})); - builder.setHeapType(2, Struct(FieldList{})); - builder.setHeapType(3, Struct(FieldList{})); - builder.setHeapType(4, Struct(FieldList{})); - builder.setSubType(1, builder.getTempHeapType(0)); - builder.setSubType(2, builder.getTempHeapType(0)); - builder.setSubType(3, builder.getTempHeapType(2)); + builder[0].setOpen() = Struct(FieldList{}); + builder[1].setOpen().subTypeOf(builder[0]) = Struct(FieldList{}); + builder[2].setOpen().subTypeOf(builder[0]) = Struct(FieldList{}); + builder[3].setOpen().subTypeOf(builder[2]) = Struct(FieldList{}); + builder[4].setOpen() = Struct(FieldList{}); auto result = builder.build(); ASSERT_TRUE(result); auto types = *result; diff --git a/test/gtest/type-builder.cpp b/test/gtest/type-builder.cpp index d64d94699..0184eb074 100644 --- a/test/gtest/type-builder.cpp +++ b/test/gtest/type-builder.cpp @@ -261,7 +261,7 @@ TEST_F(TypeTest, InvalidFinalSupertype) { TypeBuilder builder(2); builder[0] = Struct{}; builder[1] = Struct{}; - builder[0].setFinal(); + builder[0].setOpen(false); builder[1].subTypeOf(builder[0]); auto result = builder.build(); @@ -426,19 +426,16 @@ TEST_F(TypeTest, CanonicalizeSelfReferences) { TEST_F(TypeTest, CanonicalizeSupertypes) { TypeBuilder builder(6); - builder[0] = Struct{}; - builder[1] = Struct{}; + builder[0].setOpen() = Struct{}; + builder[1].setOpen() = Struct{}; // Type with a supertype - builder[2] = Struct{}; - builder[2].subTypeOf(builder[0]); + builder[2].setOpen().subTypeOf(builder[0]) = Struct{}; // Type with the same supertype after canonicalization. - builder[3] = Struct{}; - builder[3].subTypeOf(builder[1]); + builder[3].setOpen().subTypeOf(builder[1]) = Struct{}; // Type with a different supertype - builder[4] = Struct{}; - builder[4].subTypeOf(builder[2]); + builder[4].setOpen().subTypeOf(builder[2]) = Struct{}; // Type with no supertype - builder[5] = Struct{}; + builder[5].setOpen() = Struct{}; auto result = builder.build(); ASSERT_TRUE(result); @@ -455,16 +452,15 @@ TEST_F(TypeTest, CanonicalizeFinal) { // Types are different if their finality flag is different. TypeBuilder builder(2); builder[0] = Struct{}; - builder[1] = Struct{}; - builder[0].setFinal(); + builder[1].setOpen() = Struct{}; auto result = builder.build(); ASSERT_TRUE(result); auto built = *result; EXPECT_NE(built[0], built[1]); - EXPECT_TRUE(built[0].isFinal()); - EXPECT_FALSE(built[1].isFinal()); + EXPECT_TRUE(!built[0].isOpen()); + EXPECT_FALSE(!built[1].isOpen()); } TEST_F(TypeTest, HeapTypeConstructors) { @@ -500,21 +496,21 @@ TEST_F(TypeTest, CanonicalizeTypesBeforeSubtyping) { TypeBuilder builder(6); // A rec group builder.createRecGroup(0, 2); - builder[0] = Struct{}; - builder[1] = Struct{}; + builder[0].setOpen() = Struct{}; + builder[1].setOpen() = Struct{}; builder[1].subTypeOf(builder[0]); // The same rec group again builder.createRecGroup(2, 2); - builder[2] = Struct{}; - builder[3] = Struct{}; + builder[2].setOpen() = Struct{}; + builder[3].setOpen() = Struct{}; builder[3].subTypeOf(builder[2]); // This subtyping only validates if the previous two groups are deduplicated // before checking subtype validity. - builder[4] = + builder[4].setOpen() = Struct({Field(builder.getTempRefType(builder[0], Nullable), Immutable)}); - builder[5] = + builder[5].setOpen() = Struct({Field(builder.getTempRefType(builder[3], Nullable), Immutable)}); builder[5].subTypeOf(builder[4]); @@ -754,9 +750,8 @@ TEST_F(TypeTest, TestHeapTypeRelations) { { // Immutable array fields are covariant. TypeBuilder builder(2); - builder[0] = Array(Field(anyref, Immutable)); - builder[1] = Array(Field(eqref, Immutable)); - builder[1].subTypeOf(builder[0]); + builder[0].setOpen() = Array(Field(anyref, Immutable)); + builder[1].setOpen().subTypeOf(builder[0]) = Array(Field(eqref, Immutable)); auto results = builder.build(); ASSERT_TRUE(results); auto built = *results; @@ -766,9 +761,9 @@ TEST_F(TypeTest, TestHeapTypeRelations) { { // Depth subtyping TypeBuilder builder(2); - builder[0] = Struct({Field(anyref, Immutable)}); - builder[1] = Struct({Field(eqref, Immutable)}); - builder[1].subTypeOf(builder[0]); + builder[0].setOpen() = Struct({Field(anyref, Immutable)}); + builder[1].setOpen().subTypeOf(builder[0]) = + Struct({Field(eqref, Immutable)}); auto results = builder.build(); ASSERT_TRUE(results); auto built = *results; @@ -778,9 +773,9 @@ TEST_F(TypeTest, TestHeapTypeRelations) { { // Width subtyping TypeBuilder builder(2); - builder[0] = Struct({Field(anyref, Immutable)}); - builder[1] = Struct({Field(anyref, Immutable), Field(anyref, Immutable)}); - builder[1].subTypeOf(builder[0]); + builder[0].setOpen() = Struct({Field(anyref, Immutable)}); + builder[1].setOpen().subTypeOf(builder[0]) = + Struct({Field(anyref, Immutable), Field(anyref, Immutable)}); auto results = builder.build(); ASSERT_TRUE(results); auto built = *results; @@ -792,12 +787,12 @@ TEST_F(TypeTest, TestHeapTypeRelations) { TypeBuilder builder(4); auto ref0 = builder.getTempRefType(builder[0], Nullable); auto ref1 = builder.getTempRefType(builder[1], Nullable); - builder[0] = Struct({Field(anyref, Immutable)}); - builder[1] = Struct({Field(eqref, Immutable)}); - builder[2] = Struct({Field(ref0, Immutable)}); - builder[3] = Struct({Field(ref1, Immutable)}); - builder[1].subTypeOf(builder[0]); - builder[3].subTypeOf(builder[2]); + builder[0].setOpen() = Struct({Field(anyref, Immutable)}); + builder[1].setOpen().subTypeOf(builder[0]) = + Struct({Field(eqref, Immutable)}); + builder[2].setOpen() = Struct({Field(ref0, Immutable)}); + builder[3].setOpen().subTypeOf(builder[2]) = + Struct({Field(ref1, Immutable)}); auto results = builder.build(); ASSERT_TRUE(results); auto built = *results; @@ -809,9 +804,9 @@ TEST_F(TypeTest, TestHeapTypeRelations) { TypeBuilder builder(2); auto ref0 = builder.getTempRefType(builder[0], Nullable); auto ref1 = builder.getTempRefType(builder[1], Nullable); - builder[0] = Struct({Field(ref0, Immutable)}); - builder[1] = Struct({Field(ref1, Immutable)}); - builder[1].subTypeOf(builder[0]); + builder[0].setOpen() = Struct({Field(ref0, Immutable)}); + builder[1].setOpen().subTypeOf(builder[0]) = + Struct({Field(ref1, Immutable)}); auto results = builder.build(); ASSERT_TRUE(results); auto built = *results; @@ -868,8 +863,8 @@ TEST_F(TypeTest, TestSubTypes) { // Build type types, the second of which is a subtype. TypeBuilder builder(2); - builder[0] = Struct({Field(anyref, Immutable)}); - builder[1] = Struct({Field(eqref, Immutable)}); + builder[0].setOpen() = Struct({Field(anyref, Immutable)}); + builder[1].setOpen() = Struct({Field(eqref, Immutable)}); builder[1].subTypeOf(builder[0]); auto result = builder.build(); @@ -902,7 +897,7 @@ TEST_F(TypeTest, TestExistingSuperType) { Type A1; { TypeBuilder builder(1); - builder[0] = Struct(); + builder[0].setOpen() = Struct(); auto result = builder.build(); ASSERT_TRUE(result); auto built = *result; @@ -913,7 +908,7 @@ TEST_F(TypeTest, TestExistingSuperType) { Type A2; { TypeBuilder builder(1); - builder[0] = Struct(); + builder[0].setOpen() = Struct(); auto result = builder.build(); ASSERT_TRUE(result); auto built = *result; @@ -924,8 +919,7 @@ TEST_F(TypeTest, TestExistingSuperType) { Type B1; { TypeBuilder builder(1); - builder[0] = Struct(); - builder.setSubType(0, A1.getHeapType()); + builder[0].setOpen().subTypeOf(A1.getHeapType()) = Struct(); auto result = builder.build(); ASSERT_TRUE(result); auto built = *result; @@ -936,8 +930,7 @@ TEST_F(TypeTest, TestExistingSuperType) { Type B2; { TypeBuilder builder(1); - builder[0] = Struct(); - builder.setSubType(0, A2.getHeapType()); + builder[0].setOpen().subTypeOf(A2.getHeapType()) = Struct(); auto result = builder.build(); ASSERT_TRUE(result); auto built = *result; @@ -959,9 +952,8 @@ TEST_F(TypeTest, TestMaxStructDepths) { HeapType A, B; { TypeBuilder builder(2); - builder[0] = Struct(); - builder[1] = Struct(); - builder.setSubType(1, builder.getTempHeapType(0)); + builder[0].setOpen() = Struct(); + builder[1].setOpen().subTypeOf(builder[0]) = Struct(); auto result = builder.build(); ASSERT_TRUE(result); auto built = *result; @@ -1004,10 +996,9 @@ TEST_F(TypeTest, TestDepth) { HeapType A, B, C; { TypeBuilder builder(3); - builder[0] = Struct(); - builder[1] = Struct(); - builder[2] = Array(Field(Type::i32, Immutable)); - builder.setSubType(1, builder.getTempHeapType(0)); + builder[0].setOpen() = Struct(); + builder[1].setOpen().subTypeOf(builder[0]) = Struct(); + builder[2].setOpen() = Array(Field(Type::i32, Immutable)); auto result = builder.build(); ASSERT_TRUE(result); auto built = *result; @@ -1054,13 +1045,10 @@ TEST_F(TypeTest, TestIterSubTypes) { HeapType A, B, C, D; { TypeBuilder builder(4); - builder[0] = Struct(); - builder[1] = Struct(); - builder[2] = Struct(); - builder[3] = Struct(); - builder.setSubType(1, builder.getTempHeapType(0)); - builder.setSubType(2, builder.getTempHeapType(0)); - builder.setSubType(3, builder.getTempHeapType(2)); + builder[0].setOpen() = Struct(); + builder[1].setOpen().subTypeOf(builder[0]) = Struct(); + builder[2].setOpen().subTypeOf(builder[0]) = Struct(); + builder[3].setOpen().subTypeOf(builder[2]) = Struct(); auto result = builder.build(); ASSERT_TRUE(result); auto built = *result; diff --git a/test/lit/fuzz-types.test b/test/lit/fuzz-types.test index 494aa996f..ae5c00019 100644 --- a/test/lit/fuzz-types.test +++ b/test/lit/fuzz-types.test @@ -1,59 +1,60 @@ ;; RUN: wasm-fuzz-types -v --seed=0 | filecheck %s -;; CHECK: Built 20 types: +;; CHECK: Running with seed 0 +;; CHECK-NEXT: Built 20 types: ;; CHECK-NEXT: (rec -;; CHECK-NEXT: (type $0 (struct (field i32))) -;; CHECK-NEXT: (type $1 (func (param (ref $2)) (result externref))) -;; CHECK-NEXT: (type $2 (struct )) +;; CHECK-NEXT: (type $0 (sub (struct (field i32)))) +;; CHECK-NEXT: (type $1 (sub (func (param (ref $2)) (result externref)))) +;; CHECK-NEXT: (type $2 (sub (struct ))) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (rec ;; CHECK-NEXT: (type $3 (sub $0 (struct (field i32) (field (ref $5)) (field (ref $5))))) -;; CHECK-NEXT: (type $4 (sub final $3 (struct (field i32) (field (ref $5)) (field (ref $5)) (field i8) (field (ref null $13)) (field (mut i64))))) -;; CHECK-NEXT: (type $5 (array (mut f64))) -;; CHECK-NEXT: (type $6 (sub final $1 (func (param anyref) (result externref)))) -;; CHECK-NEXT: (type $7 (sub $2 (struct (field (mut (ref null $14))) (field (ref $3))))) +;; CHECK-NEXT: (type $4 (sub $3 (struct (field i32) (field (ref $5)) (field (ref $5)) (field i8) (field (ref null $13)) (field (mut i64))))) +;; CHECK-NEXT: (type $5 (sub (array (mut f64)))) +;; CHECK-NEXT: (type $6 (sub $1 (func (param anyref) (result externref)))) +;; CHECK-NEXT: (type $7 (sub final $2 (struct (field (mut (ref null $14))) (field (ref $3))))) ;; CHECK-NEXT: (type $8 (sub $1 (func (param (ref struct)) (result (ref extern))))) ;; CHECK-NEXT: (type $9 (sub $5 (array (mut f64)))) -;; CHECK-NEXT: (type $10 (sub $8 (func (param (ref any)) (result (ref noextern))))) -;; CHECK-NEXT: (type $11 (array (mut anyref))) +;; CHECK-NEXT: (type $10 (sub final $8 (func (param (ref any)) (result (ref noextern))))) +;; CHECK-NEXT: (type $11 (sub (array (mut anyref)))) ;; CHECK-NEXT: (type $12 (sub $2 (struct (field (mut f64))))) -;; CHECK-NEXT: (type $13 (sub $1 (func (param (ref $2)) (result (ref extern))))) +;; CHECK-NEXT: (type $13 (sub final $1 (func (param (ref $2)) (result (ref extern))))) ;; CHECK-NEXT: (type $14 (array (mut (ref null $14)))) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (rec -;; CHECK-NEXT: (type $15 (sub $11 (array (mut anyref)))) -;; CHECK-NEXT: (type $16 (sub $12 (struct (field (mut f64))))) -;; CHECK-NEXT: (type $17 (sub final (struct (field f32) (field (mut i32)) (field i8) (field (ref array))))) -;; CHECK-NEXT: (type $18 (sub final $11 (array (mut anyref)))) -;; CHECK-NEXT: (type $19 (sub $9 (array (mut f64)))) +;; CHECK-NEXT: (type $15 (sub final $11 (array (mut anyref)))) +;; CHECK-NEXT: (type $16 (sub final $12 (struct (field (mut f64))))) +;; CHECK-NEXT: (type $17 (sub (struct (field f32) (field (mut i32)) (field i8) (field (ref array))))) +;; CHECK-NEXT: (type $18 (sub $11 (array (mut anyref)))) +;; CHECK-NEXT: (type $19 (sub final $9 (array (mut f64)))) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ;; CHECK-NEXT: Inhabitable types: ;; CHECK-NEXT: ;; CHECK-NEXT: Built 20 types: ;; CHECK-NEXT: (rec -;; CHECK-NEXT: (type $0 (struct (field i32))) -;; CHECK-NEXT: (type $1 (func (param (ref $2)) (result externref))) -;; CHECK-NEXT: (type $2 (struct )) +;; CHECK-NEXT: (type $0 (sub (struct (field i32)))) +;; CHECK-NEXT: (type $1 (sub (func (param (ref $2)) (result externref)))) +;; CHECK-NEXT: (type $2 (sub (struct ))) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (rec ;; CHECK-NEXT: (type $3 (sub $0 (struct (field i32) (field (ref $5)) (field (ref $5))))) -;; CHECK-NEXT: (type $4 (sub final $3 (struct (field i32) (field (ref $5)) (field (ref $5)) (field i8) (field (ref null $13)) (field (mut i64))))) -;; CHECK-NEXT: (type $5 (array (mut f64))) -;; CHECK-NEXT: (type $6 (sub final $1 (func (param anyref) (result externref)))) -;; CHECK-NEXT: (type $7 (sub $2 (struct (field (mut (ref null $14))) (field (ref $3))))) +;; CHECK-NEXT: (type $4 (sub $3 (struct (field i32) (field (ref $5)) (field (ref $5)) (field i8) (field (ref null $13)) (field (mut i64))))) +;; CHECK-NEXT: (type $5 (sub (array (mut f64)))) +;; CHECK-NEXT: (type $6 (sub $1 (func (param anyref) (result externref)))) +;; CHECK-NEXT: (type $7 (sub final $2 (struct (field (mut (ref null $14))) (field (ref $3))))) ;; CHECK-NEXT: (type $8 (sub $1 (func (param (ref struct)) (result (ref extern))))) ;; CHECK-NEXT: (type $9 (sub $5 (array (mut f64)))) -;; CHECK-NEXT: (type $10 (sub $8 (func (param (ref any)) (result (ref noextern))))) -;; CHECK-NEXT: (type $11 (array (mut anyref))) +;; CHECK-NEXT: (type $10 (sub final $8 (func (param (ref any)) (result (ref noextern))))) +;; CHECK-NEXT: (type $11 (sub (array (mut anyref)))) ;; CHECK-NEXT: (type $12 (sub $2 (struct (field (mut f64))))) -;; CHECK-NEXT: (type $13 (sub $1 (func (param (ref $2)) (result (ref extern))))) +;; CHECK-NEXT: (type $13 (sub final $1 (func (param (ref $2)) (result (ref extern))))) ;; CHECK-NEXT: (type $14 (array (mut (ref null $14)))) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (rec -;; CHECK-NEXT: (type $15 (sub $11 (array (mut anyref)))) -;; CHECK-NEXT: (type $16 (sub $12 (struct (field (mut f64))))) -;; CHECK-NEXT: (type $17 (sub final (struct (field f32) (field (mut i32)) (field i8) (field (ref array))))) -;; CHECK-NEXT: (type $18 (sub final $11 (array (mut anyref)))) -;; CHECK-NEXT: (type $19 (sub $9 (array (mut f64)))) -;; CHECK-NEXT: ) +;; CHECK-NEXT: (type $15 (sub final $11 (array (mut anyref)))) +;; CHECK-NEXT: (type $16 (sub final $12 (struct (field (mut f64))))) +;; CHECK-NEXT: (type $17 (sub (struct (field f32) (field (mut i32)) (field i8) (field (ref array))))) +;; CHECK-NEXT: (type $18 (sub $11 (array (mut anyref)))) +;; CHECK-NEXT: (type $19 (sub final $9 (array (mut f64)))) +) diff --git a/test/lit/isorecursive-good.wast b/test/lit/isorecursive-good.wast index 10dc7726b..43caeb7d1 100644 --- a/test/lit/isorecursive-good.wast +++ b/test/lit/isorecursive-good.wast @@ -6,7 +6,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $super-struct (struct (field i32))) + ;; CHECK-NEXT: (type $super-struct (sub (struct (field i32)))) (type $super-struct (sub (struct i32))) ;; CHECK: (type $sub-struct (sub $super-struct (struct (field i32) (field i64)))) (type $sub-struct (sub $super-struct (struct i32 i64))) @@ -16,7 +16,7 @@ (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $super-array (array (ref $super-struct))) + ;; CHECK-NEXT: (type $super-array (sub (array (ref $super-struct)))) (type $super-array (sub (array (ref $super-struct)))) ;; CHECK: (type $sub-array (sub $super-array (array (ref $sub-struct)))) (type $sub-array (sub $super-array (array (ref $sub-struct)))) @@ -26,7 +26,7 @@ (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $super-func (func (param (ref $sub-array)) (result (ref $super-array)))) + ;; CHECK-NEXT: (type $super-func (sub (func (param (ref $sub-array)) (result (ref $super-array))))) (type $super-func (sub (func (param (ref $sub-array)) (result (ref $super-array))))) ;; CHECK: (type $sub-func (sub $super-func (func (param (ref $super-array)) (result (ref $sub-array))))) (type $sub-func (sub $super-func (func (param (ref $super-array)) (result (ref $sub-array))))) @@ -34,7 +34,7 @@ (type $final-func (sub final $sub-func (func (param (ref $super-array)) (result (ref $final-array))))) ) - ;; CHECK: (type $final-root (sub final (struct ))) + ;; CHECK: (type $final-root (struct )) (type $final-root (sub final (struct))) ;; CHECK: (func $make-super-struct (type $6) (result (ref $super-struct)) diff --git a/test/lit/isorecursive-output-ordering.wast b/test/lit/isorecursive-output-ordering.wast index 5379cec44..43bda9a21 100644 --- a/test/lit/isorecursive-output-ordering.wast +++ b/test/lit/isorecursive-output-ordering.wast @@ -9,22 +9,22 @@ (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $unused-6 (struct )) + ;; CHECK-NEXT: (type $unused-6 (sub (struct ))) - ;; CHECK: (type $used-a-bit (struct )) + ;; CHECK: (type $used-a-bit (sub (struct ))) ;; CHECK: (rec - ;; CHECK-NEXT: (type $unused-1 (struct )) + ;; CHECK-NEXT: (type $unused-1 (sub (struct ))) (type $unused-1 (struct_subtype data)) - ;; CHECK: (type $unused-2 (struct )) + ;; CHECK: (type $unused-2 (sub (struct ))) (type $unused-2 (struct_subtype data)) - ;; CHECK: (type $unused-3 (struct )) + ;; CHECK: (type $unused-3 (sub (struct ))) (type $unused-3 (struct_subtype data)) - ;; CHECK: (type $unused-4 (struct )) + ;; CHECK: (type $unused-4 (sub (struct ))) (type $unused-4 (struct_subtype data)) - ;; CHECK: (type $used-a-lot (struct )) + ;; CHECK: (type $used-a-lot (sub (struct ))) (type $used-a-lot (struct_subtype data)) - ;; CHECK: (type $unused-5 (struct )) + ;; CHECK: (type $unused-5 (sub (struct ))) (type $unused-5 (struct_subtype data)) ) @@ -47,9 +47,9 @@ (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $leaf (struct )) + ;; CHECK-NEXT: (type $leaf (sub (struct ))) (type $leaf (struct_subtype data)) - ;; CHECK: (type $unused (struct )) + ;; CHECK: (type $unused (sub (struct ))) (type $unused (struct_subtype data)) ) @@ -57,12 +57,12 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $shrub (sub $leaf (struct ))) - ;; CHECK: (type $used-a-ton (struct )) + ;; CHECK: (type $used-a-ton (sub (struct ))) ;; CHECK: (rec - ;; CHECK-NEXT: (type $twig (struct )) + ;; CHECK-NEXT: (type $twig (sub (struct ))) (type $twig (struct_subtype data)) - ;; CHECK: (type $used-a-bit (struct (field (ref $leaf)))) + ;; CHECK: (type $used-a-bit (sub (struct (field (ref $leaf))))) (type $used-a-bit (struct_subtype (ref $leaf) data)) ) @@ -73,7 +73,7 @@ (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $root (struct )) + ;; CHECK-NEXT: (type $root (sub (struct ))) (type $root (struct_subtype data)) ;; CHECK: (type $used-a-lot (sub $twig (struct ))) (type $used-a-lot (struct_subtype $twig)) @@ -99,7 +99,7 @@ ;; Test that basic heap type children do not trigger assertions. (rec - ;; CHECK: (type $contains-basic (struct (field (ref any)))) + ;; CHECK: (type $contains-basic (sub (struct (field (ref any))))) (type $contains-basic (struct_subtype (ref any) data)) ) diff --git a/test/lit/isorecursive-singleton-group.wast b/test/lit/isorecursive-singleton-group.wast index 0f73477b9..6462b0288 100644 --- a/test/lit/isorecursive-singleton-group.wast +++ b/test/lit/isorecursive-singleton-group.wast @@ -10,7 +10,7 @@ (rec - ;; CHECK: (type $singleton (struct )) + ;; CHECK: (type $singleton (sub (struct ))) (type $singleton (struct_subtype data)) ) diff --git a/test/lit/isorecursive-whole-group.wast b/test/lit/isorecursive-whole-group.wast index 14ce524ff..4900d0ad9 100644 --- a/test/lit/isorecursive-whole-group.wast +++ b/test/lit/isorecursive-whole-group.wast @@ -9,9 +9,9 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $used (struct )) + ;; CHECK-NEXT: (type $used (sub (struct ))) (type $used (struct_subtype data)) - ;; CHECK: (type $unused (struct )) + ;; CHECK: (type $unused (sub (struct ))) (type $unused (struct_subtype data)) ) diff --git a/test/lit/parse-nominal-types-extends.wast b/test/lit/parse-nominal-types-extends.wast index 51341dfd0..5ce3ffa91 100644 --- a/test/lit/parse-nominal-types-extends.wast +++ b/test/lit/parse-nominal-types-extends.wast @@ -7,8 +7,8 @@ ;; void function type (module - ;; CHECK: (type $super (func)) - (type $super (func)) + ;; CHECK: (type $super (sub (func))) + (type $super (sub (func))) ;; CHECK: (type $sub (sub $super (func))) (type $sub (func) (extends $super)) @@ -19,8 +19,8 @@ ;; function type with params and results (module - ;; CHECK: (type $super (func (param i32) (result i32))) - (type $super (func (param i32) (result i32))) + ;; CHECK: (type $super (sub (func (param i32) (result i32)))) + (type $super (sub (func (param i32) (result i32)))) ;; CHECK: (type $sub (sub $super (func (param i32) (result i32)))) (type $sub (func (param i32) (result i32)) (extends $super)) @@ -31,8 +31,8 @@ ;; empty struct type (module - ;; CHECK: (type $super (struct )) - (type $super (struct)) + ;; CHECK: (type $super (sub (struct ))) + (type $super (sub (struct))) ;; CHECK: (type $sub (sub $super (struct ))) (type $sub (struct) (extends $super)) @@ -43,8 +43,8 @@ ;; struct type with fields (module - ;; CHECK: (type $super (struct (field i32) (field i64))) - (type $super (struct (field i32) i64)) + ;; CHECK: (type $super (sub (struct (field i32) (field i64)))) + (type $super (sub (struct (field i32) i64))) ;; CHECK: (type $sub (sub $super (struct (field i32) (field i64)))) (type $sub (struct i32 (field i64)) (extends $super)) @@ -55,8 +55,8 @@ ;; array type (module - ;; CHECK: (type $super (array i8)) - (type $super (array i8)) + ;; CHECK: (type $super (sub (array i8))) + (type $super (sub (array i8))) ;; CHECK: (type $sub (sub $super (array i8))) (type $sub (array i8) (extends $super)) diff --git a/test/lit/parse-nominal-types.wast b/test/lit/parse-nominal-types.wast index f43c12950..2b753303e 100644 --- a/test/lit/parse-nominal-types.wast +++ b/test/lit/parse-nominal-types.wast @@ -7,7 +7,7 @@ ;; void function type (module - ;; CHECK: (type $super (func)) + ;; CHECK: (type $super (sub (func))) (type $super (func_subtype func)) ;; CHECK: (type $sub (sub $super (func))) @@ -19,7 +19,7 @@ ;; function type with params and results (module - ;; CHECK: (type $super (func (param i32) (result i32))) + ;; CHECK: (type $super (sub (func (param i32) (result i32)))) (type $super (func_subtype (param i32) (result i32) func)) ;; CHECK: (type $sub (sub $super (func (param i32) (result i32)))) @@ -31,7 +31,7 @@ ;; empty struct type (module - ;; CHECK: (type $super (struct )) + ;; CHECK: (type $super (sub (struct ))) (type $super (struct_subtype data)) ;; CHECK: (type $sub (sub $super (struct ))) @@ -43,7 +43,7 @@ ;; struct type with fields (module - ;; CHECK: (type $super (struct (field i32) (field i64))) + ;; CHECK: (type $super (sub (struct (field i32) (field i64)))) (type $super (struct_subtype (field i32) i64 data)) ;; CHECK: (type $sub (sub $super (struct (field i32) (field i64)))) @@ -55,7 +55,7 @@ ;; array type (module - ;; CHECK: (type $super (array i8)) + ;; CHECK: (type $super (sub (array i8))) (type $super (array_subtype i8 data)) ;; CHECK: (type $sub (sub $super (array i8))) diff --git a/test/lit/passes/abstract-type-refining.wast b/test/lit/passes/abstract-type-refining.wast index 64b7ff214..274909605 100644 --- a/test/lit/passes/abstract-type-refining.wast +++ b/test/lit/passes/abstract-type-refining.wast @@ -14,13 +14,13 @@ ;; NO_TNH: (rec ;; NO_TNH-NEXT: (type $0 (func)) - ;; NO_TNH: (type $A (struct )) - (type $A (struct)) + ;; NO_TNH: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; YESTNH: (rec ;; YESTNH-NEXT: (type $0 (func)) - ;; YESTNH: (type $B (struct )) + ;; YESTNH: (type $B (sub (struct ))) ;; NO_TNH: (type $B (sub $A (struct ))) (type $B (struct_subtype $A)) @@ -264,10 +264,10 @@ (module (rec ;; YESTNH: (rec - ;; YESTNH-NEXT: (type $A (struct )) + ;; YESTNH-NEXT: (type $A (sub (struct ))) ;; NO_TNH: (rec - ;; NO_TNH-NEXT: (type $A (struct )) - (type $A (struct)) + ;; NO_TNH-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; YESTNH: (type $B1 (sub $A (struct ))) @@ -362,13 +362,13 @@ (module (rec ;; NO_TNH: (rec - ;; NO_TNH-NEXT: (type $A (struct )) - (type $A (struct)) + ;; NO_TNH-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) (type $B (struct_subtype $A)) ;; YESTNH: (rec - ;; YESTNH-NEXT: (type $B1 (struct )) + ;; YESTNH-NEXT: (type $B1 (sub (struct ))) ;; NO_TNH: (type $B1 (sub $A (struct ))) (type $B1 (struct_subtype $A)) ;; this is a new type ) @@ -449,14 +449,14 @@ ;; A chain, $A :> $B :> $C, where we can optimize $A all the way to $C. (module ;; NO_TNH: (rec - ;; NO_TNH-NEXT: (type $A (struct )) - (type $A (struct)) + ;; NO_TNH-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; NO_TNH: (type $B (sub $A (struct ))) (type $B (struct_subtype $A)) ;; YESTNH: (rec - ;; YESTNH-NEXT: (type $C (struct )) + ;; YESTNH-NEXT: (type $C (sub (struct ))) ;; NO_TNH: (type $C (sub $B (struct ))) (type $C (struct_subtype $B)) @@ -537,7 +537,7 @@ ;; created here. No type needs to be emitted in the output. (module (rec - (type $A (struct)) + (type $A (sub (struct))) (type $B (struct_subtype $A)) @@ -824,8 +824,8 @@ ;; NO_TNH: (rec ;; NO_TNH-NEXT: (type $0 (func (param anyref))) - ;; NO_TNH: (type $A (struct )) - (type $A (struct)) + ;; NO_TNH: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; NO_TNH: (type $B (sub $A (struct ))) (type $B (struct_subtype $A)) @@ -833,7 +833,7 @@ ;; YESTNH: (rec ;; YESTNH-NEXT: (type $0 (func (param anyref))) - ;; YESTNH: (type $C1 (struct )) + ;; YESTNH: (type $C1 (sub (struct ))) ;; NO_TNH: (type $C1 (sub $B (struct ))) (type $C1 (struct_subtype $B)) @@ -986,10 +986,10 @@ ;; Function subtyping, which is a TODO - for now we do nothing. (module ;; YESTNH: (rec - ;; YESTNH-NEXT: (type $A (func)) + ;; YESTNH-NEXT: (type $A (sub (func))) ;; NO_TNH: (rec - ;; NO_TNH-NEXT: (type $A (func)) - (type $A (func)) + ;; NO_TNH-NEXT: (type $A (sub (func))) + (type $A (sub (func))) ;; YESTNH: (type $B (sub $A (func))) ;; NO_TNH: (type $B (sub $A (func))) @@ -1079,9 +1079,9 @@ ;; As above, but now the functions are also public types (exported). We should ;; be careful here in the future even when we do optimize function types. (module - ;; YESTNH: (type $A (func)) - ;; NO_TNH: (type $A (func)) - (type $A (func)) + ;; YESTNH: (type $A (sub (func))) + ;; NO_TNH: (type $A (sub (func))) + (type $A (sub (func))) ;; YESTNH: (rec ;; YESTNH-NEXT: (type $1 (func (param funcref))) @@ -1198,12 +1198,12 @@ ;; YESTNH: (rec ;; YESTNH-NEXT: (type $0 (func (param anyref))) - ;; YESTNH: (type $A (array (mut i32))) + ;; YESTNH: (type $A (sub (array (mut i32)))) ;; NO_TNH: (rec ;; NO_TNH-NEXT: (type $0 (func (param anyref))) - ;; NO_TNH: (type $A (array (mut i32))) - (type $A (array (mut i32))) + ;; NO_TNH: (type $A (sub (array (mut i32)))) + (type $A (sub (array (mut i32)))) ;; YESTNH: (type $B (sub $A (array (mut i32)))) ;; NO_TNH: (type $B (sub $A (array (mut i32)))) diff --git a/test/lit/passes/cfp.wast b/test/lit/passes/cfp.wast index d49c8b755..4236a16c6 100644 --- a/test/lit/passes/cfp.wast +++ b/test/lit/passes/cfp.wast @@ -549,8 +549,8 @@ (module ;; CHECK: (type $0 (func)) - ;; CHECK: (type $struct (struct (field i32))) - (type $struct (struct i32)) + ;; CHECK: (type $struct (sub (struct (field i32)))) + (type $struct (sub (struct i32))) ;; CHECK: (type $substruct (sub $struct (struct (field i32)))) (type $substruct (struct_subtype i32 $struct)) @@ -594,8 +594,8 @@ ;; will optimize the result to the only possible value. (In practice, though, ;; it will trap anyhow.) (module - ;; CHECK: (type $struct (struct (field (mut i32)))) - (type $struct (struct (mut i32))) + ;; CHECK: (type $struct (sub (struct (field (mut i32))))) + (type $struct (sub (struct (mut i32)))) ;; CHECK: (type $1 (func (param (ref null $struct)))) ;; CHECK: (type $substruct (sub $struct (struct (field (mut i32))))) @@ -652,8 +652,8 @@ (module ;; CHECK: (type $0 (func)) - ;; CHECK: (type $struct (struct (field i32))) - (type $struct (struct i32)) + ;; CHECK: (type $struct (sub (struct (field i32)))) + (type $struct (sub (struct i32))) ;; CHECK: (type $substruct (sub $struct (struct (field i32) (field f64)))) (type $substruct (struct_subtype i32 f64 $struct)) @@ -700,8 +700,8 @@ ;; 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 $struct (sub (struct (field i32)))) + (type $struct (sub (struct i32))) ;; CHECK: (type $1 (func)) ;; CHECK: (type $substruct (sub $struct (struct (field i32) (field f64)))) @@ -760,8 +760,8 @@ ;; for the shared field, preventing optimization, as a get of the ;; supertype may receive an instance of the subtype. (module - ;; CHECK: (type $struct (struct (field i32))) - (type $struct (struct i32)) + ;; CHECK: (type $struct (sub (struct (field i32)))) + (type $struct (sub (struct i32))) ;; CHECK: (type $1 (func)) ;; CHECK: (type $substruct (sub $struct (struct (field i32) (field f64)))) @@ -817,8 +817,8 @@ ;; one value, so we can optimize. (module - ;; CHECK: (type $struct (struct (field i32))) - (type $struct (struct i32)) + ;; CHECK: (type $struct (sub (struct (field i32)))) + (type $struct (sub (struct i32))) ;; CHECK: (type $substruct (sub $struct (struct (field i32) (field f64)))) (type $substruct (struct_subtype i32 f64 $struct)) @@ -876,8 +876,8 @@ ;; As above, but add a set of $struct. The set prevents the optimization. (module - ;; CHECK: (type $struct (struct (field (mut i32)))) - (type $struct (struct (mut i32))) + ;; CHECK: (type $struct (sub (struct (field (mut i32))))) + (type $struct (sub (struct (mut i32)))) ;; CHECK: (type $substruct (sub $struct (struct (field (mut i32)) (field f64)))) (type $substruct (struct_subtype (mut i32) f64 $struct)) @@ -939,8 +939,8 @@ ;; Multi-level subtyping, check that we propagate not just to the immediate ;; supertype but all the way as needed. (module - ;; CHECK: (type $struct1 (struct (field i32))) - (type $struct1 (struct i32)) + ;; CHECK: (type $struct1 (sub (struct (field i32)))) + (type $struct1 (sub (struct i32))) ;; CHECK: (type $struct2 (sub $struct1 (struct (field i32) (field f64)))) (type $struct2 (struct_subtype i32 f64 $struct1)) @@ -1074,8 +1074,8 @@ ;; different values in the sub-most type. Create the top and bottom types, but ;; not the middle one. (module - ;; CHECK: (type $struct1 (struct (field i32) (field i32))) - (type $struct1 (struct i32 i32)) + ;; CHECK: (type $struct1 (sub (struct (field i32) (field i32)))) + (type $struct1 (sub (struct i32 i32))) ;; CHECK: (type $struct2 (sub $struct1 (struct (field i32) (field i32) (field f64) (field f64)))) (type $struct2 (struct_subtype i32 i32 f64 f64 $struct1)) @@ -1304,8 +1304,8 @@ ;; Multi-level subtyping with a different value in the middle of the chain. We ;; can only optimize $struct3. (module - ;; CHECK: (type $struct1 (struct (field (mut i32)))) - (type $struct1 (struct (mut i32))) + ;; CHECK: (type $struct1 (sub (struct (field (mut i32))))) + (type $struct1 (sub (struct (mut i32)))) ;; CHECK: (type $struct2 (sub $struct1 (struct (field (mut i32)) (field f64)))) (type $struct2 (struct_subtype (mut i32) f64 $struct1)) ;; CHECK: (type $struct3 (sub $struct2 (struct (field (mut i32)) (field f64) (field anyref)))) @@ -1401,8 +1401,8 @@ ;; but also a set. That prevents all optimizations. (module - ;; CHECK: (type $struct1 (struct (field (mut i32)))) - (type $struct1 (struct (mut i32))) + ;; CHECK: (type $struct1 (sub (struct (field (mut i32))))) + (type $struct1 (sub (struct (mut i32)))) ;; CHECK: (type $struct2 (sub $struct1 (struct (field (mut i32)) (field f64)))) (type $struct2 (struct_subtype (mut i32) f64 $struct1)) @@ -1627,8 +1627,8 @@ ;; sets, and the final subtype C has a create and a get. The set to A should ;; apply to it, preventing optimization. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (mut i32))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (mut i32)))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (struct_subtype (mut i32) $A)) @@ -2226,8 +2226,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK-NEXT: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (struct_subtype (field (mut i32)) $A)) ) diff --git a/test/lit/passes/coalesce-locals-gc.wast b/test/lit/passes/coalesce-locals-gc.wast index fdd2b0e60..6e3381e8e 100644 --- a/test/lit/passes/coalesce-locals-gc.wast +++ b/test/lit/passes/coalesce-locals-gc.wast @@ -3,7 +3,7 @@ ;; RUN: | filecheck %s (module - ;; CHECK: (type $A (struct (field structref))) + ;; CHECK: (type $A (sub (struct (field structref)))) ;; CHECK: (type $array (array (mut i8))) (type $array (array (mut i8))) diff --git a/test/lit/passes/dae-gc-refine-params.wast b/test/lit/passes/dae-gc-refine-params.wast index cf3e75ebe..7a7a30954 100644 --- a/test/lit/passes/dae-gc-refine-params.wast +++ b/test/lit/passes/dae-gc-refine-params.wast @@ -2,8 +2,8 @@ ;; RUN: wasm-opt %s -all --dae -S -o - | filecheck %s (module - ;; CHECK: (type ${} (struct )) - (type ${} (struct)) + ;; CHECK: (type ${} (sub (struct ))) + (type ${} (sub (struct))) ;; CHECK: (type ${i32} (sub ${} (struct (field i32)))) (type ${i32} (struct_subtype (field i32) ${})) diff --git a/test/lit/passes/dae-gc-refine-return.wast b/test/lit/passes/dae-gc-refine-return.wast index bab22b2cb..a071cfc93 100644 --- a/test/lit/passes/dae-gc-refine-return.wast +++ b/test/lit/passes/dae-gc-refine-return.wast @@ -2,8 +2,8 @@ ;; RUN: wasm-opt %s -all --dae -S -o - | filecheck %s (module - ;; CHECK: (type ${} (struct )) - (type ${} (struct)) + ;; CHECK: (type ${} (sub (struct ))) + (type ${} (sub (struct))) ;; CHECK: (type $return_{} (func (result (ref ${})))) (type $return_{} (func (result (ref ${})))) diff --git a/test/lit/passes/dae_tnh.wast b/test/lit/passes/dae_tnh.wast index ea2d95433..a5b1f2f2a 100644 --- a/test/lit/passes/dae_tnh.wast +++ b/test/lit/passes/dae_tnh.wast @@ -5,7 +5,7 @@ (module ;; CHECK: (type $0 (func)) - ;; CHECK: (type $struct (struct (field i32))) + ;; CHECK: (type $struct (sub (struct (field i32)))) (type $struct (struct_subtype (field i32) data)) ;; CHECK: (type $2 (func (param (ref null $struct)))) diff --git a/test/lit/passes/gsi.wast b/test/lit/passes/gsi.wast index 559050f1f..00a2f6c60 100644 --- a/test/lit/passes/gsi.wast +++ b/test/lit/passes/gsi.wast @@ -667,7 +667,7 @@ ;; A subtype is not optimizable, which prevents $struct from being optimized. (module - ;; CHECK: (type $struct (struct (field i32))) + ;; CHECK: (type $struct (sub (struct (field i32)))) (type $struct (struct_subtype i32 data)) ;; CHECK: (type $1 (func (param (ref null $struct)))) @@ -718,7 +718,7 @@ ;; A *super*-type is not optimizable, but that does not block us, and we can ;; optimize. (module - ;; CHECK: (type $super-struct (struct (field i32))) + ;; CHECK: (type $super-struct (sub (struct (field i32)))) (type $super-struct (struct_subtype i32 data)) ;; CHECK: (type $struct (sub $super-struct (struct (field i32)))) @@ -776,7 +776,7 @@ ;; One global for each of the type and the subtype. The optimization will pick ;; between their 2 values. (module - ;; CHECK: (type $super-struct (struct (field i32))) + ;; CHECK: (type $super-struct (sub (struct (field i32)))) (type $super-struct (struct_subtype i32 data)) ;; CHECK: (type $struct (sub $super-struct (struct (field i32)))) @@ -887,7 +887,7 @@ ;; One global each for two subtypes of a common supertype, and one for the ;; supertype. (module - ;; CHECK: (type $super-struct (struct (field i32))) + ;; CHECK: (type $super-struct (sub (struct (field i32)))) (type $super-struct (struct_subtype i32 data)) ;; CHECK: (type $struct1 (sub $super-struct (struct (field i32) (field f32)))) @@ -980,7 +980,7 @@ ;; As above, but now the subtypes each have 2 values, and we can optimize. (module - ;; CHECK: (type $super-struct (struct (field i32))) + ;; CHECK: (type $super-struct (sub (struct (field i32)))) (type $super-struct (struct_subtype i32 data)) ;; CHECK: (type $struct1 (sub $super-struct (struct (field i32) (field f32)))) @@ -1228,7 +1228,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field i32))) + ;; CHECK-NEXT: (type $struct (sub (struct (field i32)))) (type $struct (struct_subtype i32 data)) ;; CHECK: (type $sub-struct1 (sub $struct (struct (field i32)))) @@ -1282,7 +1282,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field i32))) + ;; CHECK-NEXT: (type $struct (sub (struct (field i32)))) (type $struct (struct_subtype i32 data)) ;; CHECK: (type $sub-struct1 (sub $struct (struct (field i32)))) @@ -1339,7 +1339,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field i32))) + ;; CHECK-NEXT: (type $struct (sub (struct (field i32)))) (type $struct (struct_subtype i32 data)) ;; CHECK: (type $sub-struct1 (sub $struct (struct (field i32)))) @@ -1394,8 +1394,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field funcref))) - (type $A (struct (field funcref))) + ;; CHECK-NEXT: (type $A (sub (struct (field funcref)))) + (type $A (sub (struct (field funcref)))) ;; CHECK: (type $B (sub $A (struct (field (ref func))))) (type $B (sub $A (struct (field (ref func))))) ) diff --git a/test/lit/passes/gsi_vacuum_precompute.wast b/test/lit/passes/gsi_vacuum_precompute.wast index 8f4067446..1cbf47032 100644 --- a/test/lit/passes/gsi_vacuum_precompute.wast +++ b/test/lit/passes/gsi_vacuum_precompute.wast @@ -22,11 +22,11 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $vtable (struct (field funcref))) + ;; CHECK-NEXT: (type $vtable (sub (struct (field funcref)))) (type $vtable (struct_subtype (field funcref) data)) - ;; CHECK: (type $itable1 (struct (field (ref $vtable)))) + ;; CHECK: (type $itable1 (sub (struct (field (ref $vtable))))) (type $itable1 (struct_subtype (field (ref $vtable)) data)) - ;; CHECK: (type $itable2 (struct (field (ref $vtable)))) + ;; CHECK: (type $itable2 (sub (struct (field (ref $vtable))))) (type $itable2 (struct_subtype (field (ref $vtable)) data)) ) diff --git a/test/lit/passes/gto-mutability.wast b/test/lit/passes/gto-mutability.wast index 0ffa0e2d8..4be26c348 100644 --- a/test/lit/passes/gto-mutability.wast +++ b/test/lit/passes/gto-mutability.wast @@ -431,8 +431,8 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func (param (ref null $super) (ref null $sub)))) - ;; CHECK: (type $super (struct (field i32))) - (type $super (struct (field (mut i32)))) + ;; CHECK: (type $super (sub (struct (field i32)))) + (type $super (sub (struct (field (mut i32))))) ;; CHECK: (type $sub (sub $super (struct (field i32)))) (type $sub (struct_subtype (field (mut i32)) $super)) @@ -485,8 +485,8 @@ (module ;; As above, but add a write in the super, which prevents optimization. - ;; CHECK: (type $super (struct (field (mut i32)))) - (type $super (struct (field (mut i32)))) + ;; CHECK: (type $super (sub (struct (field (mut i32))))) + (type $super (sub (struct (field (mut i32))))) ;; CHECK: (type $sub (sub $super (struct (field (mut i32))))) (type $sub (struct_subtype (field (mut i32)) $super)) @@ -550,8 +550,8 @@ ;; As above, but add a write in the sub, which prevents optimization. - ;; CHECK: (type $super (struct (field (mut i32)))) - (type $super (struct (field (mut i32)))) + ;; CHECK: (type $super (sub (struct (field (mut i32))))) + (type $super (sub (struct (field (mut i32))))) ;; CHECK: (type $sub (sub $super (struct (field (mut i32))))) (type $sub (struct_subtype (field (mut i32)) $super)) diff --git a/test/lit/passes/gto-removals.wast b/test/lit/passes/gto-removals.wast index 43a81a5e2..34e29b71d 100644 --- a/test/lit/passes/gto-removals.wast +++ b/test/lit/passes/gto-removals.wast @@ -6,7 +6,7 @@ ;; removed. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct )) + ;; CHECK-NEXT: (type $struct (sub (struct ))) (type $struct (struct_subtype (field (mut funcref)) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -22,7 +22,7 @@ ;; A write does not keep a field from being removed. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct )) + ;; CHECK-NEXT: (type $struct (sub (struct ))) (type $struct (struct_subtype (field (mut funcref)) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -53,7 +53,7 @@ ;; A new does not keep a field from being removed. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct )) + ;; CHECK-NEXT: (type $struct (sub (struct ))) (type $struct (struct_subtype (field (mut funcref)) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -77,7 +77,7 @@ ;; A new_default does not keep a field from being removed. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct )) + ;; CHECK-NEXT: (type $struct (sub (struct ))) (type $struct (struct_subtype (field (mut funcref)) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -100,7 +100,7 @@ ;; A read *does* keep a field from being removed. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field funcref))) + ;; CHECK-NEXT: (type $struct (sub (struct (field funcref)))) (type $struct (struct_subtype (field (mut funcref)) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -128,11 +128,11 @@ ;; A struct with all fields marked mutable. ;; CHECK: (rec - ;; CHECK-NEXT: (type $imm-struct (struct (field $rw i32) (field $rw-2 i32))) + ;; CHECK-NEXT: (type $imm-struct (sub (struct (field $rw i32) (field $rw-2 i32)))) ;; CHECK: (type $1 (func (param (ref $imm-struct)))) - ;; CHECK: (type $mut-struct (struct (field $r i32) (field $rw (mut i32)) (field $r-2 i32) (field $rw-2 (mut i32)))) + ;; CHECK: (type $mut-struct (sub (struct (field $r i32) (field $rw (mut i32)) (field $r-2 i32) (field $rw-2 (mut i32))))) (type $mut-struct (struct_subtype (field $r (mut i32)) (field $w (mut i32)) (field $rw (mut i32)) (field $r-2 (mut i32)) (field $w-2 (mut i32)) (field $rw-2 (mut i32)) data)) ;; A similar struct but with all fields marked immutable, and the only @@ -283,7 +283,7 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func)) - ;; CHECK: (type $vtable (struct (field $v1 funcref) (field $v2 funcref))) + ;; CHECK: (type $vtable (sub (struct (field $v1 funcref) (field $v2 funcref)))) (type $vtable (struct_subtype (field $v0 funcref) (field $v1 funcref) (field $v2 funcref) (field $v3 funcref) (field $v4 funcref) data)) ;; CHECK: (global $vtable (ref $vtable) (struct.new $vtable @@ -358,7 +358,7 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func)) - ;; CHECK: (type $vtable (struct (field $v1 i64) (field $v2 f32))) + ;; CHECK: (type $vtable (sub (struct (field $v1 i64) (field $v2 f32)))) (type $vtable (struct_subtype (field $v0 i32) (field $v1 i64) (field $v2 f32) (field $v3 f64) (field $v4 anyref) data)) ;; CHECK: (global $vtable (ref $vtable) (struct.new $vtable @@ -635,7 +635,7 @@ ;; the subtypes can always add fields at the end (and only at the end). (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $parent (struct (field i32) (field i64))) + ;; CHECK-NEXT: (type $parent (sub (struct (field i32) (field i64)))) (type $parent (struct_subtype (field i32) (field i64) (field f32) (field f64) data)) ;; CHECK: (type $child (sub $parent (struct (field i32) (field i64) (field f32) (field f64) (field anyref)))) @@ -685,7 +685,7 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $parent (struct (field i32) (field i64) (field (mut f32)))) + ;; CHECK-NEXT: (type $parent (sub (struct (field i32) (field i64) (field (mut f32))))) (type $parent (struct_subtype (field (mut i32)) (field (mut i64)) (field (mut f32)) (field (mut f64)) data)) ;; CHECK: (type $child (sub $parent (struct (field i32) (field i64) (field (mut f32)) (field f64) (field anyref)))) @@ -743,7 +743,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $parent (struct (field i32))) + ;; CHECK-NEXT: (type $parent (sub (struct (field i32)))) (type $parent (struct_subtype (field i32) data)) ;; CHECK: (type $child1 (sub $parent (struct (field i32)))) (type $child1 (struct_subtype (field i32) $parent)) @@ -770,7 +770,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $parent (struct )) + ;; CHECK-NEXT: (type $parent (sub (struct ))) (type $parent (struct_subtype (field i32) data)) ;; CHECK: (type $child2 (sub $parent (struct ))) @@ -802,7 +802,7 @@ ;; CHECK: (type $2 (func)) - ;; CHECK: (type ${mut:i8} (struct )) + ;; CHECK: (type ${mut:i8} (sub (struct ))) (type ${mut:i8} (struct_subtype (field (mut i8)) data)) ;; CHECK: (type $4 (func (param (ref null ${mut:i8})))) diff --git a/test/lit/passes/gto_and_cfp_in_O.wast b/test/lit/passes/gto_and_cfp_in_O.wast index 0253e0791..ae0b11ee2 100644 --- a/test/lit/passes/gto_and_cfp_in_O.wast +++ b/test/lit/passes/gto_and_cfp_in_O.wast @@ -8,7 +8,7 @@ ;; open world we do not run them. (module - ;; OPEN_WORLD: (type $struct (struct (field (mut funcref)) (field (mut i32)))) + ;; OPEN_WORLD: (type $struct (sub (struct (field (mut funcref)) (field (mut i32))))) (type $struct (struct_subtype (field (mut funcref)) (field (mut i32)) data)) ;; OPEN_WORLD: (type $1 (func)) diff --git a/test/lit/passes/gufa-cast-all.wast b/test/lit/passes/gufa-cast-all.wast index 5ef52037f..21103089d 100644 --- a/test/lit/passes/gufa-cast-all.wast +++ b/test/lit/passes/gufa-cast-all.wast @@ -6,8 +6,8 @@ ;; CHECK: (type $none_=>_none (func)) (type $none_=>_none (func)) - ;; CHECK: (type $A (struct )) - (type $A (struct)) + ;; CHECK: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; CHECK: (type $B (sub $A (struct ))) (type $B (sub $A (struct))) diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index b300843cb..0e081637b 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -923,10 +923,10 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct )) + ;; CHECK-NEXT: (type $struct (sub (struct ))) (type $struct (struct_subtype data)) - ;; CHECK: (type $parent (struct (field (mut (ref null $struct))))) + ;; CHECK: (type $parent (sub (struct (field (mut (ref null $struct)))))) (type $parent (struct_subtype (field (mut (ref null $struct))) data)) ;; CHECK: (type $child (sub $parent (struct (field (mut (ref null $struct))) (field (mut (ref null $struct)))))) (type $child (struct_subtype (field (mut (ref null $struct))) (field (mut (ref null $struct))) $parent)) @@ -1201,9 +1201,9 @@ ;; Exact types: Writes to the parent class do not confuse us. (module - ;; CHECK: (type $struct (struct )) + ;; CHECK: (type $struct (sub (struct ))) (type $struct (struct_subtype data)) - ;; CHECK: (type $parent (struct (field (mut (ref null $struct))))) + ;; CHECK: (type $parent (sub (struct (field (mut (ref null $struct)))))) (type $parent (struct_subtype (field (mut (ref null $struct))) data)) ;; CHECK: (type $child (sub $parent (struct (field (mut (ref null $struct))) (field i32)))) (type $child (struct_subtype (field (mut (ref null $struct))) (field i32) $parent)) @@ -1285,7 +1285,7 @@ ;; Write values to the parent *and* the child and read from the child. (module - ;; CHECK: (type $parent (struct (field (mut i32)))) + ;; CHECK: (type $parent (sub (struct (field (mut i32))))) (type $parent (struct_subtype (field (mut i32)) data)) ;; CHECK: (type $child (sub $parent (struct (field (mut i32)) (field i32)))) (type $child (struct_subtype (field (mut i32)) (field i32) $parent)) @@ -1377,7 +1377,7 @@ ;; As above, but the $parent local can now contain a child too. (module - ;; CHECK: (type $parent (struct (field (mut i32)))) + ;; CHECK: (type $parent (sub (struct (field (mut i32))))) (type $parent (struct_subtype (field (mut i32)) data)) ;; CHECK: (type $child (sub $parent (struct (field (mut i32)) (field i32)))) (type $child (struct_subtype (field (mut i32)) (field i32) $parent)) @@ -1460,7 +1460,7 @@ ;; As above, but now the parent and child happen to agree on the aliased value. (module - ;; CHECK: (type $parent (struct (field (mut i32)))) + ;; CHECK: (type $parent (sub (struct (field (mut i32))))) (type $parent (struct_subtype (field (mut i32)) data)) ;; CHECK: (type $child (sub $parent (struct (field (mut i32)) (field i32)))) (type $child (struct_subtype (field (mut i32)) (field i32) $parent)) @@ -1538,13 +1538,13 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $nothing (array (mut anyref))) + ;; CHECK-NEXT: (type $nothing (sub (array (mut anyref)))) (type $nothing (array_subtype (mut (ref null any)) data)) - ;; CHECK: (type $null (array (mut anyref))) + ;; CHECK: (type $null (sub (array (mut anyref)))) (type $null (array_subtype (mut (ref null any)) data)) - ;; CHECK: (type $something (array (mut anyref))) + ;; CHECK: (type $something (sub (array (mut anyref)))) (type $something (array_subtype (mut (ref null any)) data)) ;; CHECK: (type $something-child (sub $something (array (mut anyref)))) @@ -2203,7 +2203,7 @@ ) (module - ;; CHECK: (type ${} (struct )) + ;; CHECK: (type ${} (sub (struct ))) (type ${} (struct_subtype data)) ;; CHECK: (type $1 (func (result (ref ${})))) @@ -2239,13 +2239,13 @@ (module ;; CHECK: (type $0 (func)) - ;; CHECK: (type $A (struct (field i32))) + ;; CHECK: (type $A (sub (struct (field i32)))) (type $A (struct_subtype (field i32) data)) - ;; CHECK: (type $B (struct (field i64))) + ;; CHECK: (type $B (sub (struct (field i64)))) (type $B (struct_subtype (field i64) data)) - ;; CHECK: (type $C (struct (field f32))) + ;; CHECK: (type $C (sub (struct (field f32)))) (type $C (struct_subtype (field f32) data)) - ;; CHECK: (type $D (struct (field f64))) + ;; CHECK: (type $D (sub (struct (field f64)))) (type $D (struct_subtype (field f64) data)) ;; CHECK: (func $many-types (type $0) @@ -2312,7 +2312,7 @@ ;; locations being properly noticed, both from global locations (the global's ;; init) and a function ($create). (module - ;; CHECK: (type $vtable-A (struct (field funcref) (field funcref) (field funcref))) + ;; CHECK: (type $vtable-A (sub (struct (field funcref) (field funcref) (field funcref)))) (type $vtable-A (struct_subtype (field (ref null func)) (field (ref null func)) (field (ref null func)) data)) ;; CHECK: (type $1 (func)) @@ -2395,7 +2395,7 @@ ) (module - ;; CHECK: (type $struct (struct (field i32))) + ;; CHECK: (type $struct (sub (struct (field i32)))) (type $struct (struct_subtype (field i32) data)) ;; CHECK: (type $1 (func)) @@ -2446,7 +2446,7 @@ ;; Casts. (module - ;; CHECK: (type $struct (struct (field i32))) + ;; CHECK: (type $struct (sub (struct (field i32)))) (type $struct (struct_subtype (field i32) data)) ;; CHECK: (type $substruct (sub $struct (struct (field i32) (field i32)))) (type $substruct (struct_subtype (field i32) (field i32) $struct)) @@ -2457,7 +2457,7 @@ ;; CHECK: (type $4 (func (param i32))) - ;; CHECK: (type $other (struct )) + ;; CHECK: (type $other (sub (struct ))) (type $other (struct_subtype data)) ;; CHECK: (type $6 (func (result i32))) @@ -3347,7 +3347,7 @@ ;; Test ref.eq on globals. (module - ;; CHECK: (type $A (struct (field i32))) + ;; CHECK: (type $A (sub (struct (field i32)))) (type $A (struct_subtype (field i32) data)) (type $B (struct_subtype (field i32) $A)) @@ -3511,11 +3511,11 @@ ) (module - ;; CHECK: (type $A (struct (field i32))) + ;; CHECK: (type $A (sub (struct (field i32)))) (type $A (struct_subtype (field i32) data)) - ;; CHECK: (type $B (struct (field (ref $A)))) + ;; CHECK: (type $B (sub (struct (field (ref $A))))) (type $B (struct_subtype (ref $A) data)) - ;; CHECK: (type $C (struct (field (ref $B)))) + ;; CHECK: (type $C (sub (struct (field (ref $B))))) (type $C (struct_subtype (ref $B) data)) ;; CHECK: (type $3 (func (result i32))) @@ -3564,7 +3564,7 @@ ;; ref.as* test. (module - ;; CHECK: (type $A (struct (field i32))) + ;; CHECK: (type $A (sub (struct (field i32)))) (type $A (struct_subtype (field i32) data)) ;; CHECK: (type $B (sub $A (struct (field i32) (field f64)))) (type $B (struct_subtype (field i32) (field f64) $A)) @@ -3610,7 +3610,7 @@ ) (module - ;; CHECK: (type $A (struct (field i32))) + ;; CHECK: (type $A (sub (struct (field i32)))) (type $A (struct_subtype (field i32) data)) ;; CHECK: (type $1 (func (result i32))) @@ -4223,7 +4223,7 @@ ) (module - ;; CHECK: (type $struct (struct (field (mut i32)))) + ;; CHECK: (type $struct (sub (struct (field (mut i32))))) (type $struct (struct_subtype (mut i32) data)) ;; CHECK: (type $substruct (sub $struct (struct (field (mut i32)) (field f64)))) @@ -4299,7 +4299,7 @@ ;; As above, but we can no longer infer an exact type for the struct.set on the ;; global $something. (module - ;; CHECK: (type $struct (struct (field (mut i32)))) + ;; CHECK: (type $struct (sub (struct (field (mut i32))))) (type $struct (struct_subtype (mut i32) data)) ;; CHECK: (type $substruct (sub $struct (struct (field (mut i32)) (field f64)))) @@ -4377,7 +4377,7 @@ ;; As above, but change the constants in the first field in all cases to 10. Now ;; we can optimize. (module - ;; CHECK: (type $struct (struct (field (mut i32)))) + ;; CHECK: (type $struct (sub (struct (field (mut i32))))) (type $struct (struct_subtype (mut i32) data)) ;; CHECK: (type $substruct (sub $struct (struct (field (mut i32)) (field f64)))) @@ -4585,7 +4585,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field (mut i32)))) + ;; CHECK-NEXT: (type $A (sub (struct (field (mut i32))))) (type $A (struct_subtype (field (mut i32)) data)) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (struct_subtype (field (mut i32)) $A)) @@ -4693,7 +4693,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field (mut i32)))) + ;; CHECK-NEXT: (type $A (sub (struct (field (mut i32))))) (type $A (struct_subtype (field (mut i32)) data)) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (struct_subtype (field (mut i32)) $A)) @@ -4801,7 +4801,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field (mut i32)))) + ;; CHECK-NEXT: (type $A (sub (struct (field (mut i32))))) (type $A (struct_subtype (field (mut i32)) data)) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (struct_subtype (field (mut i32)) $A)) @@ -4915,7 +4915,7 @@ ;; Cone writes. (module - ;; CHECK: (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) (type $A (struct_subtype (field (mut i32)) data)) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (struct_subtype (field (mut i32)) $A)) @@ -5013,7 +5013,7 @@ ;; As above, but write a different value. (module - ;; CHECK: (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) (type $A (struct_subtype (field (mut i32)) data)) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (struct_subtype (field (mut i32)) $A)) @@ -5112,7 +5112,7 @@ ;; As above, but write a different cone. (module - ;; CHECK: (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) (type $A (struct_subtype (field (mut i32)) data)) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (struct_subtype (field (mut i32)) $A)) @@ -5212,7 +5212,7 @@ ;; Tests for proper inference of imported etc. values - we do know their type, ;; at least. (module - ;; CHECK: (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) (type $A (struct_subtype (field (mut i32)) data)) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) @@ -5646,8 +5646,8 @@ ) (module - ;; CHECK: (type $A (struct )) - (type $A (struct)) + ;; CHECK: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; CHECK: (type $B (sub $A (struct ))) (type $B (sub $A (struct))) @@ -5683,8 +5683,8 @@ ;; A situation that we need traps-never-happens to optimize. Here we do nothing, ;; while in gufa-tnh we test with that flag. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $1 (func (param (ref null $A)))) diff --git a/test/lit/passes/gufa-tnh-closed.wast b/test/lit/passes/gufa-tnh-closed.wast index 44d16c99b..790663af4 100644 --- a/test/lit/passes/gufa-tnh-closed.wast +++ b/test/lit/passes/gufa-tnh-closed.wast @@ -231,8 +231,8 @@ ;; As above, but now the second possible function is of a subtype. We still ;; cannot optimize a call to the parent, but we can for the child. (module - ;; CHECK: (type $A (func)) - (type $A (func)) + ;; CHECK: (type $A (sub (func))) + (type $A (sub (func))) ;; CHECK: (type $B (sub $A (func))) (type $B (sub $A (func))) @@ -296,8 +296,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct )) - (type $X (struct)) + ;; CHECK-NEXT: (type $X (sub (struct ))) + (type $X (sub (struct))) ;; CHECK: (type $Y1 (sub $X (struct ))) (type $Y1 (sub $X (struct))) @@ -421,8 +421,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct )) - (type $X (struct)) + ;; CHECK-NEXT: (type $X (sub (struct ))) + (type $X (sub (struct))) ;; CHECK: (type $Y1 (sub $X (struct ))) (type $Y1 (sub $X (struct))) @@ -659,8 +659,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct )) - (type $X (struct)) + ;; CHECK-NEXT: (type $X (sub (struct ))) + (type $X (sub (struct))) ;; CHECK: (type $Y1 (sub $X (struct ))) (type $Y1 (sub $X (struct))) @@ -885,8 +885,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct )) - (type $X (struct)) + ;; CHECK-NEXT: (type $X (sub (struct ))) + (type $X (sub (struct))) ;; CHECK: (type $Y1 (sub $X (struct ))) (type $Y1 (sub $X (struct))) @@ -1041,8 +1041,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct )) - (type $X (struct)) + ;; CHECK-NEXT: (type $X (sub (struct ))) + (type $X (sub (struct))) ;; CHECK: (type $Y1 (sub $X (struct ))) (type $Y1 (sub $X (struct))) diff --git a/test/lit/passes/gufa-tnh.wast b/test/lit/passes/gufa-tnh.wast index e41a3f49c..fb9348365 100644 --- a/test/lit/passes/gufa-tnh.wast +++ b/test/lit/passes/gufa-tnh.wast @@ -157,8 +157,8 @@ ) (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -286,8 +286,8 @@ ;; A local.tee by itself, without a cast. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -372,8 +372,8 @@ ;; As above, but add a local.tee etc. in the called function. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -449,8 +449,8 @@ ;; As above, but now add some control flow before the cast in the function. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $1 (func (param (ref null $A)))) @@ -511,8 +511,8 @@ ;; As above, but make the cast uninteresting so we do not optimize. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -564,8 +564,8 @@ ;; As above, but two casts in the called function. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -631,8 +631,8 @@ ;; Multiple parameters with control flow between them. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -734,8 +734,8 @@ ;; As above, but without the cast in the middle of the called function. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -831,8 +831,8 @@ ;; As above, but with a different control flow transfer in the caller, a call. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -916,8 +916,8 @@ ;; As above, but with yet another control flow transfer, using an if. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -1011,8 +1011,8 @@ ;; A cast that will fail. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -1111,8 +1111,8 @@ ;; Verify we do not propagate *less*-refined information. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -1322,8 +1322,8 @@ ;; Refine a type to unreachable. B1 and B2 are sibling subtypes of A, and the ;; caller passes in a B1 that is cast in the function to B2. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) (rec ;; CHECK: (type $1 (func (param (ref null $A)))) @@ -1408,8 +1408,8 @@ (module ;; CHECK: (type $0 (func)) - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -1442,8 +1442,8 @@ ;; Check all combinations of types passed to a nullable cast. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -1545,8 +1545,8 @@ ;; Check all combinations of types passed to a *non*-nullable cast. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (field (mut i32)))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (field (mut i32))))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (sub $A (struct (field (mut i32))))) @@ -1960,8 +1960,8 @@ (module ;; CHECK: (type $0 (func)) - ;; CHECK: (type $A (struct )) - (type $A (struct)) + ;; CHECK: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; CHECK: (type $B (sub $A (struct ))) (type $B (sub $A (struct))) diff --git a/test/lit/passes/gufa-vs-cfp.wast b/test/lit/passes/gufa-vs-cfp.wast index 2589290c6..3ed490628 100644 --- a/test/lit/passes/gufa-vs-cfp.wast +++ b/test/lit/passes/gufa-vs-cfp.wast @@ -496,8 +496,8 @@ ;; subtype, the get must trap anyhow (the reference it receives can ;; only be null in this closed world). (module - ;; CHECK: (type $struct (struct (field i32))) - (type $struct (struct i32)) + ;; CHECK: (type $struct (sub (struct (field i32)))) + (type $struct (sub (struct i32))) (type $substruct (struct_subtype i32 $struct)) ;; CHECK: (type $1 (func (result (ref $struct)))) @@ -543,8 +543,8 @@ ;; however, cannot write to the subtype, so we still know that any reads from ;; the subtype must trap. (module - ;; CHECK: (type $struct (struct (field (mut i32)))) - (type $struct (struct (mut i32))) + ;; CHECK: (type $struct (sub (struct (field (mut i32))))) + (type $struct (sub (struct (mut i32)))) (type $substruct (struct_subtype (mut i32) $struct)) ;; CHECK: (type $1 (func)) @@ -602,8 +602,8 @@ ;; to a read of the subtype. Still, no actual instance of the subtype can ;; appear in the get, so we can optimize to an unreachable. (module - ;; CHECK: (type $struct (struct (field (mut i32)))) - (type $struct (struct (mut i32))) + ;; CHECK: (type $struct (sub (struct (field (mut i32))))) + (type $struct (sub (struct (mut i32)))) (type $substruct (struct_subtype (mut i32) $struct)) ;; CHECK: (type $1 (func)) @@ -655,7 +655,7 @@ ;; Subtyping: Create a subtype and get a supertype. The get must receive a ;; reference to the subtype and so we can infer the value of the get. (module - (type $struct (struct i32)) + (type $struct (sub (struct i32))) (type $substruct (struct_subtype i32 f64 $struct)) @@ -681,8 +681,8 @@ ;; 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 $struct (sub (struct (field i32)))) + (type $struct (sub (struct i32))) ;; CHECK: (type $1 (func (result i32))) ;; CHECK: (type $2 (func)) @@ -735,8 +735,8 @@ ;; for the shared field, preventing optimization, as a get of the ;; supertype may receive an instance of the subtype. (module - ;; CHECK: (type $struct (struct (field i32))) - (type $struct (struct i32)) + ;; CHECK: (type $struct (sub (struct (field i32)))) + (type $struct (sub (struct i32))) ;; CHECK: (type $1 (func (result i32))) ;; CHECK: (type $2 (func)) @@ -786,8 +786,8 @@ ;; shared between the types, but we only create the subtype with ;; one value, so we can optimize. (module - ;; CHECK: (type $struct (struct (field i32))) - (type $struct (struct i32)) + ;; CHECK: (type $struct (sub (struct (field i32)))) + (type $struct (sub (struct i32))) ;; CHECK: (type $substruct (sub $struct (struct (field i32) (field f64)))) (type $substruct (struct_subtype i32 f64 $struct)) @@ -843,8 +843,8 @@ ;; As above, but add a set of $struct. The set prevents the optimization. (module - ;; CHECK: (type $struct (struct (field (mut i32)))) - (type $struct (struct (mut i32))) + ;; CHECK: (type $struct (sub (struct (field (mut i32))))) + (type $struct (sub (struct (mut i32)))) ;; CHECK: (type $substruct (sub $struct (struct (field (mut i32)) (field f64)))) (type $substruct (struct_subtype (mut i32) f64 $struct)) @@ -917,8 +917,8 @@ ;; As above, but now the constant in the set agrees with the substruct value, ;; so we can optimize. (module - ;; CHECK: (type $struct (struct (field (mut i32)))) - (type $struct (struct (mut i32))) + ;; CHECK: (type $struct (sub (struct (field (mut i32))))) + (type $struct (sub (struct (mut i32)))) ;; CHECK: (type $substruct (sub $struct (struct (field (mut i32)) (field f64)))) (type $substruct (struct_subtype (mut i32) f64 $struct)) @@ -996,7 +996,7 @@ ;; Multi-level subtyping, check that we propagate not just to the immediate ;; supertype but all the way as needed. (module - ;; CHECK: (type $struct1 (struct (field i32))) + ;; CHECK: (type $struct1 (sub (struct (field i32)))) (type $struct1 (struct_subtype i32 data)) ;; CHECK: (type $struct2 (sub $struct1 (struct (field i32) (field f64)))) @@ -1137,8 +1137,8 @@ ;; different values in the sub-most type. Create the top and bottom types, but ;; not the middle one. (module - ;; CHECK: (type $struct1 (struct (field i32) (field i32))) - (type $struct1 (struct i32 i32)) + ;; CHECK: (type $struct1 (sub (struct (field i32) (field i32)))) + (type $struct1 (sub (struct i32 i32))) ;; CHECK: (type $struct2 (sub $struct1 (struct (field i32) (field i32) (field f64) (field f64)))) (type $struct2 (struct_subtype i32 i32 f64 f64 $struct1)) @@ -1371,8 +1371,8 @@ ;; Multi-level subtyping with a different value in the middle of the chain. (module - ;; CHECK: (type $struct1 (struct (field (mut i32)))) - (type $struct1 (struct (mut i32))) + ;; CHECK: (type $struct1 (sub (struct (field (mut i32))))) + (type $struct1 (sub (struct (mut i32)))) ;; CHECK: (type $struct2 (sub $struct1 (struct (field (mut i32)) (field f64)))) (type $struct2 (struct_subtype (mut i32) f64 $struct1)) ;; CHECK: (type $2 (func)) @@ -1676,8 +1676,8 @@ ;; but also a set. We can see that the set just affects the middle class, ;; though, so it is not a problem. (module - ;; CHECK: (type $struct1 (struct (field (mut i32)))) - (type $struct1 (struct (mut i32))) + ;; CHECK: (type $struct1 (sub (struct (field (mut i32))))) + (type $struct1 (sub (struct (mut i32)))) ;; CHECK: (type $struct2 (sub $struct1 (struct (field (mut i32)) (field f64)))) (type $struct2 (struct_subtype (mut i32) f64 $struct1)) ;; CHECK: (type $struct3 (sub $struct2 (struct (field (mut i32)) (field f64) (field anyref)))) @@ -1792,8 +1792,8 @@ ;; As above, but the set is of a different value. (module - ;; CHECK: (type $struct1 (struct (field (mut i32)))) - (type $struct1 (struct (mut i32))) + ;; CHECK: (type $struct1 (sub (struct (field (mut i32))))) + (type $struct1 (sub (struct (mut i32)))) ;; CHECK: (type $struct2 (sub $struct1 (struct (field (mut i32)) (field f64)))) (type $struct2 (struct_subtype (mut i32) f64 $struct1)) ;; CHECK: (type $struct3 (sub $struct2 (struct (field (mut i32)) (field f64) (field anyref)))) @@ -2019,8 +2019,8 @@ ;; sets, and the final subtype C has a create and a get. The set to A should ;; apply to it, preventing optimization. (module - ;; CHECK: (type $A (struct (field (mut i32)))) - (type $A (struct (mut i32))) + ;; CHECK: (type $A (sub (struct (field (mut i32))))) + (type $A (sub (struct (mut i32)))) ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) (type $B (struct_subtype (mut i32) $A)) diff --git a/test/lit/passes/heap2local.wast b/test/lit/passes/heap2local.wast index ec5eaa3c6..6fa0e2a1f 100644 --- a/test/lit/passes/heap2local.wast +++ b/test/lit/passes/heap2local.wast @@ -1898,8 +1898,8 @@ ) (module - ;; CHECK: (type $A (struct (field (ref null $A)))) - (type $A (struct (field (ref null $A)))) + ;; CHECK: (type $A (sub (struct (field (ref null $A))))) + (type $A (sub (struct (field (ref null $A))))) ;; CHECK: (type $B (sub $A (struct (field (ref $A))))) (type $B (sub $A (struct (field (ref $A))))) diff --git a/test/lit/passes/inlining_vacuum_optimize-instructions.wast b/test/lit/passes/inlining_vacuum_optimize-instructions.wast index 0e153d57c..948fe467f 100644 --- a/test/lit/passes/inlining_vacuum_optimize-instructions.wast +++ b/test/lit/passes/inlining_vacuum_optimize-instructions.wast @@ -11,9 +11,9 @@ ;; which is temporarily inconsistent. We must be careful to avoid confusion ;; there. (module - ;; CHECK: (type $B (struct )) + ;; CHECK: (type $B (sub (struct ))) (type $B (struct_subtype data)) - ;; CHECK: (type $A (struct (field (ref null $B)))) + ;; CHECK: (type $A (sub (struct (field (ref null $B))))) (type $A (struct_subtype (field (ref null $B)) data)) ;; CHECK: (type $2 (func (param (ref null $A)))) diff --git a/test/lit/passes/local-subtyping.wast b/test/lit/passes/local-subtyping.wast index c5f3f408a..c86f4d645 100644 --- a/test/lit/passes/local-subtyping.wast +++ b/test/lit/passes/local-subtyping.wast @@ -14,7 +14,7 @@ (type $array (array_subtype i8 data)) - ;; CHECK: (type $ret-any (func (result anyref))) + ;; CHECK: (type $ret-any (sub (func (result anyref)))) (type $ret-any (sub (func (result anyref)))) ;; CHECK: (type $ret-i31 (sub $ret-any (func (result i31ref)))) (type $ret-i31 (sub $ret-any (func (result i31ref)))) diff --git a/test/lit/passes/merge-similar-functions_types.wast b/test/lit/passes/merge-similar-functions_types.wast index aa02abf2e..5c4364a14 100644 --- a/test/lit/passes/merge-similar-functions_types.wast +++ b/test/lit/passes/merge-similar-functions_types.wast @@ -6,7 +6,7 @@ ;; of $0 and $1, so we want to merge them and pass ref.funcs of $2 and $3. ;; However, their nominal types differ, so in nominal typing we cannot do so. (module - ;; CHECK: (type $type$0 (func)) + ;; CHECK: (type $type$0 (sub (func))) (type $type$0 (func_subtype func)) (type $type$1 (func_subtype func)) (type $type$2 (func_subtype func)) @@ -110,7 +110,7 @@ (module ;; As above, but now the nominal types do match, so we can optimize in all ;; modes. - ;; CHECK: (type $type$0 (func)) + ;; CHECK: (type $type$0 (sub (func))) (type $type$0 (func_subtype func)) (type $type$1 (func_subtype func)) (type $type$3 (func_subtype (param f32) (result f32) func)) diff --git a/test/lit/passes/monomorphize.wast b/test/lit/passes/monomorphize.wast index fc3388d89..858cb4bf5 100644 --- a/test/lit/passes/monomorphize.wast +++ b/test/lit/passes/monomorphize.wast @@ -7,8 +7,8 @@ ;; RUN: foreach %s %t wasm-opt --monomorphize -all -S -o - | filecheck %s --check-prefix CAREFUL (module - ;; ALWAYS: (type $A (struct )) - ;; CAREFUL: (type $A (struct )) + ;; ALWAYS: (type $A (sub (struct ))) + ;; CAREFUL: (type $A (sub (struct ))) (type $A (struct_subtype data)) ;; ALWAYS: (type $B (sub $A (struct ))) ;; CAREFUL: (type $B (sub $A (struct ))) @@ -124,10 +124,10 @@ ;; As above, but now the refinable function uses the local in a way that ;; requires a fixup. - ;; ALWAYS: (type $A (struct )) + ;; ALWAYS: (type $A (sub (struct ))) ;; CAREFUL: (type $0 (func)) - ;; CAREFUL: (type $A (struct )) + ;; CAREFUL: (type $A (sub (struct ))) (type $A (struct_subtype data)) ;; ALWAYS: (type $B (sub $A (struct ))) ;; CAREFUL: (type $B (sub $A (struct ))) @@ -204,10 +204,10 @@ (module ;; Multiple refinings of the same function, and of different functions. - ;; ALWAYS: (type $A (struct )) + ;; ALWAYS: (type $A (sub (struct ))) ;; CAREFUL: (type $0 (func)) - ;; CAREFUL: (type $A (struct )) + ;; CAREFUL: (type $A (sub (struct ))) (type $A (struct_subtype data)) ;; ALWAYS: (type $B (sub $A (struct ))) ;; CAREFUL: (type $B (sub $A (struct ))) @@ -327,8 +327,8 @@ ;; A case where even CAREFUL mode will monomorphize, as it helps the target ;; function get optimized better. - ;; ALWAYS: (type $A (struct )) - ;; CAREFUL: (type $A (struct )) + ;; ALWAYS: (type $A (sub (struct ))) + ;; CAREFUL: (type $A (sub (struct ))) (type $A (struct_subtype data)) ;; ALWAYS: (type $B (sub $A (struct ))) @@ -558,8 +558,8 @@ (module ;; Test that we avoid recursive calls. - ;; ALWAYS: (type $A (struct )) - ;; CAREFUL: (type $A (struct )) + ;; ALWAYS: (type $A (sub (struct ))) + ;; CAREFUL: (type $A (sub (struct ))) (type $A (struct_subtype data)) ;; ALWAYS: (type $1 (func (param (ref $A)))) diff --git a/test/lit/passes/optimize-casts-tnh.wast b/test/lit/passes/optimize-casts-tnh.wast index 02720995e..d5f83f024 100644 --- a/test/lit/passes/optimize-casts-tnh.wast +++ b/test/lit/passes/optimize-casts-tnh.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --optimize-casts -all -tnh -S -o - | filecheck %s (module - ;; CHECK: (type $A (struct )) + ;; CHECK: (type $A (sub (struct ))) (type $A (struct_subtype data)) ;; CHECK: (global $a (mut i32) (i32.const 0)) diff --git a/test/lit/passes/optimize-casts.wast b/test/lit/passes/optimize-casts.wast index 4c9e38df6..2854df3bb 100644 --- a/test/lit/passes/optimize-casts.wast +++ b/test/lit/passes/optimize-casts.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --optimize-casts -all -S -o - | filecheck %s (module - ;; CHECK: (type $A (struct )) + ;; CHECK: (type $A (sub (struct ))) (type $A (struct_subtype data)) ;; CHECK: (type $B (sub $A (struct ))) diff --git a/test/lit/passes/optimize-instructions-gc-iit.wast b/test/lit/passes/optimize-instructions-gc-iit.wast index 02a9c6f29..cc5e8aec9 100644 --- a/test/lit/passes/optimize-instructions-gc-iit.wast +++ b/test/lit/passes/optimize-instructions-gc-iit.wast @@ -8,9 +8,9 @@ ;; RUN: | filecheck %s --check-prefix TNH (module - ;; CHECK: (type $parent (struct (field i32))) - ;; TNH: (type $parent (struct (field i32))) - (type $parent (struct (field i32))) + ;; CHECK: (type $parent (sub (struct (field i32)))) + ;; TNH: (type $parent (sub (struct (field i32)))) + (type $parent (sub (struct (field i32)))) ;; CHECK: (type $child (sub $parent (struct (field i32) (field f64)))) ;; TNH: (type $child (sub $parent (struct (field i32) (field f64)))) (type $child (struct_subtype (field i32) (field f64) $parent)) @@ -200,9 +200,9 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct )) + ;; CHECK-NEXT: (type $A (sub (struct ))) ;; TNH: (rec - ;; TNH-NEXT: (type $A (struct )) + ;; TNH-NEXT: (type $A (sub (struct ))) (type $A (struct_subtype data)) ;; CHECK: (type $B (sub $A (struct (field (ref null $A))))) ;; TNH: (type $B (sub $A (struct (field (ref null $A))))) diff --git a/test/lit/passes/optimize-instructions-gc-tnh.wast b/test/lit/passes/optimize-instructions-gc-tnh.wast index 28177f306..9d55ef801 100644 --- a/test/lit/passes/optimize-instructions-gc-tnh.wast +++ b/test/lit/passes/optimize-instructions-gc-tnh.wast @@ -3,8 +3,8 @@ ;; RUN: wasm-opt %s --optimize-instructions -all -S -o - | filecheck %s --check-prefix NO_TNH (module - ;; TNH: (type $struct (struct (field (mut i32)))) - ;; NO_TNH: (type $struct (struct (field (mut i32)))) + ;; TNH: (type $struct (sub (struct (field (mut i32))))) + ;; NO_TNH: (type $struct (sub (struct (field (mut i32))))) (type $struct (struct_subtype (field (mut i32)) data)) ;; TNH: (type $void (func)) diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast index 86306a27a..e62b64125 100644 --- a/test/lit/passes/optimize-instructions-gc.wast +++ b/test/lit/passes/optimize-instructions-gc.wast @@ -12,8 +12,8 @@ (field $i64 (mut i64)) )) - ;; CHECK: (type $A (struct (field i32))) - (type $A (struct (field i32))) + ;; CHECK: (type $A (sub (struct (field i32)))) + (type $A (sub (struct (field i32)))) ;; CHECK: (type $B (sub $A (struct (field i32) (field i32) (field f32)))) @@ -22,19 +22,19 @@ (type $B (struct_subtype (field i32) (field i32) (field f32) $A)) - ;; CHECK: (type $void (func)) - ;; CHECK: (type $B-child (sub $B (struct (field i32) (field i32) (field f32) (field i64)))) (type $B-child (struct_subtype (field i32) (field i32) (field f32) (field i64) $B)) (type $empty (struct)) + ;; CHECK: (type $void (sub (func))) + ;; CHECK: (type $void2 (sub $void (func))) ;; CHECK: (type $C (sub $A (struct (field i32) (field i32) (field f64)))) (type $C (struct_subtype (field i32) (field i32) (field f64) $A)) - (type $void (func)) + (type $void (sub (func))) (type $void2 (func_subtype $void)) @@ -46,7 +46,7 @@ ;; These functions test if an `if` with subtyped arms is correctly folded ;; 1. if its `ifTrue` and `ifFalse` arms are identical (can fold) - ;; CHECK: (func $if-arms-subtype-fold (type $25) (result anyref) + ;; CHECK: (func $if-arms-subtype-fold (type $26) (result anyref) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) (func $if-arms-subtype-fold (result anyref) @@ -57,7 +57,7 @@ ) ) ;; 2. if its `ifTrue` and `ifFalse` arms are not identical (cannot fold) - ;; CHECK: (func $if-arms-subtype-nofold (type $26) (param $i31ref i31ref) (result anyref) + ;; CHECK: (func $if-arms-subtype-nofold (type $27) (param $i31ref i31ref) (result anyref) ;; CHECK-NEXT: (if (result anyref) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (ref.null none) @@ -106,7 +106,7 @@ ) ;; Similar, but for arrays. - ;; CHECK: (func $store-trunc2 (type $14) (param $x (ref null $array)) + ;; CHECK: (func $store-trunc2 (type $15) (param $x (ref null $array)) ;; CHECK-NEXT: (array.set $array ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: (i32.const 0) @@ -123,7 +123,7 @@ ;; ref.is_null is not needed on a non-nullable value, and if something is ;; cast to its own type, we don't need that either, etc. - ;; CHECK: (func $unneeded_test (type $15) (param $struct (ref $struct)) (param $func (ref func)) (param $i31 (ref i31)) + ;; CHECK: (func $unneeded_test (type $16) (param $struct (ref $struct)) (param $func (ref func)) (param $i31 (ref i31)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop @@ -166,7 +166,7 @@ ;; similar to $unneeded_is, but the values are nullable. we can at least ;; leave just the null check. - ;; CHECK: (func $unneeded_test_null (type $16) (param $struct (ref null $struct)) (param $func funcref) (param $i31 i31ref) + ;; CHECK: (func $unneeded_test_null (type $17) (param $struct (ref null $struct)) (param $func funcref) (param $i31 i31ref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.is_null ;; CHECK-NEXT: (local.get $struct) @@ -207,7 +207,7 @@ ;; ref.as_non_null is not needed on a non-nullable value, and if something is ;; a func we don't need that either etc., and can just return the value. - ;; CHECK: (func $unneeded_cast (type $15) (param $struct (ref $struct)) (param $func (ref func)) (param $i31 (ref i31)) + ;; CHECK: (func $unneeded_cast (type $16) (param $struct (ref $struct)) (param $func (ref func)) (param $i31 (ref i31)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $struct) ;; CHECK-NEXT: ) @@ -235,7 +235,7 @@ ;; similar to $unneeded_cast, but the values are nullable. we can turn the ;; more specific things into ref.as_non_null. - ;; CHECK: (func $unneeded_cast_null (type $16) (param $struct (ref null $struct)) (param $func funcref) (param $i31 i31ref) + ;; CHECK: (func $unneeded_cast_null (type $17) (param $struct (ref null $struct)) (param $func funcref) (param $i31 i31ref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (local.get $struct) @@ -267,7 +267,7 @@ ) ) - ;; CHECK: (func $unneeded_unreachability (type $void) + ;; CHECK: (func $unneeded_unreachability (type $5) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.test (ref func) ;; CHECK-NEXT: (unreachable) @@ -292,7 +292,7 @@ ) ) - ;; CHECK: (func $redundant-non-null-casts (type $27) (param $x (ref null $struct)) (param $y (ref null $array)) (param $f (ref null $void)) + ;; CHECK: (func $redundant-non-null-casts (type $28) (param $x (ref null $struct)) (param $y (ref null $array)) (param $f (ref null $void)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (local.get $x) @@ -379,7 +379,7 @@ ) ) - ;; CHECK: (func $get-eqref (type $28) (result eqref) + ;; CHECK: (func $get-eqref (type $29) (result eqref) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) (func $get-eqref (result eqref) @@ -455,7 +455,7 @@ ) ) - ;; CHECK: (func $nothing (type $void) + ;; CHECK: (func $nothing (type $5) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $nothing) @@ -570,7 +570,7 @@ ) ) - ;; CHECK: (func $flip-cast-of-as-non-null (type $17) (param $x anyref) + ;; CHECK: (func $flip-cast-of-as-non-null (type $18) (param $x anyref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.cast (ref $struct) ;; CHECK-NEXT: (local.get $x) @@ -623,7 +623,7 @@ ) ) ) - ;; CHECK: (func $flip-tee-of-as-non-null (type $17) (param $x anyref) + ;; CHECK: (func $flip-tee-of-as-non-null (type $18) (param $x anyref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (local.tee $x @@ -643,7 +643,7 @@ ) ) - ;; CHECK: (func $flip-tee-of-as-non-null-non-nullable (type $29) (param $x (ref any)) (param $y anyref) + ;; CHECK: (func $flip-tee-of-as-non-null-non-nullable (type $30) (param $x (ref any)) (param $y anyref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $x ;; CHECK-NEXT: (ref.as_non_null @@ -664,7 +664,7 @@ ) ) ) - ;; CHECK: (func $ternary-identical-arms (type $30) (param $x i32) (param $y (ref null $struct)) (param $z (ref null $struct)) + ;; CHECK: (func $ternary-identical-arms (type $31) (param $x i32) (param $y (ref null $struct)) (param $z (ref null $struct)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.is_null ;; CHECK-NEXT: (if (result (ref null $struct)) @@ -684,7 +684,7 @@ ) ) ) - ;; CHECK: (func $select-identical-arms-but-side-effect (type $18) (param $x (ref null $struct)) (param $y (ref null $struct)) (param $z i32) + ;; CHECK: (func $select-identical-arms-but-side-effect (type $19) (param $x (ref null $struct)) (param $y (ref null $struct)) (param $z i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (select ;; CHECK-NEXT: (struct.get_u $struct $i8 @@ -711,7 +711,7 @@ ) ) ) - ;; CHECK: (func $ternary-identical-arms-no-side-effect (type $31) (param $x (ref $struct)) (param $y (ref $struct)) (param $z i32) + ;; CHECK: (func $ternary-identical-arms-no-side-effect (type $32) (param $x (ref $struct)) (param $y (ref $struct)) (param $z i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get_u $struct $i8 ;; CHECK-NEXT: (select (result (ref $struct)) @@ -736,7 +736,7 @@ ) ) ) - ;; CHECK: (func $if-identical-arms-with-side-effect (type $18) (param $x (ref null $struct)) (param $y (ref null $struct)) (param $z i32) + ;; CHECK: (func $if-identical-arms-with-side-effect (type $19) (param $x (ref null $struct)) (param $y (ref null $struct)) (param $z i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get_u $struct $i8 ;; CHECK-NEXT: (if (result (ref null $struct)) @@ -1055,7 +1055,7 @@ ) ) - ;; CHECK: (func $hoist-LUB-danger (type $32) (param $x i32) (param $b (ref $B)) (param $c (ref $C)) (result i32) + ;; CHECK: (func $hoist-LUB-danger (type $33) (param $x i32) (param $b (ref $B)) (param $c (ref $C)) (result i32) ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: (struct.get $B 1 @@ -1086,7 +1086,7 @@ ) ) - ;; CHECK: (func $incompatible-cast-of-non-null (type $33) (param $struct (ref $struct)) + ;; CHECK: (func $incompatible-cast-of-non-null (type $34) (param $struct (ref $struct)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref none)) ;; CHECK-NEXT: (drop @@ -1204,7 +1204,7 @@ ) ) - ;; CHECK: (func $subtype-compatible (type $20) (param $A (ref null $A)) (param $B (ref null $B)) + ;; CHECK: (func $subtype-compatible (type $21) (param $A (ref null $A)) (param $B (ref null $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (local.get $A) @@ -1284,7 +1284,7 @@ ) ) - ;; CHECK: (func $compatible-test-separate-fallthrough (type $11) (param $eqref eqref) (result i32) + ;; CHECK: (func $compatible-test-separate-fallthrough (type $12) (param $eqref eqref) (result i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $eqref ;; CHECK-NEXT: (block (result eqref) @@ -1318,7 +1318,7 @@ ) ) - ;; CHECK: (func $improvable-test-separate-fallthrough (type $11) (param $eqref eqref) (result i32) + ;; CHECK: (func $improvable-test-separate-fallthrough (type $12) (param $eqref eqref) (result i32) ;; CHECK-NEXT: (ref.test (ref i31) ;; CHECK-NEXT: (block (result eqref) ;; CHECK-NEXT: (ref.as_non_null @@ -1339,7 +1339,7 @@ ) ) - ;; CHECK: (func $incompatible-test-separate-fallthrough (type $11) (param $eqref eqref) (result i32) + ;; CHECK: (func $incompatible-test-separate-fallthrough (type $12) (param $eqref eqref) (result i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $eqref ;; CHECK-NEXT: (block (result eqref) @@ -1498,7 +1498,7 @@ ) ) - ;; CHECK: (func $ref.test-unreachable (type $34) (param $A (ref null $A)) + ;; CHECK: (func $ref.test-unreachable (type $35) (param $A (ref null $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.test (ref $A) ;; CHECK-NEXT: (unreachable) @@ -1525,7 +1525,7 @@ ) ) - ;; CHECK: (func $ref-cast-static-null (type $void) + ;; CHECK: (func $ref-cast-static-null (type $5) ;; CHECK-NEXT: (local $a (ref null $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.null none) @@ -1621,7 +1621,7 @@ ) ) - ;; CHECK: (func $ref-cast-static-general (type $20) (param $a (ref null $A)) (param $b (ref null $B)) + ;; CHECK: (func $ref-cast-static-general (type $21) (param $a (ref null $A)) (param $b (ref null $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) @@ -1907,7 +1907,7 @@ ) ) - ;; CHECK: (func $ref-cast-static-fallthrough-remaining-impossible (type $21) (param $x (ref eq)) + ;; CHECK: (func $ref-cast-static-fallthrough-remaining-impossible (type $22) (param $x (ref eq)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop @@ -1942,7 +1942,7 @@ ) ) - ;; CHECK: (func $ref-cast-static-fallthrough-remaining-nonnull (type $21) (param $x (ref eq)) + ;; CHECK: (func $ref-cast-static-fallthrough-remaining-nonnull (type $22) (param $x (ref eq)) ;; CHECK-NEXT: (local $1 (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref $B)) @@ -2051,7 +2051,7 @@ ) ) - ;; CHECK: (func $ref-test-static-same-type (type $22) (param $nullable (ref null $A)) (param $non-nullable (ref $A)) + ;; CHECK: (func $ref-test-static-same-type (type $23) (param $nullable (ref null $A)) (param $non-nullable (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (ref.is_null @@ -2084,7 +2084,7 @@ ) ) - ;; CHECK: (func $ref-test-static-subtype (type $12) (param $nullable (ref null $B)) (param $non-nullable (ref $B)) + ;; CHECK: (func $ref-test-static-subtype (type $13) (param $nullable (ref null $B)) (param $non-nullable (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (ref.is_null @@ -2115,7 +2115,7 @@ ) ) - ;; CHECK: (func $ref-test-static-supertype (type $22) (param $nullable (ref null $A)) (param $non-nullable (ref $A)) + ;; CHECK: (func $ref-test-static-supertype (type $23) (param $nullable (ref null $A)) (param $non-nullable (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (local.get $nullable) @@ -2142,7 +2142,7 @@ ) ) - ;; CHECK: (func $ref-test-static-impossible (type $35) (param $nullable (ref null $array)) (param $non-nullable (ref $array)) + ;; CHECK: (func $ref-test-static-impossible (type $36) (param $nullable (ref null $array)) (param $non-nullable (ref $array)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop @@ -2222,14 +2222,14 @@ ) ) - ;; CHECK: (func $impossible (type $36) (result (ref none)) + ;; CHECK: (func $impossible (type $37) (result (ref none)) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) (func $impossible (result (ref none)) (unreachable) ) - ;; CHECK: (func $bottom-type-accessors (type $37) (param $bot (ref none)) (param $null nullref) + ;; CHECK: (func $bottom-type-accessors (type $38) (param $bot (ref none)) (param $null nullref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) @@ -2271,7 +2271,7 @@ ) ) - ;; CHECK: (func $ref-cast-heap-type (type $12) (param $null-b (ref null $B)) (param $b (ref $B)) + ;; CHECK: (func $ref-cast-heap-type (type $13) (param $null-b (ref null $B)) (param $b (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $b) ;; CHECK-NEXT: ) @@ -2318,7 +2318,7 @@ ) ) - ;; CHECK: (func $ref-cast-heap-type-incompatible (type $12) (param $null-b (ref null $B)) (param $b (ref $B)) + ;; CHECK: (func $ref-cast-heap-type-incompatible (type $13) (param $null-b (ref null $B)) (param $b (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref none)) ;; CHECK-NEXT: (drop @@ -2377,7 +2377,7 @@ ) ) - ;; CHECK: (func $compatible-cast-separate-fallthrough (type $23) (param $eqref eqref) (result (ref i31)) + ;; CHECK: (func $compatible-cast-separate-fallthrough (type $24) (param $eqref eqref) (result (ref i31)) ;; CHECK-NEXT: (local $1 i31ref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $eqref @@ -2417,7 +2417,7 @@ ) ) - ;; CHECK: (func $compatible-cast-fallthrough-null-check (type $23) (param $eqref eqref) (result (ref i31)) + ;; CHECK: (func $compatible-cast-fallthrough-null-check (type $24) (param $eqref eqref) (result (ref i31)) ;; CHECK-NEXT: (local $1 i31ref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $eqref @@ -2449,7 +2449,7 @@ ) ) - ;; CHECK: (func $compatible-cast-separate-fallthrough-multiple-options-1 (type $24) (param $eqref eqref) (result (ref eq)) + ;; CHECK: (func $compatible-cast-separate-fallthrough-multiple-options-1 (type $25) (param $eqref eqref) (result (ref eq)) ;; CHECK-NEXT: (local $1 i31ref) ;; CHECK-NEXT: (block $outer (result (ref eq)) ;; CHECK-NEXT: (block (result (ref i31)) @@ -2507,7 +2507,7 @@ ) ) - ;; CHECK: (func $compatible-cast-separate-fallthrough-multiple-options-2 (type $24) (param $eqref eqref) (result (ref eq)) + ;; CHECK: (func $compatible-cast-separate-fallthrough-multiple-options-2 (type $25) (param $eqref eqref) (result (ref eq)) ;; CHECK-NEXT: (local $1 (ref i31)) ;; CHECK-NEXT: (block $outer (result (ref eq)) ;; CHECK-NEXT: (block (result (ref i31)) @@ -2562,7 +2562,7 @@ ) ) - ;; CHECK: (func $incompatible-cast-separate-fallthrough (type $38) (param $eqref eqref) (result structref) + ;; CHECK: (func $incompatible-cast-separate-fallthrough (type $39) (param $eqref eqref) (result structref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $eqref ;; CHECK-NEXT: (block (result (ref i31)) @@ -2699,7 +2699,7 @@ ) ) - ;; CHECK: (func $as_of_unreachable (type $39) (result (ref $A)) + ;; CHECK: (func $as_of_unreachable (type $40) (result (ref $A)) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) (func $as_of_unreachable (result (ref $A)) @@ -2713,7 +2713,7 @@ ) ) - ;; CHECK: (func $cast-internalized-extern (type $40) (param $externref externref) + ;; CHECK: (func $cast-internalized-extern (type $41) (param $externref externref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (extern.internalize @@ -2735,7 +2735,7 @@ ) ) - ;; CHECK: (func $struct.set.null.fallthrough (type $void) + ;; CHECK: (func $struct.set.null.fallthrough (type $5) ;; CHECK-NEXT: (local $temp (ref null $struct)) ;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit) ;; CHECK-NEXT: (drop @@ -2764,7 +2764,7 @@ ) ) - ;; CHECK: (func $set.array.null (type $void) + ;; CHECK: (func $set.array.null (type $5) ;; CHECK-NEXT: (local $temp (ref none)) ;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit) ;; CHECK-NEXT: (drop @@ -2822,7 +2822,7 @@ ) ) - ;; CHECK: (func $refinalize.select.arm.flip (type $void) + ;; CHECK: (func $refinalize.select.arm.flip (type $5) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.cast (ref $void2) ;; CHECK-NEXT: (ref.func $refinalize.select.arm) @@ -2842,7 +2842,7 @@ ) ) - ;; CHECK: (func $refinalize.select.arm.unknown (type $41) (param $x i32) + ;; CHECK: (func $refinalize.select.arm.unknown (type $42) (param $x i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.cast (ref $void2) ;; CHECK-NEXT: (ref.func $refinalize.select.arm) @@ -2862,7 +2862,7 @@ ) ) - ;; CHECK: (func $non-null-bottom-ref (type $42) (result (ref func)) + ;; CHECK: (func $non-null-bottom-ref (type $43) (result (ref func)) ;; CHECK-NEXT: (local $0 funcref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $0 @@ -2890,7 +2890,7 @@ ) ) - ;; CHECK: (func $non-null-bottom-cast (type $43) (result (ref nofunc)) + ;; CHECK: (func $non-null-bottom-cast (type $44) (result (ref nofunc)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.func $non-null-bottom-cast) ;; CHECK-NEXT: ) @@ -2960,7 +2960,7 @@ ) ) - ;; CHECK: (func $ref.test-fallthrough (type $void) + ;; CHECK: (func $ref.test-fallthrough (type $5) ;; CHECK-NEXT: (local $A (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.test (ref $B) @@ -3048,7 +3048,7 @@ ) ) - ;; CHECK: (func $gc_to_unreachable_in_added_constants (type $void) + ;; CHECK: (func $gc_to_unreachable_in_added_constants (type $5) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.wrap_i64 ;; CHECK-NEXT: (i64.add @@ -3089,7 +3089,7 @@ (unreachable) ) - ;; CHECK: (func $array-copy-non-null (type $14) (param $x (ref null $array)) + ;; CHECK: (func $array-copy-non-null (type $15) (param $x (ref null $array)) ;; CHECK-NEXT: (block $block ;; CHECK-NEXT: (array.copy $array $array ;; CHECK-NEXT: (ref.as_non_null diff --git a/test/lit/passes/remove-unused-brs-gc.wast b/test/lit/passes/remove-unused-brs-gc.wast index 625b31584..1bdd6f680 100644 --- a/test/lit/passes/remove-unused-brs-gc.wast +++ b/test/lit/passes/remove-unused-brs-gc.wast @@ -5,7 +5,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct )) + ;; CHECK-NEXT: (type $struct (sub (struct ))) (type $struct (sub (struct))) ;; CHECK: (type $struct2 (struct )) (type $struct2 (struct)) diff --git a/test/lit/passes/remove-unused-module-elements-refs.wast b/test/lit/passes/remove-unused-module-elements-refs.wast index ecb96c249..8a7ef42da 100644 --- a/test/lit/passes/remove-unused-module-elements-refs.wast +++ b/test/lit/passes/remove-unused-module-elements-refs.wast @@ -9,10 +9,10 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A-super (func)) + ;; CHECK-NEXT: (type $A-super (sub (func))) ;; OPEN_WORLD: (rec - ;; OPEN_WORLD-NEXT: (type $A-super (func)) - (type $A-super (func)) + ;; OPEN_WORLD-NEXT: (type $A-super (sub (func))) + (type $A-super (sub (func))) ;; CHECK: (type $A (sub $A-super (func))) ;; OPEN_WORLD: (type $A (sub $A-super (func))) @@ -634,8 +634,8 @@ ;; OPEN_WORLD: (type $void (func)) (type $void (func)) - ;; CHECK: (type $vtable (struct (field (ref $void)) (field (ref $void)))) - ;; OPEN_WORLD: (type $vtable (struct (field (ref $void)) (field (ref $void)))) + ;; CHECK: (type $vtable (sub (struct (field (ref $void)) (field (ref $void))))) + ;; OPEN_WORLD: (type $vtable (sub (struct (field (ref $void)) (field (ref $void))))) (type $vtable (struct_subtype (field (ref $void)) (field (ref $void)) data)) ;; CHECK: (global $vtable (ref $vtable) (struct.new $vtable @@ -754,12 +754,12 @@ ;; OPEN_WORLD: (type $void (func)) (type $void (func)) - ;; CHECK: (type $vtable (struct (field (ref $void)) (field (ref $void)))) - ;; OPEN_WORLD: (type $vtable (struct (field (ref $void)) (field (ref $void)))) + ;; CHECK: (type $vtable (sub (struct (field (ref $void)) (field (ref $void))))) + ;; OPEN_WORLD: (type $vtable (sub (struct (field (ref $void)) (field (ref $void))))) (type $vtable (struct_subtype (field (ref $void)) (field (ref $void)) data)) - ;; CHECK: (type $struct (struct (field (ref $vtable)) (field (ref $vtable)) (field (ref $vtable)) (field (ref $vtable)))) - ;; OPEN_WORLD: (type $struct (struct (field (ref $vtable)) (field (ref $vtable)) (field (ref $vtable)) (field (ref $vtable)))) + ;; CHECK: (type $struct (sub (struct (field (ref $vtable)) (field (ref $vtable)) (field (ref $vtable)) (field (ref $vtable))))) + ;; OPEN_WORLD: (type $struct (sub (struct (field (ref $vtable)) (field (ref $vtable)) (field (ref $vtable)) (field (ref $vtable))))) (type $struct (struct_subtype (field (ref $vtable)) (field (ref $vtable)) (field (ref $vtable)) (field (ref $vtable)) data)) ;; CHECK: (global $vtable (ref $vtable) (struct.new $vtable @@ -1070,8 +1070,8 @@ ;; OPEN_WORLD: (type $void (func)) (type $void (func)) - ;; CHECK: (type $vtable (struct (field (ref $void)) (field (ref $void)))) - ;; OPEN_WORLD: (type $vtable (struct (field (ref $void)) (field (ref $void)))) + ;; CHECK: (type $vtable (sub (struct (field (ref $void)) (field (ref $void))))) + ;; OPEN_WORLD: (type $vtable (sub (struct (field (ref $void)) (field (ref $void))))) (type $vtable (struct_subtype (field (ref $void)) (field (ref $void)) data)) ;; CHECK: (elem declare func $a $b $void) @@ -1174,8 +1174,8 @@ ;; OPEN_WORLD: (rec ;; OPEN_WORLD-NEXT: (type $vtable-func (func (param (ref $vtable)))) (type $vtable-func (func (param (ref $vtable)))) - ;; CHECK: (type $vtable (struct (field (ref $vtable-func)) (field (ref $vtable-func)))) - ;; OPEN_WORLD: (type $vtable (struct (field (ref $vtable-func)) (field (ref $vtable-func)))) + ;; CHECK: (type $vtable (sub (struct (field (ref $vtable-func)) (field (ref $vtable-func))))) + ;; OPEN_WORLD: (type $vtable (sub (struct (field (ref $vtable-func)) (field (ref $vtable-func))))) (type $vtable (struct_subtype (field (ref $vtable-func)) (field (ref $vtable-func)) data)) ) @@ -1368,9 +1368,9 @@ ;; OPEN_WORLD: (type $void (func)) (type $void (func)) - ;; CHECK: (type $struct (struct (field funcref))) - ;; OPEN_WORLD: (type $struct (struct (field funcref))) - (type $struct (struct (field funcref))) + ;; CHECK: (type $struct (sub (struct (field funcref)))) + ;; OPEN_WORLD: (type $struct (sub (struct (field funcref)))) + (type $struct (sub (struct (field funcref)))) ;; CHECK: (type $substruct (sub $struct (struct (field funcref)))) ;; OPEN_WORLD: (type $substruct (sub $struct (struct (field funcref)))) diff --git a/test/lit/passes/roundtrip-gc-types.wast b/test/lit/passes/roundtrip-gc-types.wast index e50fe7b44..c3b3e93c1 100644 --- a/test/lit/passes/roundtrip-gc-types.wast +++ b/test/lit/passes/roundtrip-gc-types.wast @@ -9,8 +9,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field (ref $C)))) - (type $A (struct (field (ref $C)))) + ;; CHECK-NEXT: (type $A (sub (struct (field (ref $C))))) + (type $A (sub (struct (field (ref $C))))) ;; CHECK: (type $B (func (param (ref $A)) (result (ref $B)))) (type $B (func (param (ref $A)) (result (ref $B)))) diff --git a/test/lit/passes/rse-gc.wast b/test/lit/passes/rse-gc.wast index f1dfb6f78..1dbc61574 100644 --- a/test/lit/passes/rse-gc.wast +++ b/test/lit/passes/rse-gc.wast @@ -2,8 +2,8 @@ ;; RUN: wasm-opt %s --rse -all -S -o - | filecheck %s (module - ;; CHECK: (type $A (struct (field structref))) - (type $A (struct (field (ref null struct)))) + ;; CHECK: (type $A (sub (struct (field structref)))) + (type $A (sub (struct (field (ref null struct))))) ;; $B is a subtype of $A, and its field has a more refined type (it is non- ;; nullable). diff --git a/test/lit/passes/signature-pruning.wast b/test/lit/passes/signature-pruning.wast index 4f054295e..98ed94d4a 100644 --- a/test/lit/passes/signature-pruning.wast +++ b/test/lit/passes/signature-pruning.wast @@ -5,7 +5,7 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func)) - ;; CHECK: (type $sig (func (param i32 f64))) + ;; CHECK: (type $sig (sub (func (param i32 f64)))) (type $sig (func_subtype (param i32) (param i64) (param f32) (param f64) func)) (memory 1 1) @@ -71,7 +71,7 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func)) - ;; CHECK: (type $sig (func (param i64 f32))) + ;; CHECK: (type $sig (sub (func (param i64 f32)))) (type $sig (func_subtype (param i32) (param i64) (param f32) (param f64) func)) (memory 1 1) @@ -136,7 +136,7 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func)) - ;; CHECK: (type $sig (func (param i32 i64 f32))) + ;; CHECK: (type $sig (sub (func (param i32 i64 f32)))) (type $sig (func_subtype (param i32) (param i64) (param f32) (param f64) func)) (memory 1 1) @@ -213,7 +213,7 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func)) - ;; CHECK: (type $sig (func (param i32 i64 f32))) + ;; CHECK: (type $sig (sub (func (param i32 i64 f32)))) (type $sig (func_subtype (param i32) (param i64) (param f32) (param f64) func)) (memory 1 1) @@ -284,7 +284,7 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func)) - ;; CHECK: (type $sig (func)) + ;; CHECK: (type $sig (sub (func))) (type $sig (func_subtype (param i32) (param i64) (param f32) (param f64) func)) (memory 1 1) @@ -331,7 +331,7 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func)) - ;; CHECK: (type $sig (func)) + ;; CHECK: (type $sig (sub (func))) (type $sig (func_subtype (param i32) func)) (memory 1 1) @@ -375,7 +375,7 @@ ) (module - ;; CHECK: (type $sig (func)) + ;; CHECK: (type $sig (sub (func))) (type $sig (func_subtype (param i32) func)) (memory 1 1) @@ -393,12 +393,12 @@ ) (module - ;; CHECK: (type $sig (func (param i32))) + ;; CHECK: (type $sig (sub (func (param i32)))) (type $sig (func_subtype (param i32) func)) ;; As above, but now an import also uses this signature, which prevents us ;; from changing anything. - ;; CHECK: (import "out" "func" (func $import (type $sig) (param i32))) + ;; CHECK: (import "out" "func" (func $import (type $func.0) (param i32))) (import "out" "func" (func $import (type $sig) (param i32))) (memory 1 1) @@ -413,7 +413,7 @@ ) (module - ;; CHECK: (type $sig (func (param i32))) + ;; CHECK: (type $sig (sub (func (param i32)))) (type $sig (func_subtype (param i32) func)) (memory 1 1) @@ -445,9 +445,9 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $sig2 (func (param i32))) + ;; CHECK-NEXT: (type $sig2 (sub (func (param i32)))) - ;; CHECK: (type $sig (func)) + ;; CHECK: (type $sig (sub (func))) (type $sig (func_subtype (param i32) func)) (type $sig2 (func_subtype (param i32) func)) @@ -484,7 +484,7 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func)) - ;; CHECK: (type $sig (func)) + ;; CHECK: (type $sig (sub (func))) (type $sig (func_subtype (param i32) func)) (memory 1 1) @@ -558,7 +558,7 @@ ;; The presence of a table prevents us from doing any optimizations. (table 1 1 anyref) - ;; CHECK: (type $sig (func (param i32))) + ;; CHECK: (type $sig (sub (func (param i32)))) (type $sig (func_subtype (param i32) func)) ;; CHECK: (table $0 1 1 anyref) @@ -573,7 +573,7 @@ ;; Exports cannot be optimized in any way: we cannot remove parameters from ;; them, and also we cannot apply constant parameter values either. (module - ;; CHECK: (type $sig (func (param i32))) + ;; CHECK: (type $sig (sub (func (param i32)))) (type $sig (func_subtype (param i32) func)) ;; CHECK: (type $1 (func)) @@ -613,9 +613,9 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $sig2 (func)) + ;; CHECK-NEXT: (type $sig2 (sub (func))) - ;; CHECK: (type $sig1 (func)) + ;; CHECK: (type $sig1 (sub (func))) (type $sig1 (func_subtype (param i32) func)) (type $sig2 (func_subtype (param f64) func)) ) @@ -638,9 +638,9 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $sig-bar (func (param i32))) + ;; CHECK-NEXT: (type $sig-bar (sub (func (param i32)))) - ;; CHECK: (type $sig-foo (func)) + ;; CHECK: (type $sig-foo (sub (func))) (type $sig-foo (func_subtype (param i32) func)) (type $sig-bar (func_subtype (param i32) func)) ) @@ -706,9 +706,9 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $sig-bar (func (param funcref))) + ;; CHECK-NEXT: (type $sig-bar (sub (func (param funcref)))) - ;; CHECK: (type $sig-foo (func)) + ;; CHECK: (type $sig-foo (sub (func))) (type $sig-foo (func_subtype (param funcref) func)) (type $sig-bar (func_subtype (param funcref) func)) ) @@ -762,9 +762,9 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $sig-bar (func (param anyref))) + ;; CHECK-NEXT: (type $sig-bar (sub (func (param anyref)))) - ;; CHECK: (type $sig-foo (func)) + ;; CHECK: (type $sig-foo (sub (func))) (type $sig-foo (func_subtype (param anyref) func)) (type $sig-bar (func_subtype (param anyref) func)) ) @@ -882,19 +882,19 @@ ;; relationship. Atm we do not prune such "cycles" so we do not optimize here. ;; TODO (module - ;; CHECK: (type $struct.A (struct (field i32))) - (type $struct.A (struct (field i32))) - ;; CHECK: (type $array.A (array (ref $struct.A))) + ;; CHECK: (type $struct.A (sub (struct (field i32)))) + (type $struct.A (sub (struct (field i32)))) + ;; CHECK: (type $array.A (sub (array (ref $struct.A)))) ;; CHECK: (type $struct.B (sub $struct.A (struct (field i32) (field i64)))) (type $struct.B (struct_subtype (field i32) (field i64) $struct.A)) - (type $array.A (array (ref $struct.A))) + (type $array.A (sub (array (ref $struct.A)))) ;; CHECK: (type $array.B (sub $array.A (array (ref $struct.B)))) (type $array.B (array_subtype (ref $struct.B) $array.A)) - ;; CHECK: (type $func.A (func (param (ref $array.B)) (result (ref $array.A)))) - (type $func.A (func (param (ref $array.B)) (result (ref $array.A)))) + ;; CHECK: (type $func.A (sub (func (param (ref $array.B)) (result (ref $array.A))))) + (type $func.A (sub (func (param (ref $array.B)) (result (ref $array.A))))) ;; CHECK: (type $func.B (sub $func.A (func (param (ref $array.A)) (result (ref $array.B))))) (type $func.B (func_subtype (param (ref $array.A)) (result (ref $array.B)) $func.A)) diff --git a/test/lit/passes/signature-refining.wast b/test/lit/passes/signature-refining.wast index dbd64ab78..c09c837d2 100644 --- a/test/lit/passes/signature-refining.wast +++ b/test/lit/passes/signature-refining.wast @@ -13,7 +13,7 @@ ;; CHECK: (type $1 (func)) - ;; CHECK: (type $sig (func (param (ref $struct)))) + ;; CHECK: (type $sig (sub (func (param (ref $struct))))) (type $sig (func_subtype (param anyref) func)) ;; CHECK: (func $func (type $sig) (param $x (ref $struct)) @@ -43,7 +43,7 @@ ;; CHECK: (type $1 (func)) - ;; CHECK: (type $sig (func (param (ref $struct)))) + ;; CHECK: (type $sig (sub (func (param (ref $struct))))) (type $sig (func_subtype (param anyref) func)) ;; CHECK: (elem declare func $func) @@ -79,7 +79,7 @@ ;; CHECK: (type $1 (func)) - ;; CHECK: (type $sig (func (param eqref))) + ;; CHECK: (type $sig (sub (func (param eqref)))) (type $sig (func_subtype (param anyref) func)) ;; CHECK: (elem declare func $func) @@ -121,7 +121,7 @@ (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct )) + ;; CHECK-NEXT: (type $struct (sub (struct ))) ;; CHECK: (type $struct-sub2 (sub $struct (struct ))) @@ -129,10 +129,10 @@ ;; CHECK: (type $3 (func)) - ;; CHECK: (type $sig (func (param (ref $struct)))) + ;; CHECK: (type $sig (sub (func (param (ref $struct))))) (type $sig (func_subtype (param anyref) func)) - (type $struct (struct)) + (type $struct (sub (struct))) (type $struct-sub1 (struct_subtype $struct)) @@ -178,7 +178,7 @@ ;; CHECK: (type $1 (func)) - ;; CHECK: (type $sig (func (param (ref $struct)))) + ;; CHECK: (type $sig (sub (func (param (ref $struct))))) (type $sig (func_subtype (param anyref) func)) (type $struct (struct)) @@ -212,11 +212,11 @@ ;; to check for proper validation after the update. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (ref $sig)))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (ref $sig))))) ;; CHECK: (type $1 (func)) - ;; CHECK: (type $sig (func (param (ref $struct) (ref $sig)))) + ;; CHECK: (type $sig (sub (func (param (ref $struct) (ref $sig))))) (type $sig (func_subtype (param anyref funcref) func)) (type $struct (struct_subtype (field (ref $sig)) data)) @@ -282,7 +282,7 @@ ;; CHECK: (type $1 (func)) - ;; CHECK: (type $sig (func (param (ref $struct)))) + ;; CHECK: (type $sig (sub (func (param (ref $struct))))) (type $sig (func_subtype (param anyref) func)) ;; CHECK: (elem declare func $func) @@ -319,7 +319,7 @@ (type $struct (struct)) - ;; CHECK: (type $sig (func (param anyref))) + ;; CHECK: (type $sig (sub (func (param anyref)))) (type $sig (func_subtype (param anyref) func)) ;; CHECK: (type $1 (func)) @@ -352,7 +352,7 @@ (type $struct (struct)) - ;; CHECK: (type $sig (func (param anyref))) + ;; CHECK: (type $sig (sub (func (param anyref)))) (type $sig (func_subtype (param anyref) func)) ;; CHECK: (func $func (type $sig) (param $x anyref) @@ -371,9 +371,9 @@ ;; CHECK: (type $1 (func)) - ;; CHECK: (type $sig-2 (func (param eqref (ref $struct)))) + ;; CHECK: (type $sig-2 (sub (func (param eqref (ref $struct))))) - ;; CHECK: (type $sig-1 (func (param structref anyref))) + ;; CHECK: (type $sig-1 (sub (func (param structref anyref)))) (type $sig-1 (func_subtype (param anyref) (param anyref) func)) (type $sig-2 (func_subtype (param anyref) (param anyref) func)) ) @@ -442,7 +442,7 @@ (module ;; The presence of a table prevents us from doing any optimizations. - ;; CHECK: (type $sig (func (param anyref))) + ;; CHECK: (type $sig (sub (func (param anyref)))) (type $sig (func_subtype (param anyref) func)) ;; CHECK: (type $1 (func)) @@ -481,7 +481,7 @@ ;; CHECK: (type $1 (func)) - ;; CHECK: (type $sig (func (param (ref null $struct)))) + ;; CHECK: (type $sig (sub (func (param (ref null $struct))))) (type $sig (func_subtype (param anyref) func)) (type $struct (struct)) @@ -515,16 +515,16 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $0 (func)) - ;; CHECK: (type $sig-unreachable (func (result anyref))) + ;; CHECK: (type $sig-unreachable (sub (func (result anyref)))) - ;; CHECK: (type $sig-cannot-refine (func (result (ref func)))) + ;; CHECK: (type $sig-cannot-refine (sub (func (result (ref func))))) ;; CHECK: (type $struct (struct )) (type $struct (struct)) ;; This signature has a single function using it, which returns a more ;; refined type, and we can refine to that. - ;; CHECK: (type $sig-can-refine (func (result (ref $struct)))) + ;; CHECK: (type $sig-can-refine (sub (func (result (ref $struct))))) (type $sig-can-refine (func_subtype (result anyref) func)) ;; Also a single function, but no refinement is possible. @@ -614,7 +614,7 @@ ;; This signature has multiple functions using it, and some of them have nulls ;; which should be updated when we refine. - ;; CHECK: (type $sig (func (result (ref null $struct)))) + ;; CHECK: (type $sig (sub (func (result (ref null $struct))))) (type $sig (func_subtype (result anyref) func)) ;; CHECK: (func $func-1 (type $sig) (result (ref null $struct)) @@ -660,7 +660,7 @@ ;; Exports prevent optimization, so $func's type will not change here. (module - ;; CHECK: (type $sig (func (param anyref))) + ;; CHECK: (type $sig (sub (func (param anyref)))) ;; CHECK: (type $1 (func)) @@ -690,7 +690,7 @@ ) (module - ;; CHECK: (type $A (func (param i32))) + ;; CHECK: (type $A (sub (func (param i32)))) (type $A (func_subtype (param i32) func)) ;; CHECK: (type $B (sub $A (func (param i32)))) (type $B (func_subtype (param i32) $A)) @@ -783,8 +783,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (func (param (ref null $B)) (result (ref null $A)))) - (type $A (func (param (ref null $B)) (result (ref null $A)))) + ;; CHECK-NEXT: (type $A (sub (func (param (ref null $B)) (result (ref null $A))))) + (type $A (sub (func (param (ref null $B)) (result (ref null $A))))) ;; CHECK: (type $B (sub $A (func (param (ref null $A)) (result (ref null $B))))) (type $B (func_subtype (param (ref null $A)) (result (ref null $B)) $A)) ) @@ -805,8 +805,8 @@ ;; supertype. In this example, refining the child's anyref to nullref would ;; cause an error. (module - ;; CHECK: (type $parent (func (param anyref))) - (type $parent (func (param anyref))) + ;; CHECK: (type $parent (sub (func (param anyref)))) + (type $parent (sub (func (param anyref)))) ;; CHECK: (type $child (sub $parent (func (param anyref)))) (type $child (func_subtype (param anyref) $parent)) @@ -893,8 +893,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct )) - (type $A (struct)) + ;; CHECK-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; CHECK: (type $B (sub $A (struct ))) (type $B (sub $A (struct))) diff --git a/test/lit/passes/simplify-locals-gc.wast b/test/lit/passes/simplify-locals-gc.wast index 223657ae9..1de41e8e8 100644 --- a/test/lit/passes/simplify-locals-gc.wast +++ b/test/lit/passes/simplify-locals-gc.wast @@ -4,7 +4,7 @@ ;; RUN: | filecheck %s (module - ;; CHECK: (type $A (struct (field structref))) + ;; CHECK: (type $A (sub (struct (field structref)))) ;; CHECK: (type $B (sub $A (struct (field (ref struct))))) diff --git a/test/lit/passes/simplify-locals-strings.wast b/test/lit/passes/simplify-locals-strings.wast index 7e8f77c02..d36db96ae 100644 --- a/test/lit/passes/simplify-locals-strings.wast +++ b/test/lit/passes/simplify-locals-strings.wast @@ -5,9 +5,9 @@ (module (memory 10 10) - ;; CHECK: (type $array (array (mut i8))) + ;; CHECK: (type $array (sub (array (mut i8)))) (type $array (array_subtype (mut i8) data)) - ;; CHECK: (type $array16 (array (mut i16))) + ;; CHECK: (type $array16 (sub (array (mut i16)))) (type $array16 (array_subtype (mut i16) data)) ;; CHECK: (func $no-new-past-store (type $1) diff --git a/test/lit/passes/type-merging-tnh.wast b/test/lit/passes/type-merging-tnh.wast index c5ad4e760..9df11164f 100644 --- a/test/lit/passes/type-merging-tnh.wast +++ b/test/lit/passes/type-merging-tnh.wast @@ -4,8 +4,8 @@ ;; ref.cast does not inhibit merging if traps never happen. (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct )) - (type $A (struct)) + ;; CHECK-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) (type $B (struct_subtype $A)) ;; CHECK: (type $1 (func (param (ref $A)) (result (ref $A)))) @@ -25,8 +25,8 @@ ;; Check that a ref.test still inhibits merging with -tnh. (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct )) - (type $A (struct)) + ;; CHECK-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; CHECK: (type $B (sub $A (struct ))) (type $B (struct_subtype $A)) @@ -47,8 +47,8 @@ ;; Check that a br_on_cast still inhibits merging with -tnh. (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct )) - (type $A (struct)) + ;; CHECK-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; CHECK: (type $B (sub $A (struct ))) (type $B (struct_subtype $A)) @@ -93,8 +93,8 @@ ;; call_indirect should not inhibit merging if traps never happen. (module - ;; CHECK: (type $A (func)) - (type $A (func)) + ;; CHECK: (type $A (sub (func))) + (type $A (sub (func))) (type $B (func_subtype $A)) (table 1 1 (ref null $A)) diff --git a/test/lit/passes/type-merging.wast b/test/lit/passes/type-merging.wast index 53582a586..4a68a9213 100644 --- a/test/lit/passes/type-merging.wast +++ b/test/lit/passes/type-merging.wast @@ -4,7 +4,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field anyref))) + ;; CHECK-NEXT: (type $A (sub (struct (field anyref)))) (type $A (struct_subtype (field anyref) data)) (type $B (struct_subtype (field anyref) $A)) ;; CHECK: (type $G (sub final $A (struct (field anyref)))) @@ -78,7 +78,7 @@ ;; Multiple levels of merging. (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field i32))) + ;; CHECK-NEXT: (type $A (sub (struct (field i32)))) (type $A (struct_subtype (field i32) data)) (type $B (struct_subtype (field i32) $A)) (type $C (struct_subtype (field i32) $B)) @@ -122,7 +122,7 @@ ;; should remain the same as before, everything merged into either $A or $D. (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field i32))) + ;; CHECK-NEXT: (type $A (sub (struct (field i32)))) (type $A (struct_subtype (field i32) data)) (type $B (struct_subtype (field i32) $A)) (type $C (struct_subtype (field i32) $B)) @@ -157,11 +157,11 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct )) - (type $X (struct)) + ;; CHECK-NEXT: (type $X (sub (struct ))) + (type $X (sub (struct))) (type $Y (struct_subtype $X)) - ;; CHECK: (type $A (struct (field (ref null $X)))) - (type $A (struct (field (ref null $X)))) + ;; CHECK: (type $A (sub (struct (field (ref null $X))))) + (type $A (sub (struct (field (ref null $X))))) (type $B (struct_subtype (field (ref null $Y)) $A)) ;; CHECK: (type $C (sub $A (struct (field (ref $X))))) (type $C (struct_subtype (field (ref $Y)) $A)) @@ -186,8 +186,8 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field (ref null $A)))) - (type $A (struct (ref null $A))) + ;; CHECK-NEXT: (type $A (sub (struct (field (ref null $A))))) + (type $A (sub (struct (ref null $A)))) (type $B (struct_subtype (ref null $B) $A)) ;; CHECK: (type $1 (func)) @@ -208,12 +208,12 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct (field (ref null $A)) (field f32))) + ;; CHECK-NEXT: (type $X (sub (struct (field (ref null $A)) (field f32)))) - ;; CHECK: (type $A (struct (field (ref null $X)) (field i32))) - (type $A (struct (ref null $X) i32)) + ;; CHECK: (type $A (sub (struct (field (ref null $X)) (field i32)))) + (type $A (sub (struct (ref null $X) i32))) (type $B (struct_subtype (ref null $Y) i32 $A)) - (type $X (struct (ref null $A) f32)) + (type $X (sub (struct (ref null $A) f32))) (type $Y (struct_subtype (ref null $B) f32 $X)) ) @@ -239,10 +239,10 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field (ref null $A)))) - (type $A (struct (ref null $X))) + ;; CHECK-NEXT: (type $A (sub (struct (field (ref null $A))))) + (type $A (sub (struct (ref null $X)))) (type $B (struct_subtype (ref null $Y) $A)) - (type $X (struct (ref null $A))) + (type $X (sub (struct (ref null $A)))) (type $Y (struct_subtype (ref null $B) $X)) ) @@ -325,12 +325,12 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct (field (ref null $A)))) + ;; CHECK-NEXT: (type $X (sub (struct (field (ref null $A))))) - ;; CHECK: (type $A (struct (field (ref null $X)))) - (type $A (struct (ref null $X))) + ;; CHECK: (type $A (sub (struct (field (ref null $X))))) + (type $A (sub (struct (ref null $X)))) (type $B (struct_subtype (ref null $Y) $A)) - (type $X (struct (ref null $A))) + (type $X (sub (struct (ref null $A)))) (type $Y (struct_subtype (ref null $B) $X)) ) @@ -481,12 +481,12 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct (field anyref))) - (type $X (struct anyref)) + ;; CHECK-NEXT: (type $X (sub (struct (field anyref)))) + (type $X (sub (struct anyref))) ;; CHECK: (type $Y (sub $X (struct (field eqref)))) (type $Y (struct_subtype eqref $X)) - ;; CHECK: (type $A (struct (field (ref null $X)))) - (type $A (struct (ref null $X))) + ;; CHECK: (type $A (sub (struct (field (ref null $X))))) + (type $A (sub (struct (ref null $X)))) ;; CHECK: (type $B (sub $A (struct (field (ref null $Y))))) (type $B (struct_subtype (ref null $Y) $A)) (type $C (struct_subtype (ref null $Y) $A)) @@ -511,8 +511,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field anyref))) - (type $A (struct anyref)) + ;; CHECK-NEXT: (type $A (sub (struct (field anyref)))) + (type $A (sub (struct anyref))) (type $B (struct_subtype eqref $A)) ;; CHECK: (type $C (sub $A (struct (field eqref)))) (type $C (struct_subtype eqref $A)) @@ -538,8 +538,8 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field anyref))) - (type $A (struct anyref)) + ;; CHECK-NEXT: (type $A (sub (struct (field anyref)))) + (type $A (sub (struct anyref))) (type $B (struct_subtype anyref $A)) (type $C (struct_subtype anyref $A)) (type $D (struct_subtype eqref $B)) @@ -574,19 +574,19 @@ (rec ;; These will get merged in the initial supertype merging stage. ;; CHECK: (rec - ;; CHECK-NEXT: (type $B' (struct (field (ref $A)))) + ;; CHECK-NEXT: (type $B' (sub (struct (field (ref $A))))) ;; CHECK: (type $C (sub $B' (struct (field (ref $A)) (field i32)))) ;; CHECK: (type $D' (sub $C (struct (field (ref $A)) (field i32) (field i32)))) - ;; CHECK: (type $A (struct )) - (type $A (struct)) + ;; CHECK: (type $A (sub (struct ))) + (type $A (sub (struct))) (type $A' (struct_subtype $A)) ;; These siblings will be merged only after $a and $a' are merged. - (type $B (struct (ref $A))) - (type $B' (struct (ref $A'))) + (type $B (sub (struct (ref $A)))) + (type $B' (sub (struct (ref $A')))) ;; These will get merged only after $b and $b' are merged. (type $C (struct_subtype (ref $A) i32 $B)) @@ -625,8 +625,8 @@ ;; Check that we refinalize properly. (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct )) - (type $A (struct)) + ;; CHECK-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) (type $B (struct_subtype $A)) ;; CHECK: (type $1 (func (result (ref null $A)))) @@ -653,7 +653,7 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $C (struct (field (mut i32)))) + ;; CHECK-NEXT: (type $C (sub (struct (field (mut i32))))) ;; CHECK: (type $D (sub $C (struct (field (mut i32)) (field (mut i32))))) @@ -663,7 +663,7 @@ ;; CHECK: (type $I (array (mut (ref null $C)))) (type $I (array (mut (ref null $C)))) - (type $C (struct (field (mut i32)))) + (type $C (sub (struct (field (mut i32))))) (type $D (struct_subtype (field (mut i32)) (field (mut i32)) $C)) (type $E (struct_subtype (field (mut i32)) (field (mut i32)) $D)) (type $F (struct_subtype (field (mut i32)) (field (mut i32)) $E)) @@ -706,15 +706,15 @@ ;; Arrays (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $refarray (array anyref)) + ;; CHECK-NEXT: (type $refarray (sub (array anyref))) ;; CHECK: (type $sub-refarray-nn (sub $refarray (array (ref any)))) - ;; CHECK: (type $intarray (array (mut i32))) - (type $intarray (array (mut i32))) + ;; CHECK: (type $intarray (sub (array (mut i32)))) + (type $intarray (sub (array (mut i32)))) (type $sub-intarray (array_subtype (mut i32) $intarray)) - (type $refarray (array (ref null any))) + (type $refarray (sub (array (ref null any)))) (type $sub-refarray (array_subtype (ref null any) $refarray)) (type $sub-refarray-nn (array_subtype (ref any) $refarray)) @@ -750,8 +750,8 @@ ;; Function types (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $func (func (param eqref))) - (type $func (func (param eqref))) + ;; CHECK-NEXT: (type $func (sub (func (param eqref)))) + (type $func (sub (func (param eqref)))) (type $sub-func (func_subtype (param eqref) $func)) ;; CHECK: (type $sub-func-refined (sub $func (func (param anyref)))) (type $sub-func-refined (func_subtype (param anyref) $func)) @@ -776,8 +776,8 @@ ;; Check that public types are not merged. (module - ;; CHECK: (type $A (func)) - (type $A (func)) ;; public + ;; CHECK: (type $A (sub (func))) + (type $A (sub (func))) ;; public ;; CHECK: (type $B (sub $A (func))) (type $B (func_subtype $A)) ;; public (type $C (func_subtype $B)) ;; private @@ -825,8 +825,8 @@ ;; other way around, causing an assertion failure in type-updating.cpp. (module (rec - ;; CHECK: (type $A (func (param (ref null $A)) (result (ref null $A)))) - (type $A (func (param (ref null $B)) (result (ref null $A)))) + ;; CHECK: (type $A (sub (func (param (ref null $A)) (result (ref null $A))))) + (type $A (sub (func (param (ref null $B)) (result (ref null $A))))) (type $B (func_subtype (param (ref null $A)) (result (ref null $B)) $A)) ) @@ -844,18 +844,18 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct (field (ref $A)))) - - ;; CHECK: (type $A (struct )) - (type $A (struct)) + ;; CHECK-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) (type $B (struct_subtype $A)) + ;; CHECK: (type $X (struct (field (ref $A)))) (type $X (struct (ref $B))) + ;; CHECK: (type $A' (struct )) (type $A' (struct)) ) - ;; CHECK: (type $2 (func)) + ;; CHECK: (type $3 (func)) - ;; CHECK: (func $foo (type $2) - ;; CHECK-NEXT: (local $b (ref null $A)) + ;; CHECK: (func $foo (type $3) + ;; CHECK-NEXT: (local $b (ref null $A')) ;; CHECK-NEXT: (local $x (ref null $X)) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) @@ -872,12 +872,12 @@ ;; $x and $y are structurally identical, but won't be merged because there is ;; a cast to $y. ;; CHECK: (rec - ;; CHECK-NEXT: (type $b (struct (field (ref null $x)))) + ;; CHECK-NEXT: (type $b (sub (struct (field (ref null $x))))) ;; CHECK: (type $b1 (sub $b (struct (field (ref null $y))))) - ;; CHECK: (type $x (struct (field anyref))) - (type $x (struct anyref)) + ;; CHECK: (type $x (sub (struct (field anyref)))) + (type $x (sub (struct anyref))) ;; CHECK: (type $y (sub $x (struct (field anyref)))) (type $y (struct_subtype anyref $x)) @@ -887,7 +887,7 @@ ;; subtype of $b. ;; CHECK: (type $a (struct (field (ref null $y)))) (type $a (struct (ref null $y))) - (type $b (struct (ref null $x))) + (type $b (sub (struct (ref null $x)))) (type $b1 (struct_subtype (ref null $y) $b)) ) @@ -926,16 +926,16 @@ ;; TODO: Investigate why the rec group contains two of the same type below. (module (rec - (type $A (func (result (ref any) (ref $C)))) ;; CHECK: (rec - ;; CHECK-NEXT: (type $B (func)) - (type $B (func)) - (type $C (sub $B (func))) - ;; CHECK: (type $1 (func (result (ref any) (ref $B)))) + ;; CHECK-NEXT: (type $B (sub (func))) - ;; CHECK: (type $2 (func (result (ref any) (ref $B)))) + ;; CHECK: (type $1 (func (result (ref any) (ref $B)))) - ;; CHECK: (type $D (sub final $2 (func (result (ref any) (ref $B))))) + ;; CHECK: (type $A (sub (func (result (ref any) (ref $B))))) + (type $A (sub (func (result (ref any) (ref $C))))) + (type $B (sub (func))) + (type $C (sub $B (func))) + ;; CHECK: (type $D (sub final $A (func (result (ref any) (ref $B))))) (type $D (sub final $A (func (result (ref any) (ref $C))))) ) @@ -961,14 +961,14 @@ ;; was to manually split partitions that end up containing separate type trees. (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $I (struct (field anyref))) + ;; CHECK-NEXT: (type $I (sub (struct (field anyref)))) (type $I (sub (struct (field anyref)))) ;; CHECK: (type $J (sub $I (struct (field eqref)))) (type $J (sub $I (struct (field eqref)))) ;; CHECK: (type $K (sub $J (struct (field i31ref)))) (type $K (sub $J (struct (field i31ref)))) (rec - ;; CHECK: (type $A (struct (field (ref null $A)) (field (ref null $I)))) + ;; CHECK: (type $A (sub (struct (field (ref null $A)) (field (ref null $I))))) (type $A (sub (struct (ref null $A) (ref null $I)))) ;; CHECK: (type $C (sub $A (struct (field (ref null $A)) (field (ref null $K))))) @@ -991,14 +991,14 @@ ;; Same as above, but with some additional types that can be merged. (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $I (struct (field anyref))) + ;; CHECK-NEXT: (type $I (sub (struct (field anyref)))) (type $I (sub (struct (field anyref)))) ;; CHECK: (type $J (sub $I (struct (field eqref)))) (type $J (sub $I (struct (field eqref)))) ;; CHECK: (type $K (sub $J (struct (field i31ref)))) (type $K (sub $J (struct (field i31ref)))) (rec - ;; CHECK: (type $A (struct (field (ref null $A)) (field (ref null $I)))) + ;; CHECK: (type $A (sub (struct (field (ref null $A)) (field (ref null $I))))) (type $A (sub (struct (ref null $A) (ref null $I)))) (type $A' (sub $A (struct (ref null $A) (ref null $I)))) ;; CHECK: (type $C (sub $A (struct (field (ref null $A)) (field (ref null $K))))) @@ -1030,8 +1030,8 @@ ;; Check that a ref.test inhibits merging (ref.cast is already checked above). (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct )) - (type $A (struct)) + ;; CHECK-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; CHECK: (type $B (sub $A (struct ))) (type $B (struct_subtype $A)) @@ -1052,8 +1052,8 @@ ;; Check that a br_on_cast inhibits merging. (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct )) - (type $A (struct)) + ;; CHECK-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; CHECK: (type $B (sub $A (struct ))) (type $B (struct_subtype $A)) @@ -1099,8 +1099,8 @@ ;; Check that a call_indirect inhibits merging. (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (func)) - (type $A (func)) + ;; CHECK-NEXT: (type $A (sub (func))) + (type $A (sub (func))) ;; CHECK: (type $B (sub $A (func))) (type $B (func_subtype $A)) diff --git a/test/lit/passes/type-refining-isorecursive.wast b/test/lit/passes/type-refining-isorecursive.wast index 628282f46..ecc9b1f90 100644 --- a/test/lit/passes/type-refining-isorecursive.wast +++ b/test/lit/passes/type-refining-isorecursive.wast @@ -5,11 +5,11 @@ ;; The types should be refined to a set of three mutually recursive types. ;; CHECK: (rec - ;; CHECK-NEXT: (type $2 (struct (field nullexternref) (field (ref $0)))) + ;; CHECK-NEXT: (type $2 (sub (struct (field nullexternref) (field (ref $0))))) - ;; CHECK: (type $1 (struct (field nullfuncref) (field (ref $2)))) + ;; CHECK: (type $1 (sub (struct (field nullfuncref) (field (ref $2))))) - ;; CHECK: (type $0 (struct (field nullref) (field (ref $1)))) + ;; CHECK: (type $0 (sub (struct (field nullref) (field (ref $1))))) (type $0 (struct_subtype nullref anyref data)) (type $1 (struct_subtype nullfuncref anyref data)) (type $2 (struct_subtype nullexternref anyref data)) @@ -64,13 +64,13 @@ ;; correctly. ;; CHECK: (rec - ;; CHECK-NEXT: (type $0 (struct (field (ref null $all)) (field (ref $0)))) + ;; CHECK-NEXT: (type $0 (sub (struct (field (ref null $all)) (field (ref $0))))) ;; CHECK: (type $1 (sub $0 (struct (field (ref null $all)) (field (ref $0))))) ;; CHECK: (type $2 (sub $1 (struct (field (ref null $all)) (field (ref $0))))) - ;; CHECK: (type $all (struct (field i32) (field (ref $0)) (field (ref $1)) (field (ref $2)))) + ;; CHECK: (type $all (sub (struct (field i32) (field (ref $0)) (field (ref $1)) (field (ref $2))))) (type $all (struct_subtype i32 anyref anyref anyref data)) (type $0 (struct_subtype anyref anyref data)) diff --git a/test/lit/passes/type-refining.wast b/test/lit/passes/type-refining.wast index 8dab9bc7e..6d0c2257a 100644 --- a/test/lit/passes/type-refining.wast +++ b/test/lit/passes/type-refining.wast @@ -6,7 +6,7 @@ ;; write of the same type, and the last a write of a subtype, which will allow ;; us to specialize that one. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut anyref)) (field (mut (ref i31))) (field (mut (ref i31))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut anyref)) (field (mut (ref i31))) (field (mut (ref i31)))))) (type $struct (struct_subtype (field (mut anyref)) (field (mut (ref i31))) (field (mut anyref)) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -55,7 +55,7 @@ ;; default value being null. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut i31ref)))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut i31ref))))) (type $struct (struct_subtype (field (mut anyref)) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -90,7 +90,7 @@ (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref $struct)))))) (type $struct (struct_subtype (field (mut structref)) data)) ;; CHECK: (type $child-B (sub $struct (struct (field (mut (ref $struct)))))) @@ -131,7 +131,7 @@ (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref $child-A))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref $child-A)))))) (type $struct (struct_subtype (field (mut structref)) data)) ;; CHECK: (type $child-A (sub $struct (struct (field (mut (ref $child-A)))))) @@ -184,7 +184,7 @@ ;; $struct but not to $child. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref $struct)))))) (type $struct (struct_subtype (field (mut structref)) data)) ;; CHECK: (type $child (sub $struct (struct (field (mut (ref $struct)))))) @@ -218,7 +218,7 @@ ;; As above, but both writes are of $child, so we can optimize. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref $child))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref $child)))))) (type $struct (struct_subtype (field (mut structref)) data)) ;; CHECK: (type $child (sub $struct (struct (field (mut (ref $child)))))) @@ -255,7 +255,7 @@ ;; child's. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref $struct)))))) (type $struct (struct_subtype (field (mut structref)) data)) ;; CHECK: (type $child (sub $struct (struct (field (mut (ref $struct)))))) @@ -300,7 +300,7 @@ ;; testcase after this.) ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (ref $struct)))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (ref $struct))))) (type $struct (struct_subtype (field structref) data)) ;; CHECK: (type $child (sub $struct (struct (field (ref $child))))) @@ -340,7 +340,7 @@ ;; improvement!) ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref $struct)))))) (type $struct (struct_subtype (field (mut structref)) data)) ;; CHECK: (type $child (sub $struct (struct (field (mut (ref $struct)))))) @@ -380,7 +380,7 @@ ;; to $child. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref $struct)))))) (type $struct (struct_subtype (field (mut structref)) data)) ;; CHECK: (type $child (sub $struct (struct (field (mut (ref $struct))) (field (mut (ref $child)))))) @@ -421,7 +421,7 @@ ;; the old type). ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref $struct)))))) (type $struct (struct_subtype (field (mut structref)) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -455,12 +455,12 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field (ref $Y)))) + ;; CHECK-NEXT: (type $A (sub (struct (field (ref $Y))))) ;; CHECK: (type $B (sub $A (struct (field (ref $Y))))) - ;; CHECK: (type $X (struct )) - (type $X (struct)) + ;; CHECK: (type $X (sub (struct ))) + (type $X (sub (struct))) ;; CHECK: (type $Y (sub $X (struct ))) (type $Y (struct_subtype $X)) @@ -509,13 +509,13 @@ (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $X (struct )) - (type $X (struct)) + ;; CHECK-NEXT: (type $X (sub (struct ))) + (type $X (sub (struct))) ;; CHECK: (type $Y (sub $X (struct ))) (type $Y (struct_subtype $X)) - ;; CHECK: (type $A (struct (field (ref $X)))) + ;; CHECK: (type $A (sub (struct (field (ref $X))))) (type $A (struct_subtype (field (ref $X)) data)) ;; CHECK: (type $B (sub $A (struct (field (ref $X))))) @@ -542,12 +542,12 @@ ) (module - ;; CHECK: (type $X (struct )) - (type $X (struct)) + ;; CHECK: (type $X (sub (struct ))) + (type $X (sub (struct))) ;; CHECK: (type $1 (func)) - ;; CHECK: (type $A (struct (field (ref $X)))) + ;; CHECK: (type $A (sub (struct (field (ref $X))))) ;; CHECK: (type $Y (sub $X (struct ))) (type $Y (struct_subtype $X)) @@ -582,7 +582,7 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref null $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref null $struct)))))) (type $struct (struct_subtype (field (mut (ref null struct))) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -616,7 +616,7 @@ ;; refine the field to nullable $struct. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref null $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref null $struct)))))) (type $struct (struct_subtype (field (mut (ref null struct))) data)) ;; CHECK: (type $child (sub $struct (struct (field (mut (ref null $struct)))))) (type $child (struct_subtype (field (mut (ref null struct))) $struct)) @@ -649,7 +649,7 @@ ;; As above, but now the null is in a parent. The result should be the same. ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref null $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref null $struct)))))) (type $struct (struct_subtype (field (mut (ref null struct))) data)) ;; CHECK: (type $child (sub $struct (struct (field (mut (ref null $struct)))))) (type $child (struct_subtype (field (mut (ref null struct))) $struct)) @@ -680,7 +680,7 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut nullref)))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut nullref))))) (type $struct (struct_subtype (field (mut (ref null struct))) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -701,7 +701,7 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref null $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref null $struct)))))) (type $struct (struct_subtype (field (mut (ref null struct))) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -730,7 +730,7 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref null $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref null $struct)))))) (type $struct (struct_subtype (field (mut (ref null struct))) data)) ;; CHECK: (type $1 (func (param (ref $struct)))) @@ -763,7 +763,7 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $struct (struct (field (mut (ref null $child))) (field (mut (ref null $struct))))) + ;; CHECK-NEXT: (type $struct (sub (struct (field (mut (ref null $child))) (field (mut (ref null $struct)))))) (type $struct (struct_subtype (field (mut (ref null struct))) (field (mut (ref null struct))) data)) ;; CHECK: (type $child (sub $struct (struct (field (mut (ref null $child))) (field (mut (ref null $struct)))))) @@ -819,13 +819,13 @@ ;; -> Leaf2-Outer[Leaf2-Inner] ;; CHECK: (rec - ;; CHECK-NEXT: (type $Root-Inner (struct )) - (type $Root-Inner (struct)) + ;; CHECK-NEXT: (type $Root-Inner (sub (struct ))) + (type $Root-Inner (sub (struct))) ;; CHECK: (type $Leaf1-Inner (sub $Root-Inner (struct (field i32)))) (type $Leaf1-Inner (struct_subtype (field i32) $Root-Inner)) - ;; CHECK: (type $Root-Outer (struct (field (ref $Leaf2-Inner)))) + ;; CHECK: (type $Root-Outer (sub (struct (field (ref $Leaf2-Inner))))) ;; CHECK: (type $Leaf1-Outer (sub $Root-Outer (struct (field (ref $Leaf2-Inner))))) @@ -897,7 +897,7 @@ ) (module - ;; CHECK: (type $A (struct (field (mut (ref null $A))))) + ;; CHECK: (type $A (sub (struct (field (mut (ref null $A)))))) (type $A (struct_subtype (field (mut (ref null $A))) data)) ;; CHECK: (type $1 (func (param (ref $A) (ref null $A)))) @@ -961,7 +961,7 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field (ref null $A)))) + ;; CHECK-NEXT: (type $A (sub (struct (field (ref null $A))))) (type $A (struct_subtype (field (ref null $A)) data)) ;; CHECK: (type $B (sub $A (struct (field (ref null $B))))) (type $B (struct_subtype (field (ref null $A)) $A)) @@ -1012,7 +1012,7 @@ (module ;; CHECK: (rec - ;; CHECK-NEXT: (type $A (struct (field (mut (ref $A))))) + ;; CHECK-NEXT: (type $A (sub (struct (field (mut (ref $A)))))) (type $A (struct_subtype (field (mut (ref null $A))) data)) ;; CHECK: (type $1 (func (param (ref $A) (ref null $A)))) diff --git a/test/lit/passes/type-ssa.wast b/test/lit/passes/type-ssa.wast index f9fb5eb26..ae5b2c532 100644 --- a/test/lit/passes/type-ssa.wast +++ b/test/lit/passes/type-ssa.wast @@ -2,12 +2,9 @@ ;; RUN: foreach %s %t wasm-opt --type-ssa -all -S -o - | filecheck %s -;; Test in both isorecursive and nominal modes to make sure we create the new -;; types properly in both. - ;; Every struct.new here should get a new type. (module - ;; CHECK: (type $struct (struct (field i32))) + ;; CHECK: (type $struct (sub (struct (field i32)))) (type $struct (struct_subtype (field i32) data)) ;; CHECK: (type $1 (func)) @@ -77,7 +74,7 @@ ;; The same module as before, except that now the type is final, so we cannot ;; create any subtypes. (module - ;; CHECK: (type $struct (sub final (struct (field i32)))) + ;; CHECK: (type $struct (struct (field i32))) (type $struct (sub final (struct (field i32)))) ;; CHECK: (type $1 (func)) @@ -138,7 +135,7 @@ ;; CHECK: (type $0 (func (param anyref arrayref))) - ;; CHECK: (type $struct (struct (field anyref))) + ;; CHECK: (type $struct (sub (struct (field anyref)))) (type $struct (struct_subtype (field (ref null any)) data)) ;; CHECK: (rec @@ -208,13 +205,13 @@ ) (module - ;; CHECK: (type $array (array (mut anyref))) - (type $array (array (mut (ref null any)))) + ;; CHECK: (type $array (sub (array (mut anyref)))) + (type $array (sub (array (mut (ref null any))))) ;; CHECK: (type $1 (func (param (ref i31) anyref))) - ;; CHECK: (type $array-func (array (mut funcref))) - (type $array-func (array (mut funcref))) + ;; CHECK: (type $array-func (sub (array (mut funcref)))) + (type $array-func (sub (array (mut funcref)))) (elem func $array.new) @@ -369,15 +366,15 @@ ;; turn into a simple Literal). (We do optimize $empty and generate $empty$1, ;; but that is not important here.) (module - ;; CHECK: (type $empty (struct )) - (type $empty (struct)) + ;; CHECK: (type $empty (sub (struct ))) + (type $empty (sub (struct))) ;; CHECK: (type $empty$1 (sub $empty (struct ))) ;; CHECK: (type $2 (func (param anyref))) - ;; CHECK: (type $struct (struct (field externref) (field anyref) (field externref))) - (type $struct (struct externref anyref externref)) + ;; CHECK: (type $struct (sub (struct (field externref) (field anyref) (field externref)))) + (type $struct (sub (struct externref anyref externref))) ;; CHECK: (global $g (mut anyref) (struct.new_default $empty$1)) (global $g (mut anyref) (struct.new $empty)) @@ -422,8 +419,8 @@ ) (module - ;; CHECK: (type $array (array (mut f32))) - (type $array (array (mut f32))) + ;; CHECK: (type $array (sub (array (mut f32)))) + (type $array (sub (array (mut f32)))) ;; CHECK: (type $subarray (sub $array (array (mut f32)))) (type $subarray (array_subtype (mut f32) $array)) @@ -455,8 +452,8 @@ ) (module - ;; CHECK: (type $A (struct )) - (type $A (struct )) + ;; CHECK: (type $A (sub (struct ))) + (type $A (sub (struct))) ;; CHECK: (type $A$1 (sub $A (struct ))) diff --git a/test/lit/passes/type-ssa_and_merging.wast b/test/lit/passes/type-ssa_and_merging.wast index 63c0b86f2..46129e37f 100644 --- a/test/lit/passes/type-ssa_and_merging.wast +++ b/test/lit/passes/type-ssa_and_merging.wast @@ -10,13 +10,13 @@ ;; NOP: (rec ;; NOP-NEXT: (type $0 (func (param (ref $A)) (result i32))) - ;; NOP: (type $A (struct (field i32))) + ;; NOP: (type $A (sub (struct (field i32)))) ;; YES: (type $0 (func (result i32))) ;; YES: (rec ;; YES-NEXT: (type $1 (func (param (ref $A)))) - ;; YES: (type $A (struct )) + ;; YES: (type $A (sub (struct ))) (type $A (struct_subtype (field (mut i32)) data)) ;; NOP: (type $2 (func (result i32))) diff --git a/test/lit/recursive-types.wast b/test/lit/recursive-types.wast index fc3d83dc3..46b6d3c10 100644 --- a/test/lit/recursive-types.wast +++ b/test/lit/recursive-types.wast @@ -11,8 +11,8 @@ ;; CHECK: (type $type$0 (func (param (ref null $type$0)) (result (ref null $type$0)))) ;; CHECK: (rec - ;; CHECK-NEXT: (type $f3 (func (param (ref null $type$2)) (result (ref null $f3)))) - (type $f3 (func (param (ref null 4)) (result (ref null 3)))) + ;; CHECK-NEXT: (type $f3 (sub (func (param (ref null $type$2)) (result (ref null $f3))))) + (type $f3 (sub (func (param (ref null 4)) (result (ref null 3))))) (type (func_subtype (param (ref null 3)) (result (ref null 4)) $f3)) ) diff --git a/test/lit/strings.wast b/test/lit/strings.wast index fa9e7b712..fb86c484d 100644 --- a/test/lit/strings.wast +++ b/test/lit/strings.wast @@ -20,9 +20,9 @@ ;; CHECK: (type $2 (func (param stringref stringview_wtf8 stringview_wtf16 stringview_iter))) - ;; CHECK: (type $array (array (mut i8))) + ;; CHECK: (type $array (sub (array (mut i8)))) (type $array (array_subtype (mut i8) data)) - ;; CHECK: (type $array16 (array (mut i16))) + ;; CHECK: (type $array16 (sub (array (mut i16)))) (type $array16 (array_subtype (mut i16) data)) ;; CHECK: (type $5 (func (param stringref stringview_wtf8 stringview_wtf16 stringview_iter stringref stringview_wtf8 stringview_wtf16 stringview_iter (ref string) (ref stringview_wtf8) (ref stringview_wtf16) (ref stringview_iter)))) diff --git a/test/lit/subtype-chain.wast b/test/lit/subtype-chain.wast index 0dabd0f2f..882aadae6 100644 --- a/test/lit/subtype-chain.wast +++ b/test/lit/subtype-chain.wast @@ -7,8 +7,8 @@ ;; types. (module - ;; CHECK: (type $root (struct )) - (type $root (struct)) + ;; CHECK: (type $root (sub (struct ))) + (type $root (sub (struct))) ;; CHECK: (type $trunk (sub $root (struct (field i32)))) (type $trunk (struct_subtype i32 $root)) diff --git a/test/lit/subtypes.wast b/test/lit/subtypes.wast index 17ccb0ba2..20f605b5f 100644 --- a/test/lit/subtypes.wast +++ b/test/lit/subtypes.wast @@ -6,24 +6,24 @@ (module (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $super-struct (struct (field i32))) - (type $super-struct (struct i32)) + ;; CHECK-NEXT: (type $super-struct (sub (struct (field i32)))) + (type $super-struct (sub (struct i32))) ;; CHECK: (type $sub-struct (sub $super-struct (struct (field i32) (field i64)))) (type $sub-struct (struct_subtype i32 i64 $super-struct)) ) (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $super-array (array (ref $super-struct))) - (type $super-array (array (ref $super-struct))) + ;; CHECK-NEXT: (type $super-array (sub (array (ref $super-struct)))) + (type $super-array (sub (array (ref $super-struct)))) ;; CHECK: (type $sub-array (sub $super-array (array (ref $sub-struct)))) (type $sub-array (array_subtype (ref $sub-struct) $super-array)) ) (rec ;; CHECK: (rec - ;; CHECK-NEXT: (type $super-func (func (param (ref $sub-array)) (result (ref $super-array)))) - (type $super-func (func (param (ref $sub-array)) (result (ref $super-array)))) + ;; CHECK-NEXT: (type $super-func (sub (func (param (ref $sub-array)) (result (ref $super-array))))) + (type $super-func (sub (func (param (ref $sub-array)) (result (ref $super-array))))) ;; CHECK: (type $sub-func (sub $super-func (func (param (ref $super-array)) (result (ref $sub-array))))) (type $sub-func (func_subtype (param (ref $super-array)) (result (ref $sub-array)) $super-func)) ) diff --git a/test/lit/tail-call.wast b/test/lit/tail-call.wast index a2f96eeba..873d79034 100644 --- a/test/lit/tail-call.wast +++ b/test/lit/tail-call.wast @@ -33,8 +33,8 @@ ;; Check GC types and subtyping (module - ;; CHECK: (type $A (struct (field i32))) - (type $A (struct i32)) + ;; CHECK: (type $A (sub (struct (field i32)))) + (type $A (sub (struct i32))) ;; CHECK: (type $B (sub $A (struct (field i32) (field i32)))) (type $B (struct_subtype i32 i32 $A)) diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast index ddf35edcf..eb8d4f100 100644 --- a/test/lit/wat-kitchen-sink.wast +++ b/test/lit/wat-kitchen-sink.wast @@ -9,7 +9,7 @@ (type $ret2 (func (result i32 i32))) (rec - ;; CHECK: (type $void (func)) + ;; CHECK: (type $void (sub (func))) ;; CHECK: (type $pair (struct (field (mut i32)) (field (mut i64)))) @@ -33,7 +33,7 @@ ;; CHECK: (type $packed-i16 (array (mut i16))) - ;; CHECK: (type $many (func (param i32 i64 f32 f64) (result anyref (ref func)))) + ;; CHECK: (type $many (sub (func (param i32 i64 f32 f64) (result anyref (ref func))))) ;; CHECK: (type $14 (func (param i32 i32))) @@ -137,16 +137,16 @@ (type $packed-i16 (array (mut i16))) (rec - (type $void (func)) + (type $void (sub open (func))) ) - ;; CHECK: (type $subvoid (sub $void (func))) + ;; CHECK: (type $subvoid (sub final $void (func))) (type $subvoid (sub $void (func))) - (type $many (func (param $x i32) (param i64 f32) (param) (param $y f64) - (result anyref (ref func)))) + (type $many (sub open (func (param $x i32) (param i64 f32) (param) (param $y f64) + (result anyref (ref func))))) - ;; CHECK: (type $submany (sub $many (func (param i32 i64 f32 f64) (result anyref (ref func))))) + ;; CHECK: (type $submany (sub final $many (func (param i32 i64 f32 f64) (result anyref (ref func))))) (type $submany (sub $many (func (param i32 i64 f32 f64) (result anyref (ref func))))) ;; globals @@ -168,7 +168,7 @@ ;; CHECK: (import "mod" "" (global $gimport$1 (ref null $many))) - ;; CHECK: (import "mod" "f5" (func $fimport$1 (type $void))) + ;; CHECK: (import "mod" "f5" (func $fimport$1 (type $func.0))) ;; CHECK: (global $2 (mut i32) (i32.const 0)) diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt index 2f6fd3d87..439515e0d 100644 --- a/test/passes/Oz_fuzz-exec_all-features.txt +++ b/test/passes/Oz_fuzz-exec_all-features.txt @@ -58,7 +58,7 @@ (module (type $bytes (array (mut i8))) (type $void_func (func)) - (type $struct (struct (field (mut i32)))) + (type $struct (sub (struct (field (mut i32))))) (type $3 (func (param i32))) (type $extendedstruct (sub $struct (struct (field (mut i32)) (field f64)))) (type $int_func (func (result i32))) diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index 5c48c4d3f..a693f0098 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -1,5 +1,5 @@ (module - (type $struct (struct (mut i32))) + (type $struct (sub (struct (mut i32)))) (type $extendedstruct (struct_subtype (mut i32) f64 $struct)) (type $bytes (array (mut i8))) diff --git a/test/spec/ref_cast.wast b/test/spec/ref_cast.wast index d68baf45e..1a09a68f3 100644 --- a/test/spec/ref_cast.wast +++ b/test/spec/ref_cast.wast @@ -1,5 +1,5 @@ (module - (type $t0 (struct)) + (type $t0 (sub (struct))) (type $t1 (struct_subtype (field i32) $t0)) (type $t1' (struct_subtype (field i32) $t1)) (type $t2 (struct_subtype (field i32) (field i32) $t1)) diff --git a/test/subtypes.wast b/test/subtypes.wast index 0562d6cb2..0076f7eb3 100644 --- a/test/subtypes.wast +++ b/test/subtypes.wast @@ -3,13 +3,13 @@ ;; Arrays (type $vector-i32 (array i32)) - (type $vector-any (array (ref any))) + (type $vector-any (sub (array (ref any)))) (type $vector-i31 (array_subtype (ref i31) $vector-any)) ;; Structs - (type $struct-any (struct + (type $struct-any (sub (struct (field (ref any)) - )) + ))) (type $struct-i31 (struct_subtype (field (ref i31)) $struct-any @@ -21,9 +21,9 @@ )) ;; Recursive structs - (type $struct-rec-one (struct + (type $struct-rec-one (sub (struct (field (ref $struct-rec-one)) - )) + ))) (type $struct-rec-two (struct_subtype (field (ref $struct-rec-two)) (field (ref $struct-rec-two)) diff --git a/test/subtypes.wast.from-wast b/test/subtypes.wast.from-wast index 0b6ede8a7..1304c0c31 100644 --- a/test/subtypes.wast.from-wast +++ b/test/subtypes.wast.from-wast @@ -1,11 +1,11 @@ (module - (type $struct-rec-one (struct (field (ref $struct-rec-one)))) + (type $struct-rec-one (sub (struct (field (ref $struct-rec-one))))) (type $struct-rec-two (sub $struct-rec-one (struct (field (ref $struct-rec-two)) (field (ref $struct-rec-two))))) (type $vector-i32 (array i32)) - (type $struct-any (struct (field (ref any)))) + (type $struct-any (sub (struct (field (ref any))))) (type $struct-i31 (sub $struct-any (struct (field (ref i31))))) (type $5 (func (param (ref $vector-i32) (ref null $vector-i32)))) - (type $vector-any (array (ref any))) + (type $vector-any (sub (array (ref any)))) (type $vector-i31 (sub $vector-any (array (ref i31)))) (type $8 (func (param (ref $vector-i31) (ref $vector-any)))) (type $9 (func (param (ref $struct-i31) (ref $struct-any)))) diff --git a/test/subtypes.wast.fromBinary b/test/subtypes.wast.fromBinary index 70fe93e95..6a3ef7345 100644 --- a/test/subtypes.wast.fromBinary +++ b/test/subtypes.wast.fromBinary @@ -1,11 +1,11 @@ (module - (type $struct-rec-one (struct (field (ref $struct-rec-one)))) + (type $struct-rec-one (sub (struct (field (ref $struct-rec-one))))) (type $struct-rec-two (sub $struct-rec-one (struct (field (ref $struct-rec-two)) (field (ref $struct-rec-two))))) (type $vector-i32 (array i32)) - (type $struct-any (struct (field (ref any)))) + (type $struct-any (sub (struct (field (ref any))))) (type $struct-i31 (sub $struct-any (struct (field (ref i31))))) (type $5 (func (param (ref $vector-i32) (ref null $vector-i32)))) - (type $vector-any (array (ref any))) + (type $vector-any (sub (array (ref any)))) (type $vector-i31 (sub $vector-any (array (ref i31)))) (type $8 (func (param (ref $vector-i31) (ref $vector-any)))) (type $9 (func (param (ref $struct-i31) (ref $struct-any)))) diff --git a/test/subtypes.wast.fromBinary.noDebugInfo b/test/subtypes.wast.fromBinary.noDebugInfo index 6776298dd..29e575555 100644 --- a/test/subtypes.wast.fromBinary.noDebugInfo +++ b/test/subtypes.wast.fromBinary.noDebugInfo @@ -1,11 +1,11 @@ (module - (type $0 (struct (field (ref $0)))) + (type $0 (sub (struct (field (ref $0))))) (type $1 (sub $0 (struct (field (ref $1)) (field (ref $1))))) (type $2 (array i32)) - (type $3 (struct (field (ref any)))) + (type $3 (sub (struct (field (ref any))))) (type $4 (sub $3 (struct (field (ref i31))))) (type $5 (func (param (ref $2) (ref null $2)))) - (type $6 (array (ref any))) + (type $6 (sub (array (ref any)))) (type $7 (sub $6 (array (ref i31)))) (type $8 (func (param (ref $7) (ref $6)))) (type $9 (func (param (ref $4) (ref $3)))) |