From c7c892e14b974fbbc68badea7fa3f4262c20e6d1 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 15 Jan 2025 13:16:40 -0800 Subject: [PATCH 1/3] Store HeapTypes in Tags Tags in WebAssembly syntactically refer to function heap types, but Binaryen IR was previously storing signatures instead and reconstructing heap types as necessary when emitting binaries. Before WasmGC this was not a problem because the reconstructed types would be the same as the original types, but with WasmGC round tripping function types through Signature could lose information such as the rec group, the declared supertype, and the finality from the original type. Store the original heap type in the IR instead to stop losing this information. Fixes #7219. --- src/binaryen-c.cpp | 8 ++-- src/ir/child-typer.h | 4 +- src/ir/eh-utils.cpp | 2 +- src/ir/module-splitting.cpp | 2 +- src/ir/module-utils.cpp | 4 +- src/ir/possible-contents.cpp | 4 +- src/ir/subtype-exprs.h | 2 +- src/ir/type-updating.cpp | 6 +-- src/parser/contexts.h | 2 +- src/passes/MergeBlocks.cpp | 2 +- src/passes/Print.cpp | 44 ++++++++++------- src/passes/TranslateEH.cpp | 2 +- src/tools/fuzzing/fuzzing.cpp | 6 +-- src/tools/wasm-merge.cpp | 6 +-- src/wasm-builder.h | 4 +- src/wasm.h | 4 +- src/wasm/wasm-binary.cpp | 4 +- src/wasm/wasm-ir-builder.cpp | 6 +-- src/wasm/wasm-validator.cpp | 22 ++++----- src/wasm/wasm.cpp | 11 ++--- test/binaryen.js/exception-handling.js.txt | 2 +- test/binaryen.js/kitchen-sink.js.txt | 10 ++-- test/binaryen.js/tag.js.txt | 6 +-- test/br_to_try.wasm.fromBinary | 2 +- test/break-within-catch.wasm.fromBinary | 2 +- test/example/c-api-kitchen-sink.txt | 2 +- test/example/module-splitting.txt | 12 ++--- test/lit/basic/exception-handling-legacy.wast | 30 ++++++------ test/lit/basic/exception-handling.wast | 30 ++++++------ test/lit/basic/extra-branch-values.wast | 8 ++-- test/lit/basic/pop-fixup.wast | 4 +- test/lit/basic/reference-types.wast | 6 +-- test/lit/basic/tags.wast | 48 +++++++++---------- .../lit/basic/typed_continuations_resume.wast | 6 +-- .../basic/typed_continuations_suspend.wast | 6 +-- test/lit/control-flow-input.wast | 2 +- test/lit/gc-eh-legacy.wast | 2 +- test/lit/merge/fusing.wat | 2 +- test/lit/merge/names.wat | 8 ++-- test/lit/merge/renamings.wat | 10 ++-- .../lit/passes/coalesce-locals-eh-legacy.wast | 4 +- test/lit/passes/coalesce-locals-eh.wast | 4 +- test/lit/passes/code-folding-eh-legacy.wast | 2 +- test/lit/passes/code-folding-eh.wast | 2 +- test/lit/passes/code-pushing-eh-legacy.wast | 2 +- test/lit/passes/code-pushing-eh.wast | 2 +- test/lit/passes/dce-eh-legacy.wast | 6 +-- test/lit/passes/dce-eh.wast | 4 +- test/lit/passes/flatten-eh-legacy.wast | 4 +- test/lit/passes/global-effects-eh-legacy.wast | 4 +- test/lit/passes/global-effects.wast | 4 +- test/lit/passes/gto-mutability.wast | 4 +- test/lit/passes/gufa-eh.wast | 2 +- test/lit/passes/gufa-refs.wast | 10 ++-- test/lit/passes/gufa-tags.wast | 4 +- test/lit/passes/heap-store-optimization.wast | 2 +- test/lit/passes/heap2local.wast | 2 +- test/lit/passes/inlining-eh-legacy.wast | 2 +- .../passes/instrument-locals-eh-legacy.wast | 2 +- test/lit/passes/local-subtyping.wast | 2 +- test/lit/passes/merge-blocks-eh.wast | 6 +-- test/lit/passes/once-reduction.wast | 2 +- .../optimize-instructions-eh-legacy.wast | 2 +- .../optimize-instructions-iit-eh-legacy.wast | 2 +- test/lit/passes/poppify.wast | 2 +- test/lit/passes/remove-unused-brs-eh.wast | 10 ++-- .../passes/remove-unused-names-eh-legacy.wast | 2 +- test/lit/passes/rse-eh-legacy.wast | 4 +- test/lit/passes/rse-eh.wast | 4 +- test/lit/passes/signature-pruning.wast | 28 +++++------ .../lit/passes/simplify-locals-eh-legacy.wast | 2 +- test/lit/passes/simplify-locals-eh.wast | 2 +- test/lit/passes/stack-ir-eh-legacy.wast | 2 +- test/lit/passes/stack-ir-eh.wast | 2 +- .../passes/stack-ir-roundtrip-eh-legacy.wast | 2 +- test/lit/passes/translate-to-exnref.wast | 12 ++--- test/lit/passes/type-refining.wast | 4 +- test/lit/passes/unsubtyping.wast | 20 ++++---- test/lit/passes/vacuum-eh-legacy.wast | 4 +- test/lit/passes/vacuum-eh.wast | 4 +- test/lit/passes/vacuum-tnh.wast | 4 +- test/lit/wat-kitchen-sink.wast | 16 +++---- test/metadce/rooted-export.wast.dced | 2 +- test/metadce/tag.wast.dced | 4 +- test/passes/dwarf_with_exceptions.bin.txt | 4 +- test/passes/metrics_all-features.txt | 4 +- ...inify-imports-and-exports_all-features.txt | 4 +- test/passes/minify-imports_all-features.txt | 4 +- ...unused-names_merge-blocks_all-features.txt | 2 +- ...nfunction-module-elements_all-features.txt | 2 +- test/try-delegate.wasm.fromBinary | 2 +- 91 files changed, 285 insertions(+), 290 deletions(-) diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index fa834d2686c..8eb73b4c259 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -4770,7 +4770,7 @@ BinaryenTagRef BinaryenAddTag(BinaryenModuleRef module, BinaryenType results) { auto* ret = new Tag(); ret->setExplicitName(name); - ret->sig = Signature(Type(params), Type(results)); + ret->type = Signature(Type(params), Type(results)); ((Module*)module)->addTag(ret); return ret; } @@ -4874,7 +4874,7 @@ void BinaryenAddTagImport(BinaryenModuleRef module, tag->name = internalName; tag->module = externalModuleName; tag->base = externalBaseName; - tag->sig = Signature(Type(params), Type(results)); + tag->type = Signature(Type(params), Type(results)); ((Module*)module)->addTag(std::move(tag)); } else { // already exists so just set module and base @@ -5838,11 +5838,11 @@ const char* BinaryenTagGetName(BinaryenTagRef tag) { return ((Tag*)tag)->name.str.data(); } BinaryenType BinaryenTagGetParams(BinaryenTagRef tag) { - return ((Tag*)tag)->sig.params.getID(); + return ((Tag*)tag)->params().getID(); } BinaryenType BinaryenTagGetResults(BinaryenTagRef tag) { - return ((Tag*)tag)->sig.results.getID(); + return ((Tag*)tag)->results().getID(); } // diff --git a/src/ir/child-typer.h b/src/ir/child-typer.h index aac7744ab45..685c171d016 100644 --- a/src/ir/child-typer.h +++ b/src/ir/child-typer.h @@ -789,7 +789,7 @@ template struct ChildTyper : OverriddenVisitor { void visitTryTable(TryTable* curr) { note(&curr->body, curr->type); } void visitThrow(Throw* curr) { - auto type = wasm.getTag(curr->tag)->sig.params; + auto type = wasm.getTag(curr->tag)->params(); assert(curr->operands.size() == type.size()); for (size_t i = 0; i < type.size(); ++i) { note(&curr->operands[i], type[i]); @@ -1113,7 +1113,7 @@ template struct ChildTyper : OverriddenVisitor { } void visitSuspend(Suspend* curr) { - auto params = wasm.getTag(curr->tag)->sig.params; + auto params = wasm.getTag(curr->tag)->params(); assert(params.size() == curr->operands.size()); for (size_t i = 0; i < params.size(); ++i) { note(&curr->operands[i], params[i]); diff --git a/src/ir/eh-utils.cpp b/src/ir/eh-utils.cpp index 6d65de4ad1c..43fd1627d31 100644 --- a/src/ir/eh-utils.cpp +++ b/src/ir/eh-utils.cpp @@ -111,7 +111,7 @@ void handleBlockNestedPop(Try* try_, Function* func, Module& wasm) { for (Index i = 0; i < try_->catchTags.size(); i++) { Name tagName = try_->catchTags[i]; auto* tag = wasm.getTag(tagName); - if (tag->sig.params == Type::none) { + if (tag->params() == Type::none) { continue; } diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp index a7ee96fa28f..bcf0b344201 100644 --- a/src/ir/module-splitting.cpp +++ b/src/ir/module-splitting.cpp @@ -883,7 +883,7 @@ void ModuleSplitter::shareImportableItems() { for (auto& tag : primary.tags) { auto secondaryTag = std::make_unique(); - secondaryTag->sig = tag->sig; + secondaryTag->type = tag->type; makeImportExport(*tag, *secondaryTag, "tag", ExternalKind::Tag); secondary.addTag(std::move(secondaryTag)); } diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index 431e33cc6e7..89c1503399f 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -125,7 +125,7 @@ Tag* copyTag(Tag* tag, Module& out) { auto* ret = new Tag(); ret->name = tag->name; ret->hasExplicitName = tag->hasExplicitName; - ret->sig = tag->sig; + ret->type = tag->type; ret->module = tag->module; ret->base = tag->base; out.addTag(ret); @@ -474,7 +474,7 @@ InsertOrderedMap collectHeapTypeInfo( info.note(curr->type); } for (auto& curr : wasm.tags) { - info.note(curr->sig); + info.note(curr->type); } for (auto& curr : wasm.tables) { info.note(curr->type); diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index 49c8ee17615..0bc03160ed7 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -1151,7 +1151,7 @@ struct InfoCollector auto tag = curr->catchTags[tagIndex]; auto* body = curr->catchBodies[tagIndex]; - auto params = getModule()->getTag(tag)->sig.params; + auto params = getModule()->getTag(tag)->params(); if (params.size() == 0) { continue; } @@ -1189,7 +1189,7 @@ struct InfoCollector Index exnrefIndex = 0; if (tag.is()) { - auto params = getModule()->getTag(tag)->sig.params; + auto params = getModule()->getTag(tag)->params(); for (Index i = 0; i < params.size(); i++) { if (isRelevant(params[i])) { diff --git a/src/ir/subtype-exprs.h b/src/ir/subtype-exprs.h index b1e40b7457f..ba5640eff7f 100644 --- a/src/ir/subtype-exprs.h +++ b/src/ir/subtype-exprs.h @@ -257,7 +257,7 @@ struct SubtypingDiscoverer : public OverriddenVisitor { } } void visitThrow(Throw* curr) { - Type params = self()->getModule()->getTag(curr->tag)->sig.params; + Type params = self()->getModule()->getTag(curr->tag)->params(); assert(params.size() == curr->operands.size()); for (size_t i = 0, size = curr->operands.size(); i < size; ++i) { self()->noteSubtype(curr->operands[i], params[i]); diff --git a/src/ir/type-updating.cpp b/src/ir/type-updating.cpp index 8b74ebfcd5d..b90d8eb8790 100644 --- a/src/ir/type-updating.cpp +++ b/src/ir/type-updating.cpp @@ -225,10 +225,6 @@ void GlobalTypeRewriter::mapTypes(const TypeMap& oldToNewTypes) { return type; } - Signature getNew(Signature sig) { - return Signature(getNew(sig.params), getNew(sig.results)); - } - void visitExpression(Expression* curr) { // local.get and local.tee are special in that their type is tied to the // type of the local in the function, which is tied to the signature. That @@ -304,7 +300,7 @@ void GlobalTypeRewriter::mapTypes(const TypeMap& oldToNewTypes) { global->type = updater.getNew(global->type); } for (auto& tag : wasm.tags) { - tag->sig = updater.getNew(tag->sig); + tag->type = updater.getNew(tag->type); } } diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 1c25e881f7c..c2e6eebf102 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1372,7 +1372,7 @@ struct ParseModuleTypesCtx : TypeParserCtx, if (!use.type.isSignature()) { return in.err(pos, "tag type must be a signature"); } - t->sig = use.type.getSignature(); + t->type = use.type; return Ok{}; } }; diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp index e0c5e575a37..3013f67ac9b 100644 --- a/src/passes/MergeBlocks.cpp +++ b/src/passes/MergeBlocks.cpp @@ -144,7 +144,7 @@ struct ProblemFinder // make more sense in TupleOptimization though as it would need // to track uses of parts of a tuple. if (!tryy->catchTags[i] || - getModule()->getTag(tryy->catchTags[i])->sig.params.size() == 0) { + getModule()->getTag(tryy->catchTags[i])->params().size() == 0) { // There must be a ref here, otherwise there is no value being sent // at all, and we should not be running ProblemFinder at all. assert(tryy->catchRefs[i]); diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index abacb86052c..e9f8509fef6 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -413,6 +413,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor { void visitTag(Tag* curr); void visitImportedTag(Tag* curr); void visitDefinedTag(Tag* curr); + void printTagType(HeapType type); void printTableHeader(Table* curr); void visitTable(Table* curr); void visitElementSegment(ElementSegment* curr); @@ -3185,16 +3186,9 @@ void PrintSExpression::visitImportedTag(Tag* curr) { emitImportHeader(curr); o << "(tag "; curr->name.print(o); - if (curr->sig.params != Type::none) { - o << maybeSpace; - printParamType(curr->sig.params); - } - if (curr->sig.results != Type::none) { - o << maybeSpace; - printResultType(curr->sig.results); - } - o << "))"; - o << maybeNewLine; + o << maybeSpace; + printTagType(curr->type); + o << "))" << maybeNewLine; } void PrintSExpression::visitDefinedTag(Tag* curr) { @@ -3202,15 +3196,31 @@ void PrintSExpression::visitDefinedTag(Tag* curr) { o << '('; printMedium(o, "tag "); curr->name.print(o); - if (curr->sig.params != Type::none) { - o << maybeSpace; - printParamType(curr->sig.params); + o << maybeSpace; + printTagType(curr->type); + o << ')' << maybeNewLine; +} + +void PrintSExpression::printTagType(HeapType type) { + o << "(type "; + printHeapType(type); + o << ')'; + if (auto params = type.getSignature().params; params != Type::none) { + o << maybeSpace << "(param"; + for (auto t : params) { + o << ' '; + printType(t); + } + o << ')'; } - if (curr->sig.results != Type::none) { - o << maybeSpace; - printResultType(curr->sig.results); + if (auto results = type.getSignature().results; results != Type::none) { + o << maybeSpace << "(result"; + for (auto t : results) { + o << ' '; + printType(t); + } + o << ')'; } - o << ")" << maybeNewLine; } void PrintSExpression::printTableHeader(Table* curr) { diff --git a/src/passes/TranslateEH.cpp b/src/passes/TranslateEH.cpp index a3411cda967..7e13ee53179 100644 --- a/src/passes/TranslateEH.cpp +++ b/src/passes/TranslateEH.cpp @@ -596,7 +596,7 @@ struct TranslateToExnref : public WalkerPass> { auto* catchBody = curr->catchBodies[i]; Type tagType = Type::none; if (tryTable->catchTags[i]) { - tagType = wasm->getTag(tryTable->catchTags[i])->sig.params; + tagType = wasm->getTag(tryTable->catchTags[i])->params(); } // This is to be the body of the next(outer) level block diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 28f7a29dbc6..50191045fed 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -2177,7 +2177,7 @@ Expression* TranslateToFuzzReader::makeTry(Type type) { // Catch bodies (aside from a catch-all) begin with a pop. Expression* prefix = nullptr; if (i < numTags) { - auto tagType = wasm.getTag(catchTags[i])->sig.params; + auto tagType = wasm.getTag(catchTags[i])->params(); if (tagType != Type::none) { auto* pop = builder.makePop(tagType); // Capture the pop in a local, so that it can be used later. @@ -2223,7 +2223,7 @@ Expression* TranslateToFuzzReader::makeTryTable(Type type) { // Look for a specific tag. auto& tag = pick(wasm.tags); tagName = tag->name; - tagType = tag->sig.params; + tagType = tag->params(); } else { // Add a catch_all at the end, some of the time (but all of the time if we // have nothing else). @@ -4793,7 +4793,7 @@ Expression* TranslateToFuzzReader::makeThrow(Type type) { addTag(); } auto* tag = pick(wasm.tags).get(); - auto tagType = tag->sig.params; + auto tagType = tag->params(); std::vector operands; for (auto t : tagType) { operands.push_back(make(t)); diff --git a/src/tools/wasm-merge.cpp b/src/tools/wasm-merge.cpp index 3de2283502c..166c875aecd 100644 --- a/src/tools/wasm-merge.cpp +++ b/src/tools/wasm-merge.cpp @@ -525,10 +525,10 @@ void fuseImportsAndExports() { kindModuleExportMaps[ExternalKind::Tag][import->module][import->base]; if (internalName.is()) { auto* export_ = merged.getTag(internalName); - if (HeapType(export_->sig) != HeapType(import->sig)) { + if (export_->type != import->type) { reportTypeMismatch(valid, "tag", import); - std::cerr << "export type " << export_->sig - << " is different from import type " << import->sig << ".\n"; + std::cerr << "export type " << export_->type + << " is different from import type " << import->type << ".\n"; } } }); diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 5201470e17e..0666a489bfe 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -162,10 +162,10 @@ class Builder { return glob; } - static std::unique_ptr makeTag(Name name, Signature sig) { + static std::unique_ptr makeTag(Name name, HeapType type) { auto tag = std::make_unique(); tag->name = name; - tag->sig = sig; + tag->type = type; return tag; } diff --git a/src/wasm.h b/src/wasm.h index 1ce9d9c02b5..e8e60789a46 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2297,7 +2297,9 @@ class Global : public Importable { class Tag : public Importable { public: - Signature sig; + HeapType type; + Type params() { return type.getSignature().params; } + Type results() { return type.getSignature().results; } }; // "Opaque" data, not part of the core wasm spec, that is held in binaries. diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index ca4d935c8a1..0841d4b8093 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -349,7 +349,7 @@ void WasmBinaryWriter::writeImports() { writeImportHeader(tag); o << U32LEB(int32_t(ExternalKind::Tag)); o << uint8_t(0); // Reserved 'attribute' field. Always 0. - o << U32LEB(getTypeIndex(tag->sig)); + o << U32LEB(getTypeIndex(tag->type)); }); ModuleUtils::iterImportedMemories(*wasm, [&](Memory* memory) { writeImportHeader(memory); @@ -854,7 +854,7 @@ void WasmBinaryWriter::writeTags() { o << U32LEB(num); ModuleUtils::iterDefinedTags(*wasm, [&](Tag* tag) { o << uint8_t(0); // Reserved 'attribute' field. Always 0. - o << U32LEB(getTypeIndex(tag->sig)); + o << U32LEB(getTypeIndex(tag->type)); }); finishSection(start); diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp index d85ee040e0d..9371046c304 100644 --- a/src/wasm/wasm-ir-builder.cpp +++ b/src/wasm/wasm-ir-builder.cpp @@ -929,7 +929,7 @@ Result<> IRBuilder::visitCatch(Name tag) { CHECK_ERR(pushScope(ScopeCtx::makeCatch(std::move(scope), tryy))); // Push a pop for the exception payload if necessary. - auto params = wasm.getTag(tag)->sig.params; + auto params = wasm.getTag(tag)->params(); if (params != Type::none) { // Note that we have a pop to help determine later whether we need to run // the fixup for pops within blocks. @@ -1815,7 +1815,7 @@ Result<> IRBuilder::makeTryTable(Name label, Result<> IRBuilder::makeThrow(Name tag) { Throw curr(wasm.allocator); curr.tag = tag; - curr.operands.resize(wasm.getTag(tag)->sig.params.size()); + curr.operands.resize(wasm.getTag(tag)->params().size()); CHECK_ERR(visitThrow(&curr)); push(builder.makeThrow(tag, curr.operands)); return Ok{}; @@ -2343,7 +2343,7 @@ Result<> IRBuilder::makeResume(HeapType ct, Result<> IRBuilder::makeSuspend(Name tag) { Suspend curr(wasm.allocator); curr.tag = tag; - curr.operands.resize(wasm.getTag(tag)->sig.params.size()); + curr.operands.resize(wasm.getTag(tag)->params().size()); CHECK_ERR(visitSuspend(&curr)); std::vector operands(curr.operands.begin(), curr.operands.end()); diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index bda3c3713a5..68951e1759d 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2585,14 +2585,14 @@ void FunctionValidator::visitTry(Try* curr) { auto* tag = getModule()->getTagOrNull(tagName); if (!shouldBeTrue(tag != nullptr, curr, "")) { getStream() << "tag name is invalid: " << tagName << "\n"; - } else if (!shouldBeEqual(tag->sig.results, Type(Type::none), curr, "")) { + } else if (!shouldBeEqual(tag->results(), Type(Type::none), curr, "")) { getStream() << "catch's tag (" << tagName << ") has result values, which is not allowed for exception handling"; } else { auto* catchBody = curr->catchBodies[i]; auto pops = EHUtils::findPops(catchBody); - if (tag->sig.params == Type::none) { + if (tag->params() == Type::none) { if (!shouldBeTrue(pops.empty(), curr, "")) { getStream() << "catch's tag (" << tagName << ") doesn't have any params, but there are pops"; @@ -2600,7 +2600,7 @@ void FunctionValidator::visitTry(Try* curr) { } else { if (shouldBeTrue(pops.size() == 1, curr, "")) { auto* pop = *pops.begin(); - if (!shouldBeSubType(tag->sig.params, pop->type, curr, "")) { + if (!shouldBeSubType(tag->params(), pop->type, curr, "")) { getStream() << "catch's tag (" << tagName << ")'s pop doesn't have the same type as the tag's params"; @@ -2672,7 +2672,7 @@ void FunctionValidator::visitTryTable(TryTable* curr) { auto* tag = getModule()->getTagOrNull(tagName); if (!shouldBeTrue(tag != nullptr, curr, "")) { getStream() << "catch's tag name is invalid: " << tagName << "\n"; - } else if (!shouldBeEqual(tag->sig.results, Type(Type::none), curr, "")) { + } else if (!shouldBeEqual(tag->results(), Type(Type::none), curr, "")) { getStream() << "catch's tag (" << tagName << ") has result values, which is not allowed for exception handling"; @@ -2680,7 +2680,7 @@ void FunctionValidator::visitTryTable(TryTable* curr) { // tagType and sentType should be the same (except for the possible exnref // at the end of sentType) - auto tagType = tag->sig.params; + auto tagType = tag->params(); tagTypeSize = tagType.size(); for (Index j = 0; j < tagType.size(); j++) { shouldBeEqual(tagType[j], sentType[j], curr, invalidSentTypeMsg); @@ -2722,18 +2722,18 @@ void FunctionValidator::visitThrow(Throw* curr) { return; } shouldBeEqual( - tag->sig.results, + tag->results(), Type(Type::none), curr, "tags with result types must not be used for exception handling"); if (!shouldBeEqual(curr->operands.size(), - tag->sig.params.size(), + tag->params().size(), curr, "tag's param numbers must match")) { return; } size_t i = 0; - for (const auto& param : tag->sig.params) { + for (const auto& param : tag->params()) { if (!shouldBeSubType(curr->operands[i]->type, param, curr->operands[i], @@ -4164,20 +4164,20 @@ static void validateTags(Module& module, ValidationInfo& info) { "Tags require exception-handling [--enable-exception-handling]"); } for (auto& curr : module.tags) { - if (curr->sig.results != Type(Type::none)) { + if (curr->results() != Type::none) { info.shouldBeTrue(module.features.hasTypedContinuations(), curr->name, "Tags with result types require typed continuations " "feature [--enable-typed-continuations]"); } - if (curr->sig.params.isTuple()) { + if (curr->params().isTuple()) { info.shouldBeTrue( module.features.hasMultivalue(), curr->name, "Multivalue tag type requires multivalue [--enable-multivalue]"); } FeatureSet features; - for (const auto& param : curr->sig.params) { + for (const auto& param : curr->params()) { features |= param.getFeatures(); info.shouldBeTrue(param.isConcrete(), curr->name, diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index eb125d6c254..94454456288 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -926,7 +926,7 @@ static void populateTryTableSentTypes(TryTable* curr, Module* wasm) { auto tagName = curr->catchTags[i]; std::vector sentType; if (tagName) { - for (auto t : wasm->getTag(tagName)->sig.params) { + for (auto t : wasm->getTag(tagName)->params()) { sentType.push_back(t); } } @@ -1412,11 +1412,10 @@ static void populateResumeSentTypes(Resume* curr, Module* wasm) { curr->sentTypes.clear(); curr->sentTypes.resize(curr->handlerTags.size()); for (Index i = 0; i < curr->handlerTags.size(); i++) { - auto& tag = curr->handlerTags[i]; - auto& tagSig = wasm->getTag(tag)->sig; + auto tag = wasm->getTag(curr->handlerTags[i]); - auto& tgps = tagSig.params; - auto& tgrs = tagSig.results; + auto tgps = tag->params(); + auto tgrs = tag->results(); HeapType ftPrime{Signature(tgrs, ctrs)}; HeapType ctPrime{Continuation(ftPrime)}; @@ -1450,7 +1449,7 @@ void Resume::finalize(Module* wasm) { void Suspend::finalize(Module* wasm) { if (!handleUnreachableOperands(this) && wasm) { auto tag = wasm->getTag(this->tag); - type = tag->sig.results; + type = tag->results(); } } diff --git a/test/binaryen.js/exception-handling.js.txt b/test/binaryen.js/exception-handling.js.txt index f8b71302538..6be0eb40a58 100644 --- a/test/binaryen.js/exception-handling.js.txt +++ b/test/binaryen.js/exception-handling.js.txt @@ -1,7 +1,7 @@ (module (type $0 (func (param i32))) (type $1 (func)) - (tag $e (param i32)) + (tag $e (type $0) (param i32)) (func $test (try $l0 (do diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index b1554bec0f2..16e19a6a0c9 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -132,14 +132,14 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (import "module" "base" (global $a-global-imp i32)) (import "module" "base" (global $a-mut-global-imp (mut i32))) (import "module" "base" (func $an-imported (type $2) (param i32 f64) (result f32))) - (import "module" "base" (tag $a-tag-imp (param i32))) + (import "module" "base" (tag $a-tag-imp (type $1) (param i32))) (global $a-global i32 (i32.const 1)) (memory $0 1 256 shared) (data $x0 (i32.const 10) "hello, world") (data $y1 "I am passive") (table $t0 1 funcref) (elem $e0 (i32.const 0) $"kitchen()sinker") - (tag $a-tag (param i32)) + (tag $a-tag (type $1) (param i32)) (export "mem" (memory $0)) (export "kitchen_sinker" (func $"kitchen()sinker")) (export "a-global-exp" (global $a-global)) @@ -2724,7 +2724,7 @@ module loaded from binary form: (type $0 (func (param i32 i32))) (type $1 (func (param i32 i32) (result i32))) (global $a-global i32 (i32.const 3)) - (tag $a-tag (param i32 i32)) + (tag $a-tag (type $0) (param i32 i32)) (func $adder (type $1) (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) @@ -2766,7 +2766,7 @@ test_parsing text: (type $0 (func (param i32))) (type $1 (func (param i32 i32) (result i32))) (global $a-global i32 (i32.const 3)) - (tag $a-tag (param i32)) + (tag $a-tag (type $0) (param i32)) (func $adder (type $1) (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) @@ -2780,7 +2780,7 @@ module loaded from text form: (type $0 (func (param i32))) (type $1 (func (param i32 i32) (result i32))) (global $a-global i32 (i32.const 3)) - (tag $a-tag (param i32)) + (tag $a-tag (type $0) (param i32)) (func $ADD_ER (type $1) (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) diff --git a/test/binaryen.js/tag.js.txt b/test/binaryen.js/tag.js.txt index 06c0c9d68fa..0bdec723f51 100644 --- a/test/binaryen.js/tag.js.txt +++ b/test/binaryen.js/tag.js.txt @@ -3,13 +3,13 @@ getTagInfo={"name":"a-tag","module":"","base":"","params":2,"results":0} (module (type $0 (func (param i32))) (type $1 (func (param i32 f32))) - (import "module" "base" (tag $a-tag-imp (param i32 f32))) - (tag $a-tag (param i32)) + (import "module" "base" (tag $a-tag-imp (type $1) (param i32 f32))) + (tag $a-tag (type $0) (param i32)) (export "a-tag-exp" (tag $a-tag)) ) (module (type $0 (func (param i32 f32))) - (import "module" "base" (tag $a-tag-imp (param i32 f32))) + (import "module" "base" (tag $a-tag-imp (type $0) (param i32 f32))) ) diff --git a/test/br_to_try.wasm.fromBinary b/test/br_to_try.wasm.fromBinary index a3bed8ee0fa..af187786658 100644 --- a/test/br_to_try.wasm.fromBinary +++ b/test/br_to_try.wasm.fromBinary @@ -1,7 +1,7 @@ (module (type $0 (func (param i32))) (type $1 (func)) - (tag $tag$0 (param i32)) + (tag $tag$0 (type $0) (param i32)) (func $0 (block $label (try diff --git a/test/break-within-catch.wasm.fromBinary b/test/break-within-catch.wasm.fromBinary index 7d151f48c48..1c21f33649b 100644 --- a/test/break-within-catch.wasm.fromBinary +++ b/test/break-within-catch.wasm.fromBinary @@ -1,7 +1,7 @@ (module (type $0 (func (param i32))) (type $1 (func)) - (tag $tag$0 (param i32)) + (tag $tag$0 (type $0) (param i32)) (func $0 (block $label (try diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index 032d15db434..ba4a520268e 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -91,7 +91,7 @@ BinaryenFeatureAll: 2097151 (table $0 1 1 funcref) (elem $0 (table $0) (i32.const 0) func $"kitchen()sinker") (elem $passive func $"kitchen()sinker") - (tag $a-tag (param i32)) + (tag $a-tag (type $4) (param i32)) (export "mem" (memory $0)) (export "kitchen_sinker" (func $"kitchen()sinker")) (start $starter) diff --git a/test/example/module-splitting.txt b/test/example/module-splitting.txt index 709ebd4d755..04d43631fb8 100644 --- a/test/example/module-splitting.txt +++ b/test/example/module-splitting.txt @@ -16,7 +16,7 @@ Before: (global $glob (mut i32) (i32.const 7)) (memory $mem 3 42 shared) (table $tab 3 42 funcref) - (tag $e (param i32)) + (tag $e (type $0) (param i32)) ) Keeping: After: @@ -25,7 +25,7 @@ After: (global $glob (mut i32) (i32.const 7)) (memory $mem 3 42 shared) (table $tab 3 42 funcref) - (tag $e (param i32)) + (tag $e (type $0) (param i32)) (export "%memory" (memory $mem)) (export "%table" (table $tab)) (export "%global" (global $glob)) @@ -42,7 +42,7 @@ Before: (import "env" "mem" (memory $mem 3 42 shared)) (import "env" "tab" (table $tab 3 42 funcref)) (import "env" "glob" (global $glob (mut i32))) - (import "env" "e" (tag $e (param i32))) + (import "env" "e" (tag $e (type $0) (param i32))) ) Keeping: After: @@ -51,7 +51,7 @@ After: (import "env" "mem" (memory $mem 3 42 shared)) (import "env" "tab" (table $tab 3 42 funcref)) (import "env" "glob" (global $glob (mut i32))) - (import "env" "e" (tag $e (param i32))) + (import "env" "e" (tag $e (type $0) (param i32))) (export "%memory" (memory $mem)) (export "%table" (table $tab)) (export "%global" (global $glob)) @@ -68,7 +68,7 @@ Before: (global $glob (mut i32) (i32.const 7)) (memory $mem 3 42 shared) (table $tab 3 42 funcref) - (tag $e (param i32)) + (tag $e (type $0) (param i32)) (export "mem" (memory $mem)) (export "tab" (table $tab)) (export "glob" (global $glob)) @@ -81,7 +81,7 @@ After: (global $glob (mut i32) (i32.const 7)) (memory $mem 3 42 shared) (table $tab 3 42 funcref) - (tag $e (param i32)) + (tag $e (type $0) (param i32)) (export "mem" (memory $mem)) (export "tab" (table $tab)) (export "glob" (global $glob)) diff --git a/test/lit/basic/exception-handling-legacy.wast b/test/lit/basic/exception-handling-legacy.wast index 791745b69ef..3f019d5323e 100644 --- a/test/lit/basic/exception-handling-legacy.wast +++ b/test/lit/basic/exception-handling-legacy.wast @@ -20,7 +20,7 @@ ;; CHECK-TEXT: (type $4 (func (param eqref))) - ;; CHECK-TEXT: (tag $e-i32 (param i32)) + ;; CHECK-TEXT: (tag $e-i32 (type $1) (param i32)) ;; CHECK-BIN: (type $0 (func)) ;; CHECK-BIN: (type $1 (func (param i32))) @@ -31,19 +31,19 @@ ;; CHECK-BIN: (type $4 (func (param eqref))) - ;; CHECK-BIN: (tag $e-i32 (param i32)) + ;; CHECK-BIN: (tag $e-i32 (type $1) (param i32)) (tag $e-i32 (param i32)) - ;; CHECK-TEXT: (tag $e-i64 (param i64)) - ;; CHECK-BIN: (tag $e-i64 (param i64)) + ;; CHECK-TEXT: (tag $e-i64 (type $2) (param i64)) + ;; CHECK-BIN: (tag $e-i64 (type $2) (param i64)) (tag $e-i64 (param i64)) - ;; CHECK-TEXT: (tag $e-i32-i64 (param i32 i64)) - ;; CHECK-BIN: (tag $e-i32-i64 (param i32 i64)) + ;; CHECK-TEXT: (tag $e-i32-i64 (type $3) (param i32 i64)) + ;; CHECK-BIN: (tag $e-i32-i64 (type $3) (param i32 i64)) (tag $e-i32-i64 (param i32 i64)) - ;; CHECK-TEXT: (tag $e-eqref (param eqref)) - ;; CHECK-BIN: (tag $e-eqref (param eqref)) + ;; CHECK-TEXT: (tag $e-eqref (type $4) (param eqref)) + ;; CHECK-BIN: (tag $e-eqref (type $4) (param eqref)) (tag $e-eqref (param (ref null eq))) - ;; CHECK-TEXT: (tag $e-empty) - ;; CHECK-BIN: (tag $e-empty) + ;; CHECK-TEXT: (tag $e-empty (type $0)) + ;; CHECK-BIN: (tag $e-empty (type $0)) (tag $e-empty) ;; CHECK-TEXT: (func $foo (type $0) @@ -1312,15 +1312,15 @@ ;; CHECK-BIN-NODEBUG: (type $4 (func (param eqref))) -;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32)) +;; CHECK-BIN-NODEBUG: (tag $tag$0 (type $1) (param i32)) -;; CHECK-BIN-NODEBUG: (tag $tag$1 (param i64)) +;; CHECK-BIN-NODEBUG: (tag $tag$1 (type $2) (param i64)) -;; CHECK-BIN-NODEBUG: (tag $tag$2 (param i32 i64)) +;; CHECK-BIN-NODEBUG: (tag $tag$2 (type $3) (param i32 i64)) -;; CHECK-BIN-NODEBUG: (tag $tag$3 (param eqref)) +;; CHECK-BIN-NODEBUG: (tag $tag$3 (type $4) (param eqref)) -;; CHECK-BIN-NODEBUG: (tag $tag$4) +;; CHECK-BIN-NODEBUG: (tag $tag$4 (type $0)) ;; CHECK-BIN-NODEBUG: (func $0 (type $0) ;; CHECK-BIN-NODEBUG-NEXT: ) diff --git a/test/lit/basic/exception-handling.wast b/test/lit/basic/exception-handling.wast index 41c10f6311a..6b1518b65b4 100644 --- a/test/lit/basic/exception-handling.wast +++ b/test/lit/basic/exception-handling.wast @@ -30,7 +30,7 @@ ;; CHECK-TEXT: (type $9 (func (param eqref))) - ;; CHECK-TEXT: (tag $e-i32 (param i32)) + ;; CHECK-TEXT: (tag $e-i32 (type $6) (param i32)) ;; CHECK-BIN: (type $0 (func)) ;; CHECK-BIN: (type $1 (func (result i32 i64))) @@ -51,19 +51,19 @@ ;; CHECK-BIN: (type $9 (func (param eqref))) - ;; CHECK-BIN: (tag $e-i32 (param i32)) + ;; CHECK-BIN: (tag $e-i32 (type $6) (param i32)) (tag $e-i32 (param i32)) - ;; CHECK-TEXT: (tag $e-i64 (param i64)) - ;; CHECK-BIN: (tag $e-i64 (param i64)) + ;; CHECK-TEXT: (tag $e-i64 (type $7) (param i64)) + ;; CHECK-BIN: (tag $e-i64 (type $7) (param i64)) (tag $e-i64 (param i64)) - ;; CHECK-TEXT: (tag $e-i32-i64 (param i32 i64)) - ;; CHECK-BIN: (tag $e-i32-i64 (param i32 i64)) + ;; CHECK-TEXT: (tag $e-i32-i64 (type $8) (param i32 i64)) + ;; CHECK-BIN: (tag $e-i32-i64 (type $8) (param i32 i64)) (tag $e-i32-i64 (param i32 i64)) - ;; CHECK-TEXT: (tag $e-eqref (param eqref)) - ;; CHECK-BIN: (tag $e-eqref (param eqref)) + ;; CHECK-TEXT: (tag $e-eqref (type $9) (param eqref)) + ;; CHECK-BIN: (tag $e-eqref (type $9) (param eqref)) (tag $e-eqref (param (ref null eq))) - ;; CHECK-TEXT: (tag $e-empty) - ;; CHECK-BIN: (tag $e-empty) + ;; CHECK-TEXT: (tag $e-empty (type $0)) + ;; CHECK-BIN: (tag $e-empty (type $0)) (tag $e-empty) ;; CHECK-TEXT: (func $foo (type $0) @@ -740,15 +740,15 @@ ;; CHECK-BIN-NODEBUG: (type $9 (func (param eqref))) -;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32)) +;; CHECK-BIN-NODEBUG: (tag $tag$0 (type $6) (param i32)) -;; CHECK-BIN-NODEBUG: (tag $tag$1 (param i64)) +;; CHECK-BIN-NODEBUG: (tag $tag$1 (type $7) (param i64)) -;; CHECK-BIN-NODEBUG: (tag $tag$2 (param i32 i64)) +;; CHECK-BIN-NODEBUG: (tag $tag$2 (type $8) (param i32 i64)) -;; CHECK-BIN-NODEBUG: (tag $tag$3 (param eqref)) +;; CHECK-BIN-NODEBUG: (tag $tag$3 (type $9) (param eqref)) -;; CHECK-BIN-NODEBUG: (tag $tag$4) +;; CHECK-BIN-NODEBUG: (tag $tag$4 (type $0)) ;; CHECK-BIN-NODEBUG: (func $0 (type $0) ;; CHECK-BIN-NODEBUG-NEXT: ) diff --git a/test/lit/basic/extra-branch-values.wast b/test/lit/basic/extra-branch-values.wast index abd609304ec..6989bf62ca9 100644 --- a/test/lit/basic/extra-branch-values.wast +++ b/test/lit/basic/extra-branch-values.wast @@ -27,11 +27,11 @@ ;; OPT_O: (import "env" "use-i32-any" (func $use-i32-any (type $15) (param i32 (ref any)))) (import "env" "use-i32-any" (func $use-i32-any (param i32 (ref any)))) - ;; CHECK: (tag $e (param i32)) - ;; OPT_O: (tag $e (param i32)) + ;; CHECK: (tag $e (type $7) (param i32)) + ;; OPT_O: (tag $e (type $5) (param i32)) (tag $e (param i32)) - ;; CHECK: (tag $e2 (param i32)) - ;; OPT_O: (tag $e2 (param i32)) + ;; CHECK: (tag $e2 (type $7) (param i32)) + ;; OPT_O: (tag $e2 (type $5) (param i32)) (tag $e2 (param i32)) ;; CHECK: (func $br_on_null-one (type $8) (param $0 i32) (param $1 anyref) (result i32) diff --git a/test/lit/basic/pop-fixup.wast b/test/lit/basic/pop-fixup.wast index 9ef51dad82d..f3578b178a9 100644 --- a/test/lit/basic/pop-fixup.wast +++ b/test/lit/basic/pop-fixup.wast @@ -2,9 +2,9 @@ ;; RUN: wasm-opt %s -all -S -o - | filecheck %s (module - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $1) (param i32)) (tag $e (param i32)) - ;; CHECK: (tag $e2 (param i32 i32)) + ;; CHECK: (tag $e2 (type $2) (param i32 i32)) (tag $e2 (param i32 i32)) ;; CHECK: (func $stacky (type $0) diff --git a/test/lit/basic/reference-types.wast b/test/lit/basic/reference-types.wast index 61497e6124f..82b1f8da4e3 100644 --- a/test/lit/basic/reference-types.wast +++ b/test/lit/basic/reference-types.wast @@ -73,7 +73,7 @@ ;; CHECK-TEXT: (elem declare func $foo $ref-taken-but-not-in-table) - ;; CHECK-TEXT: (tag $e-i32 (param i32)) + ;; CHECK-TEXT: (tag $e-i32 (type $7) (param i32)) ;; CHECK-TEXT: (export "export_func" (func $import_func)) @@ -97,7 +97,7 @@ ;; CHECK-BIN: (elem declare func $foo $ref-taken-but-not-in-table) - ;; CHECK-BIN: (tag $e-i32 (param i32)) + ;; CHECK-BIN: (tag $e-i32 (type $7) (param i32)) ;; CHECK-BIN: (export "export_func" (func $import_func)) @@ -2089,7 +2089,7 @@ ;; CHECK-BIN-NEXT: ) (func $ref-taken-but-not-in-table) ) -;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32)) +;; CHECK-BIN-NODEBUG: (tag $tag$0 (type $7) (param i32)) ;; CHECK-BIN-NODEBUG: (export "export_func" (func $fimport$0)) diff --git a/test/lit/basic/tags.wast b/test/lit/basic/tags.wast index 7d99816c1d8..4d5a9395651 100644 --- a/test/lit/basic/tags.wast +++ b/test/lit/basic/tags.wast @@ -23,40 +23,40 @@ ;; CHECK-TEXT: (type $2 (func)) - ;; CHECK-TEXT: (import "env" "im0" (tag $e-import (param i32))) + ;; CHECK-TEXT: (import "env" "im0" (tag $e-import (type $1) (param i32))) - ;; CHECK-TEXT: (import "env" "im1" (tag $eimport$0 (param i32 f32))) + ;; CHECK-TEXT: (import "env" "im1" (tag $eimport$0 (type $0) (param i32 f32))) - ;; CHECK-TEXT: (tag $tag$1 (param i32)) + ;; CHECK-TEXT: (tag $tag$1 (type $1) (param i32)) - ;; CHECK-TEXT: (tag $e (param i32 f32)) + ;; CHECK-TEXT: (tag $e (type $0) (param i32 f32)) ;; CHECK-BIN: (type $0 (func (param i32 f32))) ;; CHECK-BIN: (type $1 (func (param i32))) ;; CHECK-BIN: (type $2 (func)) - ;; CHECK-BIN: (import "env" "im0" (tag $e-import (param i32))) + ;; CHECK-BIN: (import "env" "im0" (tag $e-import (type $1) (param i32))) - ;; CHECK-BIN: (import "env" "im1" (tag $eimport$1 (param i32 f32))) + ;; CHECK-BIN: (import "env" "im1" (tag $eimport$1 (type $0) (param i32 f32))) - ;; CHECK-BIN: (tag $tag$0 (param i32)) + ;; CHECK-BIN: (tag $tag$0 (type $1) (param i32)) - ;; CHECK-BIN: (tag $e (param i32 f32)) + ;; CHECK-BIN: (tag $e (type $0) (param i32 f32)) (tag $e (param i32 f32)) - ;; CHECK-TEXT: (tag $empty) - ;; CHECK-BIN: (tag $empty) + ;; CHECK-TEXT: (tag $empty (type $2)) + ;; CHECK-BIN: (tag $empty (type $2)) (tag $empty) - ;; CHECK-TEXT: (tag $e-params0 (param i32 f32)) - ;; CHECK-BIN: (tag $e-params0 (param i32 f32)) + ;; CHECK-TEXT: (tag $e-params0 (type $0) (param i32 f32)) + ;; CHECK-BIN: (tag $e-params0 (type $0) (param i32 f32)) (tag $e-params0 (param i32 f32)) - ;; CHECK-TEXT: (tag $e-params1 (param i32 f32)) - ;; CHECK-BIN: (tag $e-params1 (param i32 f32)) + ;; CHECK-TEXT: (tag $e-params1 (type $0) (param i32 f32)) + ;; CHECK-BIN: (tag $e-params1 (type $0) (param i32 f32)) (tag $e-params1 (param i32) (param f32)) - ;; CHECK-TEXT: (tag $e-export (param i32)) - ;; CHECK-BIN: (tag $e-export (param i32)) + ;; CHECK-TEXT: (tag $e-export (type $1) (param i32)) + ;; CHECK-BIN: (tag $e-export (type $1) (param i32)) (tag $e-export (export "ex0") (param i32)) ;; CHECK-TEXT: (export "ex0" (tag $e-export)) @@ -73,21 +73,21 @@ ;; CHECK-BIN-NODEBUG: (type $2 (func)) -;; CHECK-BIN-NODEBUG: (import "env" "im0" (tag $eimport$0 (param i32))) +;; CHECK-BIN-NODEBUG: (import "env" "im0" (tag $eimport$0 (type $1) (param i32))) -;; CHECK-BIN-NODEBUG: (import "env" "im1" (tag $eimport$1 (param i32 f32))) +;; CHECK-BIN-NODEBUG: (import "env" "im1" (tag $eimport$1 (type $0) (param i32 f32))) -;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32)) +;; CHECK-BIN-NODEBUG: (tag $tag$0 (type $1) (param i32)) -;; CHECK-BIN-NODEBUG: (tag $tag$1 (param i32 f32)) +;; CHECK-BIN-NODEBUG: (tag $tag$1 (type $0) (param i32 f32)) -;; CHECK-BIN-NODEBUG: (tag $tag$2) +;; CHECK-BIN-NODEBUG: (tag $tag$2 (type $2)) -;; CHECK-BIN-NODEBUG: (tag $tag$3 (param i32 f32)) +;; CHECK-BIN-NODEBUG: (tag $tag$3 (type $0) (param i32 f32)) -;; CHECK-BIN-NODEBUG: (tag $tag$4 (param i32 f32)) +;; CHECK-BIN-NODEBUG: (tag $tag$4 (type $0) (param i32 f32)) -;; CHECK-BIN-NODEBUG: (tag $tag$5 (param i32)) +;; CHECK-BIN-NODEBUG: (tag $tag$5 (type $1) (param i32)) ;; CHECK-BIN-NODEBUG: (export "ex0" (tag $tag$5)) diff --git a/test/lit/basic/typed_continuations_resume.wast b/test/lit/basic/typed_continuations_resume.wast index 07afb9388f3..b80e1e2fa93 100644 --- a/test/lit/basic/typed_continuations_resume.wast +++ b/test/lit/basic/typed_continuations_resume.wast @@ -27,12 +27,12 @@ ;; CHECK-TEXT: (type $3 (func (param (ref $ct)) (result i32))) - ;; CHECK-TEXT: (tag $t (param i32) (result i32)) + ;; CHECK-TEXT: (tag $t (type $ft) (param i32) (result i32)) ;; CHECK-BIN: (type $2 (func (result i32 (ref $ct)))) ;; CHECK-BIN: (type $3 (func (param (ref $ct)) (result i32))) - ;; CHECK-BIN: (tag $t (param i32) (result i32)) + ;; CHECK-BIN: (tag $t (type $ft) (param i32) (result i32)) (tag $t (param i32) (result i32)) ;; CHECK-BINARY: (func $go (type $3) (param $x (ref $ct)) (result i32) @@ -129,7 +129,7 @@ ;; CHECK-BIN-NODEBUG: (type $3 (func (param (ref $1)) (result i32))) -;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32) (result i32)) +;; CHECK-BIN-NODEBUG: (tag $tag$0 (type $0) (param i32) (result i32)) ;; CHECK-BIN-NODEBUG: (func $0 (type $3) (param $0 (ref $1)) (result i32) ;; CHECK-BIN-NODEBUG-NEXT: (local $scratch (tuple i32 (ref $1))) diff --git a/test/lit/basic/typed_continuations_suspend.wast b/test/lit/basic/typed_continuations_suspend.wast index 62a09c2133c..e7cfc139d11 100644 --- a/test/lit/basic/typed_continuations_suspend.wast +++ b/test/lit/basic/typed_continuations_suspend.wast @@ -14,12 +14,12 @@ ;; CHECK-TEXT: (type $1 (func (result i64))) - ;; CHECK-TEXT: (tag $t (param i32) (result i64)) + ;; CHECK-TEXT: (tag $t (type $0) (param i32) (result i64)) ;; CHECK-BIN: (type $0 (func (param i32) (result i64))) ;; CHECK-BIN: (type $1 (func (result i64))) - ;; CHECK-BIN: (tag $t (param i32) (result i64)) + ;; CHECK-BIN: (tag $t (type $0) (param i32) (result i64)) (tag $t (param i32) (result i64)) ;; CHECK-TEXT: (func $f (type $1) (result i64) @@ -40,7 +40,7 @@ ;; CHECK-BIN-NODEBUG: (type $1 (func (result i64))) -;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32) (result i64)) +;; CHECK-BIN-NODEBUG: (tag $tag$0 (type $0) (param i32) (result i64)) ;; CHECK-BIN-NODEBUG: (func $0 (type $1) (result i64) ;; CHECK-BIN-NODEBUG-NEXT: (suspend $tag$0 diff --git a/test/lit/control-flow-input.wast b/test/lit/control-flow-input.wast index 7baae35f0ef..39cb28d9fa1 100644 --- a/test/lit/control-flow-input.wast +++ b/test/lit/control-flow-input.wast @@ -11,7 +11,7 @@ (module (type $id (func (param i32) (result i32))) - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $3) (param i32)) (tag $e (param i32)) ;; CHECK: (func $block (type $0) (result i32) diff --git a/test/lit/gc-eh-legacy.wast b/test/lit/gc-eh-legacy.wast index 2c12cec49d5..85b0c287f42 100644 --- a/test/lit/gc-eh-legacy.wast +++ b/test/lit/gc-eh-legacy.wast @@ -10,7 +10,7 @@ (field (mut i32)) )) - ;; CHECK: (tag $tagA (param (ref $A))) + ;; CHECK: (tag $tagA (type $1) (param (ref $A))) (tag $tagA (param (ref $A))) ;; CHECK: (func $foo (type $2) (result (ref null $A)) diff --git a/test/lit/merge/fusing.wat b/test/lit/merge/fusing.wat index e074d30ba0c..9f80c80e96f 100644 --- a/test/lit/merge/fusing.wat +++ b/test/lit/merge/fusing.wat @@ -32,7 +32,7 @@ ;; CHECK: (memory $second.mem 2) - ;; CHECK: (tag $exn) + ;; CHECK: (tag $exn (type $0)) ;; CHECK: (export "foo" (func $first.foo)) diff --git a/test/lit/merge/names.wat b/test/lit/merge/names.wat index 6f51b54cac5..0c5030d2400 100644 --- a/test/lit/merge/names.wat +++ b/test/lit/merge/names.wat @@ -36,13 +36,13 @@ ;; CHECK: (table $3 1 funcref) - ;; CHECK: (tag $tag0) + ;; CHECK: (tag $tag0 (type $0)) - ;; CHECK: (tag $tag$1) + ;; CHECK: (tag $tag$1 (type $0)) - ;; CHECK: (tag $tag2) + ;; CHECK: (tag $tag2 (type $0)) - ;; CHECK: (tag $tag$3) + ;; CHECK: (tag $tag$3 (type $0)) ;; CHECK: (export "f0" (func $func0)) diff --git a/test/lit/merge/renamings.wat b/test/lit/merge/renamings.wat index e680b276b3e..acaff3e295a 100644 --- a/test/lit/merge/renamings.wat +++ b/test/lit/merge/renamings.wat @@ -21,7 +21,7 @@ ;; CHECK: (type $6 (func (param f32))) - ;; CHECK: (import "elsewhere" "some.tag" (tag $imported (param f64))) + ;; CHECK: (import "elsewhere" "some.tag" (tag $imported (type $2) (param f64))) ;; CHECK: (global $foo i32 (i32.const 1)) (global $foo i32 (i32.const 1)) @@ -83,17 +83,17 @@ ;; CHECK: (elem $bar_2 func $other $foo_3) - ;; CHECK: (tag $foo (param i32)) + ;; CHECK: (tag $foo (type $4) (param i32)) (tag $foo (param i32)) - ;; CHECK: (tag $bar (param i64)) + ;; CHECK: (tag $bar (type $5) (param i64)) (tag $bar (param i64)) ;; This export has a conflict in second.wat, and so second.wat's $foo ;; will be renamed. - ;; CHECK: (tag $foo_2 (param f32)) + ;; CHECK: (tag $foo_2 (type $6) (param f32)) - ;; CHECK: (tag $other (param f64)) + ;; CHECK: (tag $other (type $2) (param f64)) ;; CHECK: (export "foo" (func $foo)) (export "foo" (func $foo)) diff --git a/test/lit/passes/coalesce-locals-eh-legacy.wast b/test/lit/passes/coalesce-locals-eh-legacy.wast index b5b41b66154..75807f0a858 100644 --- a/test/lit/passes/coalesce-locals-eh-legacy.wast +++ b/test/lit/passes/coalesce-locals-eh-legacy.wast @@ -2,10 +2,10 @@ ;; RUN: wasm-opt %s --coalesce-locals -all -S -o - | filecheck %s (module - ;; CHECK: (tag $e) + ;; CHECK: (tag $e (type $0)) (tag $e) - ;; CHECK: (tag $any (param (ref any))) + ;; CHECK: (tag $any (type $1) (param (ref any))) (tag $any (param (ref any))) ;; CHECK: (func $bar (type $2) (result i32) diff --git a/test/lit/passes/coalesce-locals-eh.wast b/test/lit/passes/coalesce-locals-eh.wast index 90458f32fef..6f3deaa76b5 100644 --- a/test/lit/passes/coalesce-locals-eh.wast +++ b/test/lit/passes/coalesce-locals-eh.wast @@ -2,10 +2,10 @@ ;; RUN: wasm-opt %s --coalesce-locals -all -S -o - | filecheck %s (module - ;; CHECK: (tag $e) + ;; CHECK: (tag $e (type $0)) (tag $e) - ;; CHECK: (tag $any (param (ref any))) + ;; CHECK: (tag $any (type $1) (param (ref any))) (tag $any (param (ref any))) ;; CHECK: (func $bar (type $2) (result i32) diff --git a/test/lit/passes/code-folding-eh-legacy.wast b/test/lit/passes/code-folding-eh-legacy.wast index cde0fba2836..a2fc562c926 100644 --- a/test/lit/passes/code-folding-eh-legacy.wast +++ b/test/lit/passes/code-folding-eh-legacy.wast @@ -3,7 +3,7 @@ ;; RUN: | filecheck %s (module - ;; CHECK: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $2) (param i32)) (tag $e-i32 (param i32)) ;; CHECK: (func $pop-test (type $1) diff --git a/test/lit/passes/code-folding-eh.wast b/test/lit/passes/code-folding-eh.wast index 94eb0b38d32..e56518121dd 100644 --- a/test/lit/passes/code-folding-eh.wast +++ b/test/lit/passes/code-folding-eh.wast @@ -3,7 +3,7 @@ ;; RUN: | filecheck %s (module - ;; CHECK: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $2) (param i32)) (tag $e-i32 (param i32)) ;; CHECK: (func $try_table-call-optimize-terminating-tails-success (type $0) (result i32) diff --git a/test/lit/passes/code-pushing-eh-legacy.wast b/test/lit/passes/code-pushing-eh-legacy.wast index 06b2e3e7140..74cedc5f6ca 100644 --- a/test/lit/passes/code-pushing-eh-legacy.wast +++ b/test/lit/passes/code-pushing-eh-legacy.wast @@ -4,7 +4,7 @@ ;; The tests in this file test EffectAnalyzer, which is used by CodePushing. (module - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $1) (param i32)) (tag $e (param i32)) ;; CHECK: (func $can-push-past-try (type $0) diff --git a/test/lit/passes/code-pushing-eh.wast b/test/lit/passes/code-pushing-eh.wast index 3c6d005b123..f19a746beaa 100644 --- a/test/lit/passes/code-pushing-eh.wast +++ b/test/lit/passes/code-pushing-eh.wast @@ -4,7 +4,7 @@ ;; The tests in this file test EffectAnalyzer, which is used by CodePushing. (module - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $1) (param i32)) (tag $e (param i32)) ;; CHECK: (func $cannot-push-past-call (type $0) diff --git a/test/lit/passes/dce-eh-legacy.wast b/test/lit/passes/dce-eh-legacy.wast index 31ba4fac2de..2bc87f0819b 100644 --- a/test/lit/passes/dce-eh-legacy.wast +++ b/test/lit/passes/dce-eh-legacy.wast @@ -17,11 +17,11 @@ ;; CHECK: (type $struct (struct (field (mut eqref)))) (type $struct (struct (field (mut (ref null eq))))) - ;; CHECK: (tag $e) + ;; CHECK: (tag $e (type $0)) (tag $e) - ;; CHECK: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $1) (param i32)) (tag $e-i32 (param i32)) - ;; CHECK: (tag $e-eqref (param eqref)) + ;; CHECK: (tag $e-eqref (type $2) (param eqref)) (tag $e-eqref (param (ref null eq))) ;; CHECK: (func $foo (type $0) diff --git a/test/lit/passes/dce-eh.wast b/test/lit/passes/dce-eh.wast index b2742913b54..b9c7b596009 100644 --- a/test/lit/passes/dce-eh.wast +++ b/test/lit/passes/dce-eh.wast @@ -4,10 +4,10 @@ ;; If either try_table body or any of catch handler is reachable, the whole ;; try_table construct is reachable. (module - ;; CHECK: (tag $e) + ;; CHECK: (tag $e (type $0)) (tag $e) - ;; CHECK: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $1) (param i32)) (tag $e-i32 (param i32)) ;; CHECK: (func $foo (type $0) diff --git a/test/lit/passes/flatten-eh-legacy.wast b/test/lit/passes/flatten-eh-legacy.wast index 34b5cf08b82..3d22b41a4e5 100644 --- a/test/lit/passes/flatten-eh-legacy.wast +++ b/test/lit/passes/flatten-eh-legacy.wast @@ -2,9 +2,9 @@ ;; RUN: wasm-opt %s -all --flatten -S -o - | filecheck %s (module - ;; CHECK: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $2) (param i32)) (tag $e-i32 (param i32)) - ;; CHECK: (tag $e-f32 (param f32)) + ;; CHECK: (tag $e-f32 (type $3) (param f32)) (tag $e-f32 (param f32)) ;; CHECK: (func $try_catch (type $1) diff --git a/test/lit/passes/global-effects-eh-legacy.wast b/test/lit/passes/global-effects-eh-legacy.wast index 7390f996d8d..dae61274e10 100644 --- a/test/lit/passes/global-effects-eh-legacy.wast +++ b/test/lit/passes/global-effects-eh-legacy.wast @@ -31,10 +31,10 @@ ;; WITHOUT: (elem declare func $throw) - ;; WITHOUT: (tag $tag) + ;; WITHOUT: (tag $tag (type $void)) ;; INCLUDE: (elem declare func $throw) - ;; INCLUDE: (tag $tag) + ;; INCLUDE: (tag $tag (type $void)) (tag $tag) ;; WITHOUT: (func $main (type $void) diff --git a/test/lit/passes/global-effects.wast b/test/lit/passes/global-effects.wast index c3c6d207370..1125f738e68 100644 --- a/test/lit/passes/global-effects.wast +++ b/test/lit/passes/global-effects.wast @@ -31,10 +31,10 @@ ;; WITHOUT: (elem declare func $throw) - ;; WITHOUT: (tag $tag) + ;; WITHOUT: (tag $tag (type $void)) ;; INCLUDE: (elem declare func $throw) - ;; INCLUDE: (tag $tag) + ;; INCLUDE: (tag $tag (type $void)) (tag $tag) ;; WITHOUT: (func $main (type $void) diff --git a/test/lit/passes/gto-mutability.wast b/test/lit/passes/gto-mutability.wast index 3cf0e77016d..0e64c4aa777 100644 --- a/test/lit/passes/gto-mutability.wast +++ b/test/lit/passes/gto-mutability.wast @@ -24,13 +24,11 @@ ;; CHECK: (type $4 (func (param (ref $struct)))) - ;; CHECK: (type $5 (func (param (ref $struct)))) - ;; CHECK: (table $0 0 funcref) ;; CHECK: (elem declare func $func-two-params) - ;; CHECK: (tag $tag (param (ref $struct))) + ;; CHECK: (tag $tag (type $4) (param (ref $struct))) (tag $tag (param (ref $struct))) ;; CHECK: (func $func (type $4) (param $x (ref $struct)) diff --git a/test/lit/passes/gufa-eh.wast b/test/lit/passes/gufa-eh.wast index 79265a31825..d4e30473d81 100644 --- a/test/lit/passes/gufa-eh.wast +++ b/test/lit/passes/gufa-eh.wast @@ -9,7 +9,7 @@ ;; CHECK: (type $2 (func)) - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $0) (param i32)) (tag $e (param i32)) ;; CHECK: (func $try_table-target-block-is-not-unreachable (type $1) (result i32) diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index ec67cf40cfd..a4878df7b31 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -1904,13 +1904,13 @@ ;; CHECK: (type $struct (struct)) (type $struct (struct)) - ;; CHECK: (tag $nothing (param anyref)) + ;; CHECK: (tag $nothing (type $1) (param anyref)) (tag $nothing (param (ref null any))) - ;; CHECK: (tag $something (param anyref)) + ;; CHECK: (tag $something (type $1) (param anyref)) (tag $something (param (ref null any))) - ;; CHECK: (tag $empty) + ;; CHECK: (tag $empty (type $0)) (tag $empty (param)) ;; CHECK: (func $func (type $0) @@ -2136,7 +2136,7 @@ ;; CHECK: (type $struct (struct)) (type $struct (struct)) - ;; CHECK: (tag $tag (param anyref anyref)) + ;; CHECK: (tag $tag (type $0) (param anyref anyref)) (tag $tag (param (ref null any)) (param (ref null any))) ;; CHECK: (func $func (type $1) @@ -3859,7 +3859,7 @@ ;; CHECK: (table $t 0 externref) - ;; CHECK: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $2) (param i32)) (tag $e-i32 (param i32)) (memory $0 10) diff --git a/test/lit/passes/gufa-tags.wast b/test/lit/passes/gufa-tags.wast index a035673073b..4bac560900b 100644 --- a/test/lit/passes/gufa-tags.wast +++ b/test/lit/passes/gufa-tags.wast @@ -11,9 +11,9 @@ ;; CHECK: (type $3 (func (result i32))) - ;; CHECK: (tag $tag$i32 (param i32)) + ;; CHECK: (tag $tag$i32 (type $0) (param i32)) (tag $tag$i32 (param i32)) - ;; CHECK: (tag $tag$f32 (param f32)) + ;; CHECK: (tag $tag$f32 (type $1) (param f32)) (tag $tag$f32 (param f32)) ;; CHECK: (func $test (type $2) diff --git a/test/lit/passes/heap-store-optimization.wast b/test/lit/passes/heap-store-optimization.wast index d317888be37..2a773a3882f 100644 --- a/test/lit/passes/heap-store-optimization.wast +++ b/test/lit/passes/heap-store-optimization.wast @@ -12,7 +12,7 @@ ;; CHECK: (type $struct3 (struct (field (mut i32)) (field (mut i32)) (field (mut i32)))) - ;; CHECK: (tag $tag) + ;; CHECK: (tag $tag (type $1)) (tag $tag) (type $struct (struct (field (mut i32)))) diff --git a/test/lit/passes/heap2local.wast b/test/lit/passes/heap2local.wast index 0af7e7bb4ea..53f1fe289f4 100644 --- a/test/lit/passes/heap2local.wast +++ b/test/lit/passes/heap2local.wast @@ -4497,7 +4497,7 @@ ;; CHECK: (type $2 (struct (field (mut i32)) (field (mut i32)) (field (mut i32)))) - ;; CHECK: (tag $tag (param i32)) + ;; CHECK: (tag $tag (type $1) (param i32)) (tag $tag (param i32)) ;; CHECK: (func $struct-with-pop (type $0) diff --git a/test/lit/passes/inlining-eh-legacy.wast b/test/lit/passes/inlining-eh-legacy.wast index 4d9d3a7aa94..ca005fc7c58 100644 --- a/test/lit/passes/inlining-eh-legacy.wast +++ b/test/lit/passes/inlining-eh-legacy.wast @@ -5,7 +5,7 @@ ;; --------------------------------------------------------------------------- ;; CHECK: (import "a" "b" (func $foo (type $2) (result i32))) (import "a" "b" (func $foo (result i32))) - ;; CHECK: (tag $tag$0 (param i32)) + ;; CHECK: (tag $tag$0 (type $1) (param i32)) (tag $tag$0 (param i32)) (func $callee-with-label (try $label diff --git a/test/lit/passes/instrument-locals-eh-legacy.wast b/test/lit/passes/instrument-locals-eh-legacy.wast index 23d944a0cff..10188038848 100644 --- a/test/lit/passes/instrument-locals-eh-legacy.wast +++ b/test/lit/passes/instrument-locals-eh-legacy.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --instrument-locals -all -S -o - | filecheck %s (module - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $7) (param i32)) (tag $e (param i32)) ;; CHECK: (func $test (type $8) diff --git a/test/lit/passes/local-subtyping.wast b/test/lit/passes/local-subtyping.wast index 04890521dea..795a0a01cd1 100644 --- a/test/lit/passes/local-subtyping.wast +++ b/test/lit/passes/local-subtyping.wast @@ -24,7 +24,7 @@ ;; CHECK: (import "out" "i64" (func $i64 (type $4) (result i64))) (import "out" "i64" (func $i64 (result i64))) - ;; CHECK: (tag $e-anyref (param anyref)) + ;; CHECK: (tag $e-anyref (type $7) (param anyref)) (tag $e-anyref (param anyref)) ;; Refinalization can find a more specific type, where the declared type was diff --git a/test/lit/passes/merge-blocks-eh.wast b/test/lit/passes/merge-blocks-eh.wast index e56f536f4b6..75fecd532db 100644 --- a/test/lit/passes/merge-blocks-eh.wast +++ b/test/lit/passes/merge-blocks-eh.wast @@ -5,13 +5,13 @@ ;; CHECK: (import "a" "b" (func $import (type $0))) (import "a" "b" (func $import)) - ;; CHECK: (tag $empty) + ;; CHECK: (tag $empty (type $0)) (tag $empty) - ;; CHECK: (tag $i32 (param i32)) + ;; CHECK: (tag $i32 (type $3) (param i32)) (tag $i32 (param i32)) - ;; CHECK: (tag $exnref (param exnref)) + ;; CHECK: (tag $exnref (type $4) (param exnref)) (tag $exnref (param exnref)) ;; CHECK: (func $drop-block-try_catch_all_ref (type $0) diff --git a/test/lit/passes/once-reduction.wast b/test/lit/passes/once-reduction.wast index 640d14461f1..f8a6a1cee67 100644 --- a/test/lit/passes/once-reduction.wast +++ b/test/lit/passes/once-reduction.wast @@ -1194,7 +1194,7 @@ ;; CHECK: (global $once (mut i32) (i32.const 0)) - ;; CHECK: (tag $tag (param i32)) + ;; CHECK: (tag $tag (type $1) (param i32)) (tag $tag (param i32)) (global $once (mut i32) (i32.const 0)) diff --git a/test/lit/passes/optimize-instructions-eh-legacy.wast b/test/lit/passes/optimize-instructions-eh-legacy.wast index dd51d6c1753..423d17d219b 100644 --- a/test/lit/passes/optimize-instructions-eh-legacy.wast +++ b/test/lit/passes/optimize-instructions-eh-legacy.wast @@ -3,7 +3,7 @@ ;; RUN: | filecheck %s (module - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $1) (param i32)) ;; CHECK: (func $dummy (type $0) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/optimize-instructions-iit-eh-legacy.wast b/test/lit/passes/optimize-instructions-iit-eh-legacy.wast index 79cb6f6f1c8..c9ed6ca2dfa 100644 --- a/test/lit/passes/optimize-instructions-iit-eh-legacy.wast +++ b/test/lit/passes/optimize-instructions-iit-eh-legacy.wast @@ -5,7 +5,7 @@ (module ;; CHECK: (type $struct.A (struct (field i32))) (type $struct.A (struct i32)) - ;; CHECK: (tag $e (param (ref null $struct.A))) + ;; CHECK: (tag $e (type $1) (param (ref null $struct.A))) (tag $e (param (ref null $struct.A))) ;; CHECK: (func $ref-cast-statically-removed (type $2) diff --git a/test/lit/passes/poppify.wast b/test/lit/passes/poppify.wast index 82825753202..d22bb874c7b 100644 --- a/test/lit/passes/poppify.wast +++ b/test/lit/passes/poppify.wast @@ -3,7 +3,7 @@ ;; RUN: wasm-opt %s --poppify --no-validation -all -S -o - | filecheck %s (module - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $3) (param i32)) (tag $e (param i32)) ;; CHECK: (func $id (type $4) (param $x i32) (result i32) diff --git a/test/lit/passes/remove-unused-brs-eh.wast b/test/lit/passes/remove-unused-brs-eh.wast index 336b3b5a807..ca492d4d0ff 100644 --- a/test/lit/passes/remove-unused-brs-eh.wast +++ b/test/lit/passes/remove-unused-brs-eh.wast @@ -2,11 +2,11 @@ ;; RUN: foreach %s %t wasm-opt -all --remove-unused-brs -S -o - | filecheck %s (module - ;; CHECK: (tag $e) + ;; CHECK: (tag $e (type $0)) (tag $e) - ;; CHECK: (tag $f) + ;; CHECK: (tag $f (type $0)) (tag $f) - ;; CHECK: (tag $g) + ;; CHECK: (tag $g (type $0)) (tag $g) ;; CHECK: (func $throw-caught-all (type $0) @@ -368,10 +368,10 @@ ;; CHECK: (import "a" "b" (func $effect (type $2) (result i32))) (import "a" "b" (func $effect (result i32))) - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $1) (param i32)) (tag $e (param i32)) - ;; CHECK: (tag $multi (param i32 f64)) + ;; CHECK: (tag $multi (type $3) (param i32 f64)) (tag $multi (param i32 f64)) ;; CHECK: (func $throw-caught-all (type $1) (param $x i32) diff --git a/test/lit/passes/remove-unused-names-eh-legacy.wast b/test/lit/passes/remove-unused-names-eh-legacy.wast index 797dabb55cd..ca753206992 100644 --- a/test/lit/passes/remove-unused-names-eh-legacy.wast +++ b/test/lit/passes/remove-unused-names-eh-legacy.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --remove-unused-names -all -S -o - | filecheck %s (module - ;; CHECK: (tag $tag$0 (param i32)) + ;; CHECK: (tag $tag$0 (type $1) (param i32)) (tag $tag$0 (param i32)) ;; CHECK: (func $func0 (type $0) diff --git a/test/lit/passes/rse-eh-legacy.wast b/test/lit/passes/rse-eh-legacy.wast index 95a1459c3ba..6a491242186 100644 --- a/test/lit/passes/rse-eh-legacy.wast +++ b/test/lit/passes/rse-eh-legacy.wast @@ -2,9 +2,9 @@ ;; RUN: wasm-opt %s --rse -all -S -o - | filecheck %s (module - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $1) (param i32)) (tag $e (param i32)) - ;; CHECK: (tag $e2) + ;; CHECK: (tag $e2 (type $0)) (tag $e2) ;; CHECK: (func $try1 (type $0) diff --git a/test/lit/passes/rse-eh.wast b/test/lit/passes/rse-eh.wast index 8c26946b1ac..5ef0cb72c82 100644 --- a/test/lit/passes/rse-eh.wast +++ b/test/lit/passes/rse-eh.wast @@ -8,9 +8,9 @@ ;; CHECK: (type $2 (func (param i32))) - ;; CHECK: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $2) (param i32)) (tag $e-i32 (param i32)) - ;; CHECK: (tag $e-empty) + ;; CHECK: (tag $e-empty (type $0)) (tag $e-empty) ;; CHECK: (func $foo (type $0) diff --git a/test/lit/passes/signature-pruning.wast b/test/lit/passes/signature-pruning.wast index 6a20d281551..f7ce07a621f 100644 --- a/test/lit/passes/signature-pruning.wast +++ b/test/lit/passes/signature-pruning.wast @@ -970,19 +970,17 @@ ) (module - ;; CHECK: (type $0 (func (param i32))) - ;; CHECK: (rec - ;; CHECK-NEXT: (type $1 (func (param i32))) + ;; CHECK-NEXT: (type $0 (func (param i32))) - ;; CHECK: (type $2 (func (result i32))) + ;; CHECK: (type $1 (func (result i32))) - ;; CHECK: (type $3 (func (param i32))) + ;; CHECK: (type $2 (func (param i32))) - ;; CHECK: (tag $tag (param i32)) + ;; CHECK: (tag $tag (type $2) (param i32)) (tag $tag (param i32)) - ;; CHECK: (func $catch-pop (type $2) (result i32) + ;; CHECK: (func $catch-pop (type $1) (result i32) ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (local $2 i32) @@ -1043,7 +1041,7 @@ ) ) - ;; CHECK: (func $target (type $1) (param $0 i32) + ;; CHECK: (func $target (type $0) (param $0 i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $0) @@ -1059,19 +1057,17 @@ ;; As above, but remove the other parameter (the pop). (module - ;; CHECK: (type $0 (func (param i32))) - ;; CHECK: (rec - ;; CHECK-NEXT: (type $1 (func (param i32))) + ;; CHECK-NEXT: (type $0 (func (param i32))) - ;; CHECK: (type $2 (func (result i32))) + ;; CHECK: (type $1 (func (result i32))) - ;; CHECK: (type $3 (func (param i32))) + ;; CHECK: (type $2 (func (param i32))) - ;; CHECK: (tag $tag (param i32)) + ;; CHECK: (tag $tag (type $2) (param i32)) (tag $tag (param i32)) - ;; CHECK: (func $catch-pop (type $2) (result i32) + ;; CHECK: (func $catch-pop (type $1) (result i32) ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (local $2 i32) @@ -1127,7 +1123,7 @@ ) ) - ;; CHECK: (func $target (type $1) (param $0 i32) + ;; CHECK: (func $target (type $0) (param $0 i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $0) diff --git a/test/lit/passes/simplify-locals-eh-legacy.wast b/test/lit/passes/simplify-locals-eh-legacy.wast index f9ab2f8c197..e113fcde922 100644 --- a/test/lit/passes/simplify-locals-eh-legacy.wast +++ b/test/lit/passes/simplify-locals-eh-legacy.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --simplify-locals -all -S -o - | filecheck %s (module - ;; CHECK: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $2) (param i32)) (tag $e-i32 (param i32)) ;; CHECK: (func $foo (type $3) (param $0 i32) (param $1 i32) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/simplify-locals-eh.wast b/test/lit/passes/simplify-locals-eh.wast index f455bd4e5a0..b65b5ba4613 100644 --- a/test/lit/passes/simplify-locals-eh.wast +++ b/test/lit/passes/simplify-locals-eh.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --simplify-locals -all -S -o - | filecheck %s (module - ;; CHECK: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $0) (param i32)) (tag $e-i32 (param i32)) ;; CHECK: (func $bar (type $1) (result i32) diff --git a/test/lit/passes/stack-ir-eh-legacy.wast b/test/lit/passes/stack-ir-eh-legacy.wast index a5f0b924952..14e53a33a98 100644 --- a/test/lit/passes/stack-ir-eh-legacy.wast +++ b/test/lit/passes/stack-ir-eh-legacy.wast @@ -3,7 +3,7 @@ ;; RUN: -all --print-stack-ir | filecheck %s (module - ;; CHECK: (tag $e0 (param i32)) + ;; CHECK: (tag $e0 (type $0) (param i32)) (tag $e0 (param i32)) ;; CHECK: (func $eh (type $1) diff --git a/test/lit/passes/stack-ir-eh.wast b/test/lit/passes/stack-ir-eh.wast index e06e5e5172d..0165bdc1341 100644 --- a/test/lit/passes/stack-ir-eh.wast +++ b/test/lit/passes/stack-ir-eh.wast @@ -3,7 +3,7 @@ ;; RUN: -all --print-stack-ir | filecheck %s (module - ;; CHECK: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $2) (param i32)) (tag $e-i32 (param i32)) ;; CHECK: (func $foo (type $0) diff --git a/test/lit/passes/stack-ir-roundtrip-eh-legacy.wast b/test/lit/passes/stack-ir-roundtrip-eh-legacy.wast index dbaa2c6015c..67c48c235bb 100644 --- a/test/lit/passes/stack-ir-roundtrip-eh-legacy.wast +++ b/test/lit/passes/stack-ir-roundtrip-eh-legacy.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --generate-stack-ir --roundtrip -all -S -o - | filecheck %s (module - ;; CHECK: (tag $tag (param i32)) + ;; CHECK: (tag $tag (type $0) (param i32)) (tag $tag (param i32)) ;; CHECK: (func $delegate-child (type $1) ;; CHECK-NEXT: (try diff --git a/test/lit/passes/translate-to-exnref.wast b/test/lit/passes/translate-to-exnref.wast index 388bcf8bda8..b4168505256 100644 --- a/test/lit/passes/translate-to-exnref.wast +++ b/test/lit/passes/translate-to-exnref.wast @@ -18,7 +18,7 @@ ;; CHECK: (type $6 (func (param i32 i64))) - ;; CHECK: (tag $e-empty) + ;; CHECK: (tag $e-empty (type $1)) ;; STACKIR-OPT: (type $0 (func (result i32 i64))) ;; STACKIR-OPT: (type $1 (func)) @@ -33,13 +33,13 @@ ;; STACKIR-OPT: (type $6 (func (param i32 i64))) - ;; STACKIR-OPT: (tag $e-empty) + ;; STACKIR-OPT: (tag $e-empty (type $1)) (tag $e-empty) - ;; CHECK: (tag $e-i32 (param i32)) - ;; STACKIR-OPT: (tag $e-i32 (param i32)) + ;; CHECK: (tag $e-i32 (type $5) (param i32)) + ;; STACKIR-OPT: (tag $e-i32 (type $5) (param i32)) (tag $e-i32 (param i32)) - ;; CHECK: (tag $e-i32-i64 (param i32 i64)) - ;; STACKIR-OPT: (tag $e-i32-i64 (param i32 i64)) + ;; CHECK: (tag $e-i32-i64 (type $6) (param i32 i64)) + ;; STACKIR-OPT: (tag $e-i32-i64 (type $6) (param i32 i64)) (tag $e-i32-i64 (param i32 i64)) ;; CHECK: (func $foo (type $1) diff --git a/test/lit/passes/type-refining.wast b/test/lit/passes/type-refining.wast index fad016e1d57..622e7422011 100644 --- a/test/lit/passes/type-refining.wast +++ b/test/lit/passes/type-refining.wast @@ -1247,9 +1247,7 @@ ;; CHECK: (type $5 (func (param (ref noextern)))) - ;; CHECK: (type $6 (func)) - - ;; CHECK: (tag $tag) + ;; CHECK: (tag $tag (type $1)) (tag $tag) ;; CHECK: (func $struct.new (type $2) (param $extern externref) (result anyref) diff --git a/test/lit/passes/unsubtyping.wast b/test/lit/passes/unsubtyping.wast index 14964716551..8696e565af5 100644 --- a/test/lit/passes/unsubtyping.wast +++ b/test/lit/passes/unsubtyping.wast @@ -922,16 +922,14 @@ ;; CHECK: (type $sub (sub $super (struct))) (type $sub (sub $super (struct))) - ;; CHECK: (type $2 (func)) - - ;; CHECK: (type $3 (func (param (ref $super)))) + ;; CHECK: (type $2 (func (param (ref $super)))) - ;; CHECK: (type $4 (func (param (ref $super)))) + ;; CHECK: (type $3 (func)) - ;; CHECK: (tag $t (param (ref $super))) + ;; CHECK: (tag $t (type $2) (param (ref $super))) (tag $t (param (ref $super))) - ;; CHECK: (func $throw (type $2) + ;; CHECK: (func $throw (type $3) ;; CHECK-NEXT: (throw $t ;; CHECK-NEXT: (struct.new_default $sub) ;; CHECK-NEXT: ) @@ -1790,16 +1788,14 @@ (type $sub (sub $super (func))) ) - ;; CHECK: (type $2 (func (result (ref $super)))) - - ;; CHECK: (type $3 (func (param (ref $sub)))) + ;; CHECK: (type $2 (func (param (ref $sub)))) - ;; CHECK: (type $4 (func (param (ref $sub)))) + ;; CHECK: (type $3 (func (result (ref $super)))) - ;; CHECK: (tag $tag (param (ref $sub))) + ;; CHECK: (tag $tag (type $2) (param (ref $sub))) (tag $tag (param (ref $sub))) - ;; CHECK: (func $test (type $2) (result (ref $super)) + ;; CHECK: (func $test (type $3) (result (ref $super)) ;; CHECK-NEXT: (block $label (result (ref $sub)) ;; CHECK-NEXT: (try_table (catch $tag $label) ;; CHECK-NEXT: (unreachable) diff --git a/test/lit/passes/vacuum-eh-legacy.wast b/test/lit/passes/vacuum-eh-legacy.wast index 0eb53bb56e3..cb780206a55 100644 --- a/test/lit/passes/vacuum-eh-legacy.wast +++ b/test/lit/passes/vacuum-eh-legacy.wast @@ -8,9 +8,9 @@ ;; CHECK: (table $t 0 funcref) (table $t 0 funcref) - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $1) (param i32)) (tag $e (param i32)) - ;; CHECK: (tag $e2 (param i32)) + ;; CHECK: (tag $e2 (type $1) (param i32)) (tag $e2 (param i32)) ;; CHECK: (func $try-test (type $void) diff --git a/test/lit/passes/vacuum-eh.wast b/test/lit/passes/vacuum-eh.wast index 4df41f854f1..fb0cc0732ce 100644 --- a/test/lit/passes/vacuum-eh.wast +++ b/test/lit/passes/vacuum-eh.wast @@ -8,9 +8,9 @@ ;; CHECK: (table $t 0 funcref) (table $t 0 funcref) - ;; CHECK: (tag $e (param i32)) + ;; CHECK: (tag $e (type $1) (param i32)) (tag $e (param i32)) - ;; CHECK: (tag $e2 (param i32)) + ;; CHECK: (tag $e2 (type $1) (param i32)) (tag $e2 (param i32)) ;; CHECK: (func $try_table-test (type $void) diff --git a/test/lit/passes/vacuum-tnh.wast b/test/lit/passes/vacuum-tnh.wast index 1bb4ba13976..8bfcfd95170 100644 --- a/test/lit/passes/vacuum-tnh.wast +++ b/test/lit/passes/vacuum-tnh.wast @@ -8,10 +8,10 @@ (module ;; YESTNH: (type $struct (struct (field (mut i32)))) - ;; YESTNH: (tag $tag (param i32)) + ;; YESTNH: (tag $tag (type $1) (param i32)) ;; NO_TNH: (type $struct (struct (field (mut i32)))) - ;; NO_TNH: (tag $tag (param i32)) + ;; NO_TNH: (tag $tag (type $2) (param i32)) (tag $tag (param i32)) (memory 1 1) diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast index 9cf7f27c5d0..9f85b526fc2 100644 --- a/test/lit/wat-kitchen-sink.wast +++ b/test/lit/wat-kitchen-sink.wast @@ -300,11 +300,11 @@ ;; CHECK: (import "mod" "imported-f" (func $fimport$1 (type $5) (result i32 i64))) - ;; CHECK: (import "mod" "t0" (tag $imported (param i32 i64))) + ;; CHECK: (import "mod" "t0" (tag $imported (type $7) (param i32 i64))) - ;; CHECK: (import "mod" "t1" (tag $eimport$0)) + ;; CHECK: (import "mod" "t1" (tag $eimport$0 (type $0))) - ;; CHECK: (import "mod" "imported-tag" (tag $eimport$1)) + ;; CHECK: (import "mod" "imported-tag" (tag $eimport$1 (type $0))) ;; CHECK: (global $global$2 (mut i32) (i32.const 0)) @@ -413,18 +413,18 @@ ;; tags (tag) - ;; CHECK: (tag $tag$2) + ;; CHECK: (tag $tag$2 (type $0)) - ;; CHECK: (tag $empty) + ;; CHECK: (tag $empty (type $0)) (tag $empty) - ;; CHECK: (tag $tag-i32 (param i32)) + ;; CHECK: (tag $tag-i32 (type $18) (param i32)) (tag $tag-i32 (param $x i32)) - ;; CHECK: (tag $tag-pair (param i32 i64)) + ;; CHECK: (tag $tag-pair (type $7) (param i32 i64)) (tag $tag-pair (param i32 i64)) - ;; CHECK: (tag $tag-pair-to-pair (param i32 i64) (result i32 i64)) + ;; CHECK: (tag $tag-pair-to-pair (type $21) (param i32 i64) (result i32 i64)) (tag $tag-pair-to-pair (param i32 i64) (result i32 i64)) ;; explicit exports diff --git a/test/metadce/rooted-export.wast.dced b/test/metadce/rooted-export.wast.dced index 186746e5602..ceaf18277c7 100644 --- a/test/metadce/rooted-export.wast.dced +++ b/test/metadce/rooted-export.wast.dced @@ -1,7 +1,7 @@ (module (type $0 (func (param i32))) (type $1 (func)) - (tag $b_wasm_tag (param i32)) + (tag $b_wasm_tag (type $0) (param i32)) (export "wasm_func_b" (func $b_wasm_func)) (export "wasm_tag_b" (tag $b_wasm_tag)) (func $b_wasm_func (type $1) diff --git a/test/metadce/tag.wast.dced b/test/metadce/tag.wast.dced index f2d5cf6250b..498906c59bf 100644 --- a/test/metadce/tag.wast.dced +++ b/test/metadce/tag.wast.dced @@ -1,7 +1,7 @@ (module (type $0 (func)) - (import "env" "imported_tag" (tag $t0)) - (tag $t1) + (import "env" "imported_tag" (tag $t0 (type $0))) + (tag $t1 (type $0)) (export "test" (func $test)) (func $test (type $0) (try diff --git a/test/passes/dwarf_with_exceptions.bin.txt b/test/passes/dwarf_with_exceptions.bin.txt index a4e3b5e614d..f6a40099430 100644 --- a/test/passes/dwarf_with_exceptions.bin.txt +++ b/test/passes/dwarf_with_exceptions.bin.txt @@ -8,7 +8,7 @@ (import "env" "_ZSt9terminatev" (func $std::terminate\28\29)) (global $__stack_pointer (mut i32) (i32.const 66560)) (memory $0 2) - (tag $tag$0 (param i32)) + (tag $tag$0 (type $1) (param i32)) (export "memory" (memory $0)) (func $__wasm_call_ctors ) @@ -414,7 +414,7 @@ file_names[ 1]: (import "env" "_ZSt9terminatev" (func $std::terminate\28\29)) (global $__stack_pointer (mut i32) (i32.const 66560)) (memory $0 2) - (tag $tag$0 (param i32)) + (tag $tag$0 (type $1) (param i32)) (export "memory" (memory $0)) (func $__wasm_call_ctors ) diff --git a/test/passes/metrics_all-features.txt b/test/passes/metrics_all-features.txt index a5e80db455c..14e0f9bce69 100644 --- a/test/passes/metrics_all-features.txt +++ b/test/passes/metrics_all-features.txt @@ -25,8 +25,8 @@ total (data $0 (i32.const 0) "\ff\ef\0f\1f 0@P\99") (table $0 256 256 funcref) (elem $0 (i32.const 0) $ifs $ifs $ifs) - (tag $e0 (param i32)) - (tag $e1 (param i32 i32)) + (tag $e0 (type $0) (param i32)) + (tag $e1 (type $1) (param i32 i32)) (func $ifs (type $0) (param $x i32) (local $y f32) (block $block0 diff --git a/test/passes/minify-imports-and-exports_all-features.txt b/test/passes/minify-imports-and-exports_all-features.txt index 87aa3c2f289..17f954cd80f 100644 --- a/test/passes/minify-imports-and-exports_all-features.txt +++ b/test/passes/minify-imports-and-exports_all-features.txt @@ -10014,8 +10014,8 @@ longname4880 => zza (import "other" "anything" (func $internalInfinity (type $0))) (import "wasi_unstable" "f" (func $internal3_wasi (type $0))) (import "wasi_unstable" "LBa" (func $internal3_wasi_only (type $0))) - (import "env" "MBa" (tag $tagname1 (param i32))) - (tag $tag1 (param i32 i32)) + (import "env" "MBa" (tag $tagname1 (type $1) (param i32))) + (tag $tag1 (type $2) (param i32 i32)) (export "NBa" (func $foo1)) (export "OBa" (func $foo2)) (export "PBa" (tag $tag1)) diff --git a/test/passes/minify-imports_all-features.txt b/test/passes/minify-imports_all-features.txt index ec25564396a..bff76bb395c 100644 --- a/test/passes/minify-imports_all-features.txt +++ b/test/passes/minify-imports_all-features.txt @@ -10008,8 +10008,8 @@ longname4880 => zza (import "env" "JBa" (func $internal4998 (type $0))) (import "env" "KBa" (func $internal4999 (type $0))) (import "other" "anything" (func $internalInfinity (type $0))) - (import "env" "LBa" (tag $tagname1 (param i32))) - (tag $tag1 (param i32 i32)) + (import "env" "LBa" (tag $tagname1 (type $1) (param i32))) + (tag $tag1 (type $2) (param i32 i32)) (export "foo1" (func $foo1)) (export "foo2" (func $foo2)) (export "tag1" (tag $tag1)) diff --git a/test/passes/remove-unused-names_merge-blocks_all-features.txt b/test/passes/remove-unused-names_merge-blocks_all-features.txt index 2169d636b71..974b76b4fe4 100644 --- a/test/passes/remove-unused-names_merge-blocks_all-features.txt +++ b/test/passes/remove-unused-names_merge-blocks_all-features.txt @@ -1655,7 +1655,7 @@ (module (type $0 (func)) (type $1 (func (param i32))) - (tag $e (param i32)) + (tag $e (type $1) (param i32)) (func $foo (type $0) ) (func $throw (type $0) diff --git a/test/passes/remove-unused-nonfunction-module-elements_all-features.txt b/test/passes/remove-unused-nonfunction-module-elements_all-features.txt index c56b99253d1..83a7c472b48 100644 --- a/test/passes/remove-unused-nonfunction-module-elements_all-features.txt +++ b/test/passes/remove-unused-nonfunction-module-elements_all-features.txt @@ -342,7 +342,7 @@ (module (type $1 (func (param i64))) (type $0 (func (param i32))) - (tag $e1 (param i64)) + (tag $e1 (type $1) (param i64)) (export "e1" (tag $e1)) (func $f (type $0) (param $0 i32) ) diff --git a/test/try-delegate.wasm.fromBinary b/test/try-delegate.wasm.fromBinary index a3e799627d6..ba3b098033b 100644 --- a/test/try-delegate.wasm.fromBinary +++ b/test/try-delegate.wasm.fromBinary @@ -1,6 +1,6 @@ (module (type $0 (func)) - (tag $tag$0) + (tag $tag$0 (type $0)) (func $0 (try $label (do From 6505e7260377c20661c09c2c00a280321d2b6501 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 15 Jan 2025 14:10:35 -0800 Subject: [PATCH 2/3] Update src/wasm.h Co-authored-by: Alon Zakai --- src/wasm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wasm.h b/src/wasm.h index e8e60789a46..eee81fe106b 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2298,6 +2298,7 @@ class Global : public Importable { class Tag : public Importable { public: HeapType type; + Type params() { return type.getSignature().params; } Type results() { return type.getSignature().results; } }; From 3662fbaeba5e5d9167a52df426eda457efdd54c3 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 15 Jan 2025 14:47:24 -0800 Subject: [PATCH 3/3] update manual tests --- test/lit/binary/stacky-eh-legacy.test | 2 +- test/lit/binary/stacky-nn-tuple.test | 2 +- test/lit/merge/types.wat | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/lit/binary/stacky-eh-legacy.test b/test/lit/binary/stacky-eh-legacy.test index 792c436d527..9c933574c67 100644 --- a/test/lit/binary/stacky-eh-legacy.test +++ b/test/lit/binary/stacky-eh-legacy.test @@ -41,7 +41,7 @@ ;; CHECK: (type $1 (func)) -;; CHECK: (tag $tag$0 (param i32)) +;; CHECK: (tag $tag$0 (type $0) (param i32)) ;; CHECK: (func $0 ;; CHECK-NEXT: (local $0 i32) diff --git a/test/lit/binary/stacky-nn-tuple.test b/test/lit/binary/stacky-nn-tuple.test index 1f6b5bb59eb..c7ab57e9090 100644 --- a/test/lit/binary/stacky-nn-tuple.test +++ b/test/lit/binary/stacky-nn-tuple.test @@ -47,7 +47,7 @@ ;; CHECK: (type $3 (func)) -;; CHECK: (tag $tag$0 (param (ref null $0) (ref null $1))) +;; CHECK: (tag $tag$0 (type $2) (param (ref null $0) (ref null $1))) ;; CHECK: (func $0 (type $3) ;; CHECK-NEXT: (local $0 (ref null $0)) diff --git a/test/lit/merge/types.wat b/test/lit/merge/types.wat index e9ee76b3478..956d885e034 100644 --- a/test/lit/merge/types.wat +++ b/test/lit/merge/types.wat @@ -17,8 +17,8 @@ ;; CHECK-NEXT: Type mismatch when importing global g2 from module env ($bad3): export type eqref is different from import type i31ref. ;; CHECK-NEXT: Type mismatch when importing global g2 from module env ($bad4): export type eqref is different from import type anyref. ;; CHECK-NEXT: Type mismatch when importing global g1 from module env ($bad5): type eqref is not a subtype of i31ref. -;; CHECK-NEXT: Type mismatch when importing tag t from module env ($bad1): export type (func (param eqref)) is different from import type (func (param anyref)). -;; CHECK-NEXT: Type mismatch when importing tag t from module env ($bad2): export type (func (param eqref)) is different from import type (func (param i31ref)). +;; CHECK-NEXT: Type mismatch when importing tag t from module env ($bad1): export type (type $func.0 (func (param eqref))) is different from import type (type $func.0 (func (param anyref))). +;; CHECK-NEXT: Type mismatch when importing tag t from module env ($bad2): export type (type $func.0 (func (param eqref))) is different from import type (type $func.0 (func (param i31ref))). ;; CHECK-NEXT: Fatal: import/export mismatches (module