diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/MC/WasmObjectWriter.cpp | 47 | ||||
-rw-r--r-- | llvm/lib/Object/WasmObjectFile.cpp | 45 | ||||
-rw-r--r-- | llvm/lib/ObjectYAML/WasmYAML.cpp | 18 | ||||
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp | 30 |
4 files changed, 17 insertions, 123 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index 8e45b2f3e0c..0cca3757be9 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -224,7 +224,6 @@ class WasmObjectWriter : public MCObjectWriter { // Stores output data (index, relocations, content offset) for custom // section. std::vector<WasmCustomSection> CustomSections; - std::unique_ptr<WasmCustomSection> ProducersSection; // Relocations for fixing up references in the custom sections. DenseMap<const MCSectionWasm *, std::vector<WasmRelocationEntry>> CustomSectionsRelocations; @@ -266,8 +265,6 @@ private: WasmIndices.clear(); TableIndices.clear(); DataLocations.clear(); - CustomSections.clear(); - ProducersSection.reset(); CustomSectionsRelocations.clear(); SignatureIndices.clear(); Signatures.clear(); @@ -314,8 +311,7 @@ private: ArrayRef<wasm::WasmSymbolInfo> SymbolInfos, ArrayRef<std::pair<uint16_t, uint32_t>> InitFuncs, const std::map<StringRef, std::vector<WasmComdatEntry>> &Comdats); - void writeCustomSection(WasmCustomSection &CustomSection, - const MCAssembler &Asm, const MCAsmLayout &Layout); + void writeCustomSections(const MCAssembler &Asm, const MCAsmLayout &Layout); void writeCustomRelocSections(); void updateCustomSectionRelocations(const SmallVector<WasmFunction, 4> &Functions, @@ -1049,24 +1045,25 @@ void WasmObjectWriter::writeLinkingMetaDataSection( endSection(Section); } -void WasmObjectWriter::writeCustomSection(WasmCustomSection &CustomSection, - const MCAssembler &Asm, - const MCAsmLayout &Layout) { - SectionBookkeeping Section; - auto *Sec = CustomSection.Section; - startCustomSection(Section, CustomSection.Name); +void WasmObjectWriter::writeCustomSections(const MCAssembler &Asm, + const MCAsmLayout &Layout) { + for (auto &CustomSection : CustomSections) { + SectionBookkeeping Section; + auto *Sec = CustomSection.Section; + startCustomSection(Section, CustomSection.Name); - Sec->setSectionOffset(W.OS.tell() - Section.ContentsOffset); - Asm.writeSectionData(W.OS, Sec, Layout); + Sec->setSectionOffset(W.OS.tell() - Section.ContentsOffset); + Asm.writeSectionData(W.OS, Sec, Layout); - CustomSection.OutputContentsOffset = Section.ContentsOffset; - CustomSection.OutputIndex = Section.Index; + CustomSection.OutputContentsOffset = Section.ContentsOffset; + CustomSection.OutputIndex = Section.Index; - endSection(Section); + endSection(Section); - // Apply fixups. - auto &Relocations = CustomSectionsRelocations[CustomSection.Section]; - applyRelocations(Relocations, CustomSection.OutputContentsOffset); + // Apply fixups. + auto &Relocations = CustomSectionsRelocations[CustomSection.Section]; + applyRelocations(Relocations, CustomSection.OutputContentsOffset); + } } uint32_t WasmObjectWriter::getFunctionType(const MCSymbolWasm &Symbol) { @@ -1285,13 +1282,6 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm, report_fatal_error("section name and begin symbol should match: " + Twine(SectionName)); } - - // Separate out the producers section - if (Name == "producers") { - ProducersSection = llvm::make_unique<WasmCustomSection>(Name, &Section); - continue; - } - CustomSections.emplace_back(Name, &Section); } } @@ -1580,14 +1570,11 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm, writeElemSection(TableElems); writeCodeSection(Asm, Layout, Functions); writeDataSection(); - for (auto &CustomSection : CustomSections) - writeCustomSection(CustomSection, Asm, Layout); + writeCustomSections(Asm, Layout); writeLinkingMetaDataSection(SymbolInfos, InitFuncs, Comdats); writeRelocSection(CodeSectionIndex, "CODE", CodeRelocations); writeRelocSection(DataSectionIndex, "DATA", DataRelocations); writeCustomRelocSections(); - if (ProducersSection) - writeCustomSection(*ProducersSection, Asm, Layout); // TODO: Translate the .comment section to the output. return W.OS.tell() - StartOffset; diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index fd6ad9bdefe..d84cb48c9fb 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -10,7 +10,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" #include "llvm/ADT/Triple.h" @@ -660,47 +659,6 @@ Error WasmObjectFile::parseLinkingSectionComdat(ReadContext &Ctx) { return Error::success(); } -Error WasmObjectFile::parseProducersSection(ReadContext &Ctx) { - llvm::SmallSet<StringRef, 3> FieldsSeen; - uint32_t Fields = readVaruint32(Ctx); - for (size_t i = 0; i < Fields; ++i) { - StringRef FieldName = readString(Ctx); - if (!FieldsSeen.insert(FieldName).second) - return make_error<GenericBinaryError>( - "Producers section does not have unique fields", - object_error::parse_failed); - std::vector<std::pair<std::string, std::string>> *ProducerVec = nullptr; - if (FieldName == "language") { - ProducerVec = &ProducerInfo.Languages; - } else if (FieldName == "processed-by") { - ProducerVec = &ProducerInfo.Tools; - } else if (FieldName == "sdk") { - ProducerVec = &ProducerInfo.SDKs; - } else { - return make_error<GenericBinaryError>( - "Producers section field is not named one of language, processed-by, " - "or sdk", - object_error::parse_failed); - } - uint32_t ValueCount = readVaruint32(Ctx); - llvm::SmallSet<StringRef, 8> ProducersSeen; - for (size_t j = 0; j < ValueCount; ++j) { - StringRef Name = readString(Ctx); - StringRef Version = readString(Ctx); - if (!ProducersSeen.insert(Name).second) { - return make_error<GenericBinaryError>( - "Producers section contains repeated producer", - object_error::parse_failed); - } - ProducerVec->emplace_back(Name, Version); - } - } - if (Ctx.Ptr != Ctx.End) - return make_error<GenericBinaryError>("Producers section ended prematurely", - object_error::parse_failed); - return Error::success(); -} - Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) { uint32_t SectionIndex = readVaruint32(Ctx); if (SectionIndex >= Sections.size()) @@ -799,9 +757,6 @@ Error WasmObjectFile::parseCustomSection(WasmSection &Sec, ReadContext &Ctx) { } else if (Sec.Name == "linking") { if (Error Err = parseLinkingSection(Ctx)) return Err; - } else if (Sec.Name == "producers") { - if (Error Err = parseProducersSection(Ctx)) - return Err; } else if (Sec.Name.startswith("reloc.")) { if (Error Err = parseRelocSection(Sec.Name, Ctx)) return Err; diff --git a/llvm/lib/ObjectYAML/WasmYAML.cpp b/llvm/lib/ObjectYAML/WasmYAML.cpp index b45c8ce65eb..47bf853e0d3 100644 --- a/llvm/lib/ObjectYAML/WasmYAML.cpp +++ b/llvm/lib/ObjectYAML/WasmYAML.cpp @@ -74,14 +74,6 @@ static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) { IO.mapOptional("Comdats", Section.Comdats); } -static void sectionMapping(IO &IO, WasmYAML::ProducersSection &Section) { - commonSectionMapping(IO, Section); - IO.mapRequired("Name", Section.Name); - IO.mapOptional("Languages", Section.Languages); - IO.mapOptional("Tools", Section.Tools); - IO.mapOptional("SDKs", Section.SDKs); -} - static void sectionMapping(IO &IO, WasmYAML::CustomSection &Section) { commonSectionMapping(IO, Section); IO.mapRequired("Name", Section.Name); @@ -177,10 +169,6 @@ void MappingTraits<std::unique_ptr<WasmYAML::Section>>::mapping( if (!IO.outputting()) Section.reset(new WasmYAML::NameSection()); sectionMapping(IO, *cast<WasmYAML::NameSection>(Section.get())); - } else if (SectionName == "producers") { - if (!IO.outputting()) - Section.reset(new WasmYAML::ProducersSection()); - sectionMapping(IO, *cast<WasmYAML::ProducersSection>(Section.get())); } else { if (!IO.outputting()) Section.reset(new WasmYAML::CustomSection(SectionName)); @@ -305,12 +293,6 @@ void MappingTraits<WasmYAML::NameEntry>::mapping( IO.mapRequired("Name", NameEntry.Name); } -void MappingTraits<WasmYAML::ProducerEntry>::mapping( - IO &IO, WasmYAML::ProducerEntry &ProducerEntry) { - IO.mapRequired("Name", ProducerEntry.Name); - IO.mapRequired("Version", ProducerEntry.Version); -} - void MappingTraits<WasmYAML::SegmentInfo>::mapping( IO &IO, WasmYAML::SegmentInfo &SegmentInfo) { IO.mapRequired("Index", SegmentInfo.Index); diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp index 6d5647a7ace..c4f03dfa7f9 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -22,7 +22,6 @@ #include "WebAssemblyMCInstLower.h" #include "WebAssemblyMachineFunctionInfo.h" #include "WebAssemblyRegisterInfo.h" -#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/CodeGen/Analysis.h" #include "llvm/CodeGen/AsmPrinter.h" @@ -147,35 +146,6 @@ void WebAssemblyAsmPrinter::EmitEndOfAsmFile(Module &M) { OutStreamer->PopSection(); } } - - if (const NamedMDNode *Ident = M.getNamedMetadata("llvm.ident")) { - llvm::SmallSet<StringRef, 4> SeenTools; - llvm::SmallVector<std::pair<StringRef, StringRef>, 4> Tools; - for (size_t i = 0, e = Ident->getNumOperands(); i < e; ++i) { - const auto *S = cast<MDString>(Ident->getOperand(i)->getOperand(0)); - std::pair<StringRef, StringRef> Field = S->getString().split("version"); - StringRef Name = Field.first.trim(); - StringRef Version = Field.second.trim(); - if (!SeenTools.insert(Name).second) - continue; - Tools.emplace_back(Name, Version); - } - MCSectionWasm *Producers = OutContext.getWasmSection( - ".custom_section.producers", SectionKind::getMetadata()); - OutStreamer->PushSection(); - OutStreamer->SwitchSection(Producers); - OutStreamer->EmitULEB128IntValue(1); - OutStreamer->EmitULEB128IntValue(strlen("processed-by")); - OutStreamer->EmitBytes("processed-by"); - OutStreamer->EmitULEB128IntValue(Tools.size()); - for (auto &Tool : Tools) { - OutStreamer->EmitULEB128IntValue(Tool.first.size()); - OutStreamer->EmitBytes(Tool.first); - OutStreamer->EmitULEB128IntValue(Tool.second.size()); - OutStreamer->EmitBytes(Tool.second); - } - OutStreamer->PopSection(); - } } void WebAssemblyAsmPrinter::EmitConstantPool() { |