diff --git a/lld/include/lld/Common/LLVM.h b/lld/include/lld/Common/LLVM.h --- a/lld/include/lld/Common/LLVM.h +++ b/lld/include/lld/Common/LLVM.h @@ -45,7 +45,6 @@ namespace wasm { struct WasmTag; -struct WasmTagType; struct WasmFunction; struct WasmGlobal; struct WasmGlobalType; @@ -97,7 +96,6 @@ using llvm::wasm::WasmTable; using llvm::wasm::WasmTableType; using llvm::wasm::WasmTag; -using llvm::wasm::WasmTagType; } // end namespace lld. namespace std { diff --git a/lld/test/wasm/tag-section.ll b/lld/test/wasm/tag-section.ll --- a/lld/test/wasm/tag-section.ll +++ b/lld/test/wasm/tag-section.ll @@ -30,10 +30,7 @@ ; CHECK-NEXT: ReturnTypes: [] ; CHECK: - Type: TAG -; CHECK-NEXT: Tags: -; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Attribute: 0 -; CHECK-NEXT: SigIndex: 1 +; CHECK-NEXT: TagTypes: [ 1 ] ; Global section has to come after tag section ; CHECK: - Type: GLOBAL diff --git a/lld/wasm/InputElement.h b/lld/wasm/InputElement.h --- a/lld/wasm/InputElement.h +++ b/lld/wasm/InputElement.h @@ -74,14 +74,9 @@ class InputTag : public InputElement { public: InputTag(const WasmSignature &s, const WasmTag &t, ObjFile *f) - : InputElement(t.SymbolName, f), signature(s), type(t.Type) {} - - const WasmTagType &getType() const { return type; } + : InputElement(t.SymbolName, f), signature(s) {} const WasmSignature &signature; - -private: - WasmTagType type; }; class InputTable : public InputElement { diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -336,10 +336,9 @@ LLVM_DEBUG(dbgs() << "Synthesizing symbol for table import: " << info->Name << "\n"); const WasmGlobalType *globalType = nullptr; - const WasmTagType *tagType = nullptr; const WasmSignature *signature = nullptr; - auto *wasmSym = make(*info, globalType, &tableImport->Table, - tagType, signature); + auto *wasmSym = + make(*info, globalType, &tableImport->Table, signature); Symbol *sym = createUndefined(*wasmSym, false); // We're only sure it's a TableSymbol if the createUndefined succeeded. if (errorCount()) @@ -516,7 +515,7 @@ // Populate `Tags`. for (const WasmTag &t : wasmObj->tags()) - tags.emplace_back(make(types[t.Type.SigIndex], t, this)); + tags.emplace_back(make(types[t.SigIndex], t, this)); // Populate `Symbols` based on the symbols in the object. symbols.reserve(wasmObj->getNumberOfSymbols()); diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp --- a/lld/wasm/SymbolTable.cpp +++ b/lld/wasm/SymbolTable.cpp @@ -169,7 +169,6 @@ } static void checkTagType(const Symbol *existing, const InputFile *file, - const WasmTagType *newType, const WasmSignature *newSig) { const auto *existingTag = dyn_cast(existing); if (!isa(existing)) { @@ -177,12 +176,7 @@ return; } - const WasmTagType *oldType = cast(existing)->getTagType(); const WasmSignature *oldSig = existingTag->signature; - if (newType->Attribute != oldType->Attribute) - error("Tag type mismatch: " + existing->getName() + "\n>>> defined as " + - toString(*oldType) + " in " + toString(existing->getFile()) + - "\n>>> defined as " + toString(*newType) + " in " + toString(file)); if (*newSig != *oldSig) warn("Tag signature mismatch: " + existing->getName() + "\n>>> defined as " + toString(*oldSig) + " in " + @@ -430,7 +424,7 @@ return s; } - checkTagType(s, file, &tag->getType(), &tag->signature); + checkTagType(s, file, &tag->signature); if (shouldReplace(s, file, flags)) replaceSym(); diff --git a/lld/wasm/Symbols.h b/lld/wasm/Symbols.h --- a/lld/wasm/Symbols.h +++ b/lld/wasm/Symbols.h @@ -439,8 +439,6 @@ public: static bool classof(const Symbol *s) { return s->kind() == DefinedTagKind; } - const WasmTagType *getTagType() const { return tagType; } - // Get/set the tag index uint32_t getTagIndex() const; void setTagIndex(uint32_t index); @@ -450,10 +448,9 @@ protected: TagSymbol(StringRef name, Kind k, uint32_t flags, InputFile *f, - const WasmTagType *tagType, const WasmSignature *sig) - : Symbol(name, k, flags, f), signature(sig), tagType(tagType) {} + const WasmSignature *sig) + : Symbol(name, k, flags, f), signature(sig) {} - const WasmTagType *tagType; uint32_t tagIndex = INVALID_INDEX; }; diff --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp --- a/lld/wasm/Symbols.cpp +++ b/lld/wasm/Symbols.cpp @@ -369,7 +369,6 @@ DefinedTag::DefinedTag(StringRef name, uint32_t flags, InputFile *file, InputTag *tag) : TagSymbol(name, DefinedTagKind, flags, file, - tag ? &tag->getType() : nullptr, tag ? &tag->signature : nullptr), tag(tag) {} diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp --- a/lld/wasm/SyntheticSections.cpp +++ b/lld/wasm/SyntheticSections.cpp @@ -226,8 +226,7 @@ import.Global = *globalSym->getGlobalType(); } else if (auto *tagSym = dyn_cast(sym)) { import.Kind = WASM_EXTERNAL_TAG; - import.Tag.Attribute = tagSym->getTagType()->Attribute; - import.Tag.SigIndex = out.typeSec->lookupType(*tagSym->signature); + import.SigIndex = out.typeSec->lookupType(*tagSym->signature); } else { auto *tableSym = cast(sym); import.Kind = WASM_EXTERNAL_TABLE; @@ -332,9 +331,8 @@ writeUleb128(os, inputTags.size(), "tag count"); for (InputTag *t : inputTags) { - WasmTagType type = t->getType(); - type.SigIndex = out.typeSec->lookupType(t->signature); - writeTagType(os, type); + writeUleb128(os, 0, "tag attribute"); // Reserved "attribute" field + writeUleb128(os, out.typeSec->lookupType(t->signature), "sig index"); } } diff --git a/lld/wasm/WriterUtils.h b/lld/wasm/WriterUtils.h --- a/lld/wasm/WriterUtils.h +++ b/lld/wasm/WriterUtils.h @@ -55,10 +55,6 @@ void writeGlobalType(raw_ostream &os, const llvm::wasm::WasmGlobalType &type); -void writeTagType(raw_ostream &os, const llvm::wasm::WasmTagType &type); - -void writeTag(raw_ostream &os, const llvm::wasm::WasmTag &tag); - void writeTableType(raw_ostream &os, const llvm::wasm::WasmTableType &type); void writeImport(raw_ostream &os, const llvm::wasm::WasmImport &import); @@ -70,7 +66,6 @@ std::string toString(llvm::wasm::ValType type); std::string toString(const llvm::wasm::WasmSignature &sig); std::string toString(const llvm::wasm::WasmGlobalType &type); -std::string toString(const llvm::wasm::WasmTagType &type); std::string toString(const llvm::wasm::WasmTableType &type); } // namespace lld diff --git a/lld/wasm/WriterUtils.cpp b/lld/wasm/WriterUtils.cpp --- a/lld/wasm/WriterUtils.cpp +++ b/lld/wasm/WriterUtils.cpp @@ -58,12 +58,6 @@ toString(static_cast(type.Type)); } -std::string toString(const WasmTagType &type) { - if (type.Attribute == WASM_TAG_ATTRIBUTE_EXCEPTION) - return "exception"; - return "unknown"; -} - static std::string toString(const llvm::wasm::WasmLimits &limits) { std::string ret; ret += "flags=0x" + std::to_string(limits.Flags); @@ -204,15 +198,6 @@ writeU8(os, type.Mutable, "global mutable"); } -void writeTagType(raw_ostream &os, const WasmTagType &type) { - writeUleb128(os, type.Attribute, "tag attribute"); - writeUleb128(os, type.SigIndex, "sig index"); -} - -void writeTag(raw_ostream &os, const WasmTag &tag) { - writeTagType(os, tag.Type); -} - void writeTableType(raw_ostream &os, const WasmTableType &type) { writeValueType(os, ValType(type.ElemType), "table type"); writeLimits(os, type.Limits); @@ -230,7 +215,8 @@ writeGlobalType(os, import.Global); break; case WASM_EXTERNAL_TAG: - writeTagType(os, import.Tag); + writeUleb128(os, 0, "tag attribute"); // Reserved "attribute" field + writeUleb128(os, import.SigIndex, "import sig index"); break; case WASM_EXTERNAL_MEMORY: writeLimits(os, import.Memory); diff --git a/llvm/include/llvm/BinaryFormat/Wasm.h b/llvm/include/llvm/BinaryFormat/Wasm.h --- a/llvm/include/llvm/BinaryFormat/Wasm.h +++ b/llvm/include/llvm/BinaryFormat/Wasm.h @@ -107,15 +107,9 @@ StringRef SymbolName; // from the "linking" section }; -struct WasmTagType { - // Kind of tag. Currently only WASM_TAG_ATTRIBUTE_EXCEPTION is possible. - uint8_t Attribute; - uint32_t SigIndex; -}; - struct WasmTag { uint32_t Index; - WasmTagType Type; + uint32_t SigIndex; StringRef SymbolName; // from the "linking" section }; @@ -128,7 +122,6 @@ WasmGlobalType Global; WasmTableType Table; WasmLimits Memory; - WasmTagType Tag; }; }; diff --git a/llvm/include/llvm/MC/MCSymbolWasm.h b/llvm/include/llvm/MC/MCSymbolWasm.h --- a/llvm/include/llvm/MC/MCSymbolWasm.h +++ b/llvm/include/llvm/MC/MCSymbolWasm.h @@ -27,7 +27,6 @@ wasm::WasmSignature *Signature = nullptr; Optional GlobalType; Optional TableType; - Optional TagType; /// An expression describing how to calculate the size of a symbol. If a /// symbol has no size this field will be NULL. @@ -147,12 +146,6 @@ wasm::WasmLimits Limits = {wasm::WASM_LIMITS_FLAG_NONE, 0, 0}; setTableType({uint8_t(VT), Limits}); } - - const wasm::WasmTagType &getTagType() const { - assert(TagType.hasValue()); - return TagType.getValue(); - } - void setTagType(wasm::WasmTagType ET) { TagType = ET; } }; } // end namespace llvm diff --git a/llvm/include/llvm/Object/Wasm.h b/llvm/include/llvm/Object/Wasm.h --- a/llvm/include/llvm/Object/Wasm.h +++ b/llvm/include/llvm/Object/Wasm.h @@ -37,15 +37,13 @@ WasmSymbol(const wasm::WasmSymbolInfo &Info, const wasm::WasmGlobalType *GlobalType, const wasm::WasmTableType *TableType, - const wasm::WasmTagType *TagType, const wasm::WasmSignature *Signature) : Info(Info), GlobalType(GlobalType), TableType(TableType), - TagType(TagType), Signature(Signature) {} + Signature(Signature) {} const wasm::WasmSymbolInfo &Info; const wasm::WasmGlobalType *GlobalType; const wasm::WasmTableType *TableType; - const wasm::WasmTagType *TagType; const wasm::WasmSignature *Signature; bool isTypeFunction() const { @@ -274,7 +272,6 @@ wasm::WasmProducerInfo ProducerInfo; std::vector TargetFeatures; std::vector Signatures; - std::vector FunctionTypes; std::vector Tables; std::vector Memories; std::vector Globals; diff --git a/llvm/include/llvm/ObjectYAML/WasmYAML.h b/llvm/include/llvm/ObjectYAML/WasmYAML.h --- a/llvm/include/llvm/ObjectYAML/WasmYAML.h +++ b/llvm/include/llvm/ObjectYAML/WasmYAML.h @@ -77,12 +77,6 @@ wasm::WasmInitExpr InitExpr; }; -struct Tag { - uint32_t Index; - uint32_t Attribute; - uint32_t SigIndex; -}; - struct Import { StringRef Module; StringRef Field; @@ -92,7 +86,7 @@ Global GlobalImport; Table TableImport; Limits Memory; - Tag TagImport; + uint32_t TagIndex; }; }; @@ -329,7 +323,7 @@ return S->Type == wasm::WASM_SEC_TAG; } - std::vector Tags; + std::vector TagTypes; }; struct GlobalSection : Section { @@ -431,7 +425,6 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::InitFunction) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::ComdatEntry) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Comdat) -LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Tag) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::DylinkExport) namespace llvm { @@ -577,10 +570,6 @@ static void enumeration(IO &IO, WasmYAML::RelocType &Kind); }; -template <> struct MappingTraits { - static void mapping(IO &IO, WasmYAML::Tag &Tag); -}; - template <> struct MappingTraits { static void mapping(IO &IO, WasmYAML::DylinkExport &Export); }; diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -317,7 +317,7 @@ uint32_t writeCodeSection(const MCAssembler &Asm, const MCAsmLayout &Layout, ArrayRef Functions); uint32_t writeDataSection(const MCAsmLayout &Layout); - void writeTagSection(ArrayRef Tags); + void writeTagSection(ArrayRef TagTypes); void writeGlobalSection(ArrayRef Globals); void writeTableSection(ArrayRef Tables); void writeRelocSection(uint32_t SectionIndex, StringRef Name, @@ -831,8 +831,8 @@ encodeULEB128(NumElements, W->OS); // initial break; case wasm::WASM_EXTERNAL_TAG: - W->OS << char(Import.Tag.Attribute); - encodeULEB128(Import.Tag.SigIndex, W->OS); + W->OS << char(0); // Reserved 'attribute' field + encodeULEB128(Import.SigIndex, W->OS); break; default: llvm_unreachable("unsupported import kind"); @@ -856,17 +856,17 @@ endSection(Section); } -void WasmObjectWriter::writeTagSection(ArrayRef Tags) { - if (Tags.empty()) +void WasmObjectWriter::writeTagSection(ArrayRef TagTypes) { + if (TagTypes.empty()) return; SectionBookkeeping Section; startSection(Section, wasm::WASM_SEC_TAG); - encodeULEB128(Tags.size(), W->OS); - for (const wasm::WasmTagType &Tag : Tags) { - W->OS << char(Tag.Attribute); - encodeULEB128(Tag.SigIndex, W->OS); + encodeULEB128(TagTypes.size(), W->OS); + for (uint32_t Index : TagTypes) { + W->OS << char(0); // Reserved 'attribute' field + encodeULEB128(Index, W->OS); } endSection(Section); @@ -1346,8 +1346,7 @@ Import.Module = WS.getImportModule(); Import.Field = WS.getImportName(); Import.Kind = wasm::WASM_EXTERNAL_TAG; - Import.Tag.Attribute = wasm::WASM_TAG_ATTRIBUTE_EXCEPTION; - Import.Tag.SigIndex = getTagType(WS); + Import.SigIndex = getTagType(WS); Imports.push_back(Import); assert(WasmIndices.count(&WS) == 0); WasmIndices[&WS] = NumTagImports++; @@ -1415,7 +1414,7 @@ SmallVector TableElems; SmallVector Imports; SmallVector Exports; - SmallVector Tags; + SmallVector TagTypes; SmallVector Globals; SmallVector Tables; SmallVector SymbolInfos; @@ -1654,13 +1653,11 @@ // (__c_longjmp) unsigned Index; if (WS.isDefined()) { - Index = NumTagImports + Tags.size(); - wasm::WasmTagType Tag; - Tag.SigIndex = getTagType(WS); - Tag.Attribute = wasm::WASM_TAG_ATTRIBUTE_EXCEPTION; + Index = NumTagImports + TagTypes.size(); + uint32_t SigIndex = getTagType(WS); assert(WasmIndices.count(&WS) == 0); WasmIndices[&WS] = Index; - Tags.push_back(Tag); + TagTypes.push_back(SigIndex); } else { // An import; the index was assigned above. assert(WasmIndices.count(&WS) > 0); @@ -1878,7 +1875,7 @@ writeFunctionSection(Functions); writeTableSection(Tables); // Skip the "memory" section; we import the memory instead. - writeTagSection(Tags); + writeTagSection(TagTypes); writeGlobalSection(Globals); writeExportSection(Exports); const MCSymbol *IndirectFunctionTable = diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -582,7 +582,6 @@ const wasm::WasmSignature *Signature = nullptr; const wasm::WasmGlobalType *GlobalType = nullptr; const wasm::WasmTableType *TableType = nullptr; - const wasm::WasmTagType *TagType = nullptr; Info.Kind = readUint8(Ctx); Info.Flags = readVaruint32(Ctx); @@ -727,8 +726,7 @@ Info.Name = readString(Ctx); unsigned TagIndex = Info.ElementIndex - NumImportedTags; wasm::WasmTag &Tag = Tags[TagIndex]; - Signature = &Signatures[Tag.Type.SigIndex]; - TagType = &Tag.Type; + Signature = &Signatures[Tag.SigIndex]; if (Tag.SymbolName.empty()) Tag.SymbolName = Info.Name; @@ -740,8 +738,7 @@ } else { Info.Name = Import.Field; } - TagType = &Import.Tag; - Signature = &Signatures[TagType->SigIndex]; + Signature = &Signatures[Import.SigIndex]; if (!Import.Module.empty()) { Info.ImportModule = Import.Module; } @@ -763,7 +760,7 @@ object_error::parse_failed); LinkingData.SymbolTable.emplace_back(Info); Symbols.emplace_back(LinkingData.SymbolTable.back(), GlobalType, TableType, - TagType, Signature); + Signature); LLVM_DEBUG(dbgs() << "Adding symbol: " << Symbols.back() << "\n"); } @@ -1090,6 +1087,7 @@ Error WasmObjectFile::parseImportSection(ReadContext &Ctx) { uint32_t Count = readVaruint32(Ctx); + uint32_t NumTypes = Signatures.size(); Imports.reserve(Count); for (uint32_t I = 0; I < Count; I++) { wasm::WasmImport Im; @@ -1100,6 +1098,9 @@ case wasm::WASM_EXTERNAL_FUNCTION: NumImportedFunctions++; Im.SigIndex = readVaruint32(Ctx); + if (Im.SigIndex >= NumTypes) + return make_error("invalid function type", + object_error::parse_failed); break; case wasm::WASM_EXTERNAL_GLOBAL: NumImportedGlobals++; @@ -1123,8 +1124,10 @@ } case wasm::WASM_EXTERNAL_TAG: NumImportedTags++; - Im.Tag.Attribute = readUint8(Ctx); - Im.Tag.SigIndex = readVarint32(Ctx); + Im.SigIndex = readVaruint32(Ctx); + if (Im.SigIndex >= NumTypes) + return make_error("invalid tag type", + object_error::parse_failed); break; default: return make_error("unexpected import kind", @@ -1198,11 +1201,19 @@ TagSection = Sections.size(); uint32_t Count = readVaruint32(Ctx); Tags.reserve(Count); + uint32_t NumTypes = Signatures.size(); while (Count--) { + char Attr = readUint8(Ctx); // Reserved 'attribute' field + if (Attr != 0) + return make_error("invalid attribute", + object_error::parse_failed); + uint32_t Type = readVaruint32(Ctx); + if (Type >= NumTypes) + return make_error("invalid tag type", + object_error::parse_failed); wasm::WasmTag Tag; Tag.Index = NumImportedTags + Tags.size(); - Tag.Type.Attribute = readUint8(Ctx); - Tag.Type.SigIndex = readVaruint32(Ctx); + Tag.SigIndex = Type; Tags.push_back(Tag); } diff --git a/llvm/lib/ObjectYAML/WasmEmitter.cpp b/llvm/lib/ObjectYAML/WasmEmitter.cpp --- a/llvm/lib/ObjectYAML/WasmEmitter.cpp +++ b/llvm/lib/ObjectYAML/WasmEmitter.cpp @@ -397,8 +397,8 @@ NumImportedGlobals++; break; case wasm::WASM_EXTERNAL_TAG: - writeUint32(OS, Import.TagImport.Attribute); - writeUint32(OS, Import.TagImport.SigIndex); + writeUint8(OS, 0); // Reserved 'attribute' field + encodeULEB128(Import.SigIndex, OS); NumImportedTags++; break; case wasm::WASM_EXTERNAL_MEMORY: @@ -462,16 +462,10 @@ void WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::TagSection &Section) { - encodeULEB128(Section.Tags.size(), OS); - uint32_t ExpectedIndex = NumImportedTags; - for (auto &Tag : Section.Tags) { - if (Tag.Index != ExpectedIndex) { - reportError("unexpected tag index: " + Twine(Tag.Index)); - return; - } - ++ExpectedIndex; - encodeULEB128(Tag.Attribute, OS); - encodeULEB128(Tag.SigIndex, OS); + encodeULEB128(Section.TagTypes.size(), OS); + for (uint32_t TagType : Section.TagTypes) { + writeUint8(OS, 0); // Reserved 'attribute' field + encodeULEB128(TagType, OS); } } diff --git a/llvm/lib/ObjectYAML/WasmYAML.cpp b/llvm/lib/ObjectYAML/WasmYAML.cpp --- a/llvm/lib/ObjectYAML/WasmYAML.cpp +++ b/llvm/lib/ObjectYAML/WasmYAML.cpp @@ -123,7 +123,7 @@ static void sectionMapping(IO &IO, WasmYAML::TagSection &Section) { commonSectionMapping(IO, Section); - IO.mapOptional("Tags", Section.Tags); + IO.mapOptional("TagTypes", Section.TagTypes); } static void sectionMapping(IO &IO, WasmYAML::GlobalSection &Section) { @@ -392,14 +392,12 @@ IO.mapRequired("Module", Import.Module); IO.mapRequired("Field", Import.Field); IO.mapRequired("Kind", Import.Kind); - if (Import.Kind == wasm::WASM_EXTERNAL_FUNCTION) { + if (Import.Kind == wasm::WASM_EXTERNAL_FUNCTION || + Import.Kind == wasm::WASM_EXTERNAL_TAG) { IO.mapRequired("SigIndex", Import.SigIndex); } else if (Import.Kind == wasm::WASM_EXTERNAL_GLOBAL) { IO.mapRequired("GlobalType", Import.GlobalImport.Type); IO.mapRequired("GlobalMutable", Import.GlobalImport.Mutable); - } else if (Import.Kind == wasm::WASM_EXTERNAL_TAG) { - IO.mapRequired("TagAttribute", Import.TagImport.Attribute); - IO.mapRequired("TagSigIndex", Import.TagImport.SigIndex); } else if (Import.Kind == wasm::WASM_EXTERNAL_TABLE) { IO.mapRequired("Table", Import.TableImport); } else if (Import.Kind == wasm::WASM_EXTERNAL_MEMORY) { @@ -526,12 +524,6 @@ } } -void MappingTraits::mapping(IO &IO, WasmYAML::Tag &Tag) { - IO.mapRequired("Index", Tag.Index); - IO.mapRequired("Attribute", Tag.Attribute); - IO.mapRequired("SigIndex", Tag.SigIndex); -} - void MappingTraits::mapping( IO &IO, WasmYAML::DylinkExport &Export) { IO.mapRequired("Name", Export.Name); diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -238,10 +238,6 @@ SmallVector Params; if (Name == "__cpp_exception" || Name == "__c_longjmp") { WasmSym->setType(wasm::WASM_SYMBOL_TYPE_TAG); - // We can't confirm its signature index for now because there can be - // imported exceptions. Set it to be 0 for now. - WasmSym->setTagType( - {wasm::WASM_TAG_ATTRIBUTE_EXCEPTION, /* SigIndex */ 0}); // We may have multiple C++ compilation units to be linked together, each of // which defines the exception symbol. To resolve them, we declare them as // weak. diff --git a/llvm/test/MC/WebAssembly/tag-section-decoding.ll b/llvm/test/MC/WebAssembly/tag-section-decoding.ll --- a/llvm/test/MC/WebAssembly/tag-section-decoding.ll +++ b/llvm/test/MC/WebAssembly/tag-section-decoding.ll @@ -339,7 +339,4 @@ ; number with which its LEB128 and ULEB128 encodings are different, because its ; 7th least significant bit is not 0. ; CHECK: - Type: TAG -; CHECK-NEXT: Tags: -; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Attribute: 0 -; CHECK-NEXT: SigIndex: 64 +; CHEC-NEXT: TagTypes: [ 64 ] diff --git a/llvm/test/MC/WebAssembly/tag-section.ll b/llvm/test/MC/WebAssembly/tag-section.ll --- a/llvm/test/MC/WebAssembly/tag-section.ll +++ b/llvm/test/MC/WebAssembly/tag-section.ll @@ -29,10 +29,7 @@ ; CHECK-NEXT: ReturnTypes: [] ; CHECK: - Type: TAG -; CHECK-NEXT: Tags: -; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Attribute: 0 -; CHECK-NEXT: SigIndex: 1 +; CHECK-NEXT: TagTypes: [ 1 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Relocations: diff --git a/llvm/test/ObjectYAML/wasm/event_section.yaml b/llvm/test/ObjectYAML/wasm/event_section.yaml --- a/llvm/test/ObjectYAML/wasm/event_section.yaml +++ b/llvm/test/ObjectYAML/wasm/event_section.yaml @@ -18,10 +18,7 @@ - Type: FUNCTION FunctionTypes: [ 0 ] - Type: TAG - Tags: - - Index: 0 - Attribute: 0 - SigIndex: 1 + TagTypes: [ 1 ] - Type: CODE Relocations: - Type: R_WASM_TAG_INDEX_LEB @@ -68,10 +65,7 @@ # CHECK-NEXT: - Type: FUNCTION # CHECK-NEXT: FunctionTypes: [ 0 ] # CHECK-NEXT: - Type: TAG -# CHECK-NEXT: Tags: -# CHECK-NEXT: - Index: 0 -# CHECK-NEXT: Attribute: 0 -# CHECK-NEXT: SigIndex: 1 +# CHECK-NEXT: TagTypes: [ 1 ] # CHECK-NEXT: - Type: CODE # CHECK-NEXT: Relocations: # CHECK-NEXT: - Type: R_WASM_TAG_INDEX_LEB diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp --- a/llvm/tools/obj2yaml/wasm2yaml.cpp +++ b/llvm/tools/obj2yaml/wasm2yaml.cpp @@ -241,8 +241,7 @@ Im.GlobalImport.Mutable = Import.Global.Mutable; break; case wasm::WASM_EXTERNAL_TAG: - Im.TagImport.Attribute = Import.Tag.Attribute; - Im.TagImport.SigIndex = Import.Tag.SigIndex; + Im.SigIndex = Import.SigIndex; break; case wasm::WASM_EXTERNAL_TABLE: // FIXME: Currently we always output an index of 0 for any imported @@ -285,11 +284,7 @@ case wasm::WASM_SEC_TAG: { auto TagSec = std::make_unique(); for (auto &Tag : Obj.tags()) { - WasmYAML::Tag T; - T.Index = Tag.Index; - T.Attribute = Tag.Type.Attribute; - T.SigIndex = Tag.Type.SigIndex; - TagSec->Tags.push_back(T); + TagSec->TagTypes.push_back(Tag.SigIndex); } S = std::move(TagSec); break;