Skip to content

Commit 3cfcc94

Browse files
committed
Revert "[WebAssembly] Parse llvm.ident into producers section"
This reverts commit eccdbba3a02a33e13b5262e92200a33e2ead873d. llvm-svn: 351410
1 parent d24ae47 commit 3cfcc94

File tree

14 files changed

+18
-276
lines changed

14 files changed

+18
-276
lines changed

llvm/include/llvm/BinaryFormat/Wasm.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ struct WasmDylinkInfo {
4343
std::vector<StringRef> Needed; // Shared library depenedencies
4444
};
4545

46-
struct WasmProducerInfo {
47-
std::vector<std::pair<std::string, std::string>> Languages;
48-
std::vector<std::pair<std::string, std::string>> Tools;
49-
std::vector<std::pair<std::string, std::string>> SDKs;
50-
};
51-
5246
struct WasmExport {
5347
StringRef Name;
5448
uint8_t Kind;

llvm/include/llvm/Object/Wasm.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ class WasmObjectFile : public ObjectFile {
130130
static bool classof(const Binary *v) { return v->isWasm(); }
131131

132132
const wasm::WasmDylinkInfo &dylinkInfo() const { return DylinkInfo; }
133-
const wasm::WasmProducerInfo &getProducerInfo() const { return ProducerInfo; }
134133
ArrayRef<wasm::WasmSignature> types() const { return Signatures; }
135134
ArrayRef<uint32_t> functionTypes() const { return FunctionTypes; }
136135
ArrayRef<wasm::WasmImport> imports() const { return Imports; }
@@ -150,6 +149,7 @@ class WasmObjectFile : public ObjectFile {
150149
uint32_t getNumImportedGlobals() const { return NumImportedGlobals; }
151150
uint32_t getNumImportedFunctions() const { return NumImportedFunctions; }
152151
uint32_t getNumImportedEvents() const { return NumImportedEvents; }
152+
153153
void moveSymbolNext(DataRefImpl &Symb) const override;
154154

155155
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
@@ -252,13 +252,11 @@ class WasmObjectFile : public ObjectFile {
252252
Error parseLinkingSection(ReadContext &Ctx);
253253
Error parseLinkingSectionSymtab(ReadContext &Ctx);
254254
Error parseLinkingSectionComdat(ReadContext &Ctx);
255-
Error parseProducersSection(ReadContext &Ctx);
256255
Error parseRelocSection(StringRef Name, ReadContext &Ctx);
257256

258257
wasm::WasmObjectHeader Header;
259258
std::vector<WasmSection> Sections;
260259
wasm::WasmDylinkInfo DylinkInfo;
261-
wasm::WasmProducerInfo ProducerInfo;
262260
std::vector<wasm::WasmSignature> Signatures;
263261
std::vector<uint32_t> FunctionTypes;
264262
std::vector<wasm::WasmTable> Tables;

llvm/include/llvm/ObjectYAML/WasmYAML.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@ struct NameEntry {
123123
StringRef Name;
124124
};
125125

126-
struct ProducerEntry {
127-
std::string Name;
128-
std::string Version;
129-
};
130-
131126
struct SegmentInfo {
132127
uint32_t Index;
133128
StringRef Name;
@@ -229,19 +224,6 @@ struct LinkingSection : CustomSection {
229224
std::vector<Comdat> Comdats;
230225
};
231226

232-
struct ProducersSection : CustomSection {
233-
ProducersSection() : CustomSection("producers") {}
234-
235-
static bool classof(const Section *S) {
236-
auto C = dyn_cast<CustomSection>(S);
237-
return C && C->Name == "producers";
238-
}
239-
240-
std::vector<ProducerEntry> Languages;
241-
std::vector<ProducerEntry> Tools;
242-
std::vector<ProducerEntry> SDKs;
243-
};
244-
245227
struct TypeSection : Section {
246228
TypeSection() : Section(wasm::WASM_SEC_TYPE) {}
247229

@@ -384,7 +366,6 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Function)
384366
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::LocalDecl)
385367
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Relocation)
386368
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::NameEntry)
387-
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::ProducerEntry)
388369
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SegmentInfo)
389370
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SymbolInfo)
390371
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::InitFunction)
@@ -463,10 +444,6 @@ template <> struct MappingTraits<WasmYAML::NameEntry> {
463444
static void mapping(IO &IO, WasmYAML::NameEntry &NameEntry);
464445
};
465446

466-
template <> struct MappingTraits<WasmYAML::ProducerEntry> {
467-
static void mapping(IO &IO, WasmYAML::ProducerEntry &ProducerEntry);
468-
};
469-
470447
template <> struct MappingTraits<WasmYAML::SegmentInfo> {
471448
static void mapping(IO &IO, WasmYAML::SegmentInfo &SegmentInfo);
472449
};

llvm/lib/MC/WasmObjectWriter.cpp

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ class WasmObjectWriter : public MCObjectWriter {
224224
// Stores output data (index, relocations, content offset) for custom
225225
// section.
226226
std::vector<WasmCustomSection> CustomSections;
227-
std::unique_ptr<WasmCustomSection> ProducersSection;
228227
// Relocations for fixing up references in the custom sections.
229228
DenseMap<const MCSectionWasm *, std::vector<WasmRelocationEntry>>
230229
CustomSectionsRelocations;
@@ -266,8 +265,6 @@ class WasmObjectWriter : public MCObjectWriter {
266265
WasmIndices.clear();
267266
TableIndices.clear();
268267
DataLocations.clear();
269-
CustomSections.clear();
270-
ProducersSection.reset();
271268
CustomSectionsRelocations.clear();
272269
SignatureIndices.clear();
273270
Signatures.clear();
@@ -314,8 +311,7 @@ class WasmObjectWriter : public MCObjectWriter {
314311
ArrayRef<wasm::WasmSymbolInfo> SymbolInfos,
315312
ArrayRef<std::pair<uint16_t, uint32_t>> InitFuncs,
316313
const std::map<StringRef, std::vector<WasmComdatEntry>> &Comdats);
317-
void writeCustomSection(WasmCustomSection &CustomSection,
318-
const MCAssembler &Asm, const MCAsmLayout &Layout);
314+
void writeCustomSections(const MCAssembler &Asm, const MCAsmLayout &Layout);
319315
void writeCustomRelocSections();
320316
void
321317
updateCustomSectionRelocations(const SmallVector<WasmFunction, 4> &Functions,
@@ -1049,24 +1045,25 @@ void WasmObjectWriter::writeLinkingMetaDataSection(
10491045
endSection(Section);
10501046
}
10511047

1052-
void WasmObjectWriter::writeCustomSection(WasmCustomSection &CustomSection,
1053-
const MCAssembler &Asm,
1054-
const MCAsmLayout &Layout) {
1055-
SectionBookkeeping Section;
1056-
auto *Sec = CustomSection.Section;
1057-
startCustomSection(Section, CustomSection.Name);
1048+
void WasmObjectWriter::writeCustomSections(const MCAssembler &Asm,
1049+
const MCAsmLayout &Layout) {
1050+
for (auto &CustomSection : CustomSections) {
1051+
SectionBookkeeping Section;
1052+
auto *Sec = CustomSection.Section;
1053+
startCustomSection(Section, CustomSection.Name);
10581054

1059-
Sec->setSectionOffset(W.OS.tell() - Section.ContentsOffset);
1060-
Asm.writeSectionData(W.OS, Sec, Layout);
1055+
Sec->setSectionOffset(W.OS.tell() - Section.ContentsOffset);
1056+
Asm.writeSectionData(W.OS, Sec, Layout);
10611057

1062-
CustomSection.OutputContentsOffset = Section.ContentsOffset;
1063-
CustomSection.OutputIndex = Section.Index;
1058+
CustomSection.OutputContentsOffset = Section.ContentsOffset;
1059+
CustomSection.OutputIndex = Section.Index;
10641060

1065-
endSection(Section);
1061+
endSection(Section);
10661062

1067-
// Apply fixups.
1068-
auto &Relocations = CustomSectionsRelocations[CustomSection.Section];
1069-
applyRelocations(Relocations, CustomSection.OutputContentsOffset);
1063+
// Apply fixups.
1064+
auto &Relocations = CustomSectionsRelocations[CustomSection.Section];
1065+
applyRelocations(Relocations, CustomSection.OutputContentsOffset);
1066+
}
10701067
}
10711068

10721069
uint32_t WasmObjectWriter::getFunctionType(const MCSymbolWasm &Symbol) {
@@ -1285,13 +1282,6 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm,
12851282
report_fatal_error("section name and begin symbol should match: " +
12861283
Twine(SectionName));
12871284
}
1288-
1289-
// Separate out the producers section
1290-
if (Name == "producers") {
1291-
ProducersSection = llvm::make_unique<WasmCustomSection>(Name, &Section);
1292-
continue;
1293-
}
1294-
12951285
CustomSections.emplace_back(Name, &Section);
12961286
}
12971287
}
@@ -1580,14 +1570,11 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm,
15801570
writeElemSection(TableElems);
15811571
writeCodeSection(Asm, Layout, Functions);
15821572
writeDataSection();
1583-
for (auto &CustomSection : CustomSections)
1584-
writeCustomSection(CustomSection, Asm, Layout);
1573+
writeCustomSections(Asm, Layout);
15851574
writeLinkingMetaDataSection(SymbolInfos, InitFuncs, Comdats);
15861575
writeRelocSection(CodeSectionIndex, "CODE", CodeRelocations);
15871576
writeRelocSection(DataSectionIndex, "DATA", DataRelocations);
15881577
writeCustomRelocSections();
1589-
if (ProducersSection)
1590-
writeCustomSection(*ProducersSection, Asm, Layout);
15911578

15921579
// TODO: Translate the .comment section to the output.
15931580
return W.OS.tell() - StartOffset;

llvm/lib/Object/WasmObjectFile.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "llvm/ADT/ArrayRef.h"
1111
#include "llvm/ADT/DenseSet.h"
1212
#include "llvm/ADT/STLExtras.h"
13-
#include "llvm/ADT/SmallSet.h"
1413
#include "llvm/ADT/StringRef.h"
1514
#include "llvm/ADT/StringSet.h"
1615
#include "llvm/ADT/Triple.h"
@@ -660,47 +659,6 @@ Error WasmObjectFile::parseLinkingSectionComdat(ReadContext &Ctx) {
660659
return Error::success();
661660
}
662661

663-
Error WasmObjectFile::parseProducersSection(ReadContext &Ctx) {
664-
llvm::SmallSet<StringRef, 3> FieldsSeen;
665-
uint32_t Fields = readVaruint32(Ctx);
666-
for (size_t i = 0; i < Fields; ++i) {
667-
StringRef FieldName = readString(Ctx);
668-
if (!FieldsSeen.insert(FieldName).second)
669-
return make_error<GenericBinaryError>(
670-
"Producers section does not have unique fields",
671-
object_error::parse_failed);
672-
std::vector<std::pair<std::string, std::string>> *ProducerVec = nullptr;
673-
if (FieldName == "language") {
674-
ProducerVec = &ProducerInfo.Languages;
675-
} else if (FieldName == "processed-by") {
676-
ProducerVec = &ProducerInfo.Tools;
677-
} else if (FieldName == "sdk") {
678-
ProducerVec = &ProducerInfo.SDKs;
679-
} else {
680-
return make_error<GenericBinaryError>(
681-
"Producers section field is not named one of language, processed-by, "
682-
"or sdk",
683-
object_error::parse_failed);
684-
}
685-
uint32_t ValueCount = readVaruint32(Ctx);
686-
llvm::SmallSet<StringRef, 8> ProducersSeen;
687-
for (size_t j = 0; j < ValueCount; ++j) {
688-
StringRef Name = readString(Ctx);
689-
StringRef Version = readString(Ctx);
690-
if (!ProducersSeen.insert(Name).second) {
691-
return make_error<GenericBinaryError>(
692-
"Producers section contains repeated producer",
693-
object_error::parse_failed);
694-
}
695-
ProducerVec->emplace_back(Name, Version);
696-
}
697-
}
698-
if (Ctx.Ptr != Ctx.End)
699-
return make_error<GenericBinaryError>("Producers section ended prematurely",
700-
object_error::parse_failed);
701-
return Error::success();
702-
}
703-
704662
Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) {
705663
uint32_t SectionIndex = readVaruint32(Ctx);
706664
if (SectionIndex >= Sections.size())
@@ -799,9 +757,6 @@ Error WasmObjectFile::parseCustomSection(WasmSection &Sec, ReadContext &Ctx) {
799757
} else if (Sec.Name == "linking") {
800758
if (Error Err = parseLinkingSection(Ctx))
801759
return Err;
802-
} else if (Sec.Name == "producers") {
803-
if (Error Err = parseProducersSection(Ctx))
804-
return Err;
805760
} else if (Sec.Name.startswith("reloc.")) {
806761
if (Error Err = parseRelocSection(Sec.Name, Ctx))
807762
return Err;

llvm/lib/ObjectYAML/WasmYAML.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,6 @@ static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) {
7474
IO.mapOptional("Comdats", Section.Comdats);
7575
}
7676

77-
static void sectionMapping(IO &IO, WasmYAML::ProducersSection &Section) {
78-
commonSectionMapping(IO, Section);
79-
IO.mapRequired("Name", Section.Name);
80-
IO.mapOptional("Languages", Section.Languages);
81-
IO.mapOptional("Tools", Section.Tools);
82-
IO.mapOptional("SDKs", Section.SDKs);
83-
}
84-
8577
static void sectionMapping(IO &IO, WasmYAML::CustomSection &Section) {
8678
commonSectionMapping(IO, Section);
8779
IO.mapRequired("Name", Section.Name);
@@ -177,10 +169,6 @@ void MappingTraits<std::unique_ptr<WasmYAML::Section>>::mapping(
177169
if (!IO.outputting())
178170
Section.reset(new WasmYAML::NameSection());
179171
sectionMapping(IO, *cast<WasmYAML::NameSection>(Section.get()));
180-
} else if (SectionName == "producers") {
181-
if (!IO.outputting())
182-
Section.reset(new WasmYAML::ProducersSection());
183-
sectionMapping(IO, *cast<WasmYAML::ProducersSection>(Section.get()));
184172
} else {
185173
if (!IO.outputting())
186174
Section.reset(new WasmYAML::CustomSection(SectionName));
@@ -305,12 +293,6 @@ void MappingTraits<WasmYAML::NameEntry>::mapping(
305293
IO.mapRequired("Name", NameEntry.Name);
306294
}
307295

308-
void MappingTraits<WasmYAML::ProducerEntry>::mapping(
309-
IO &IO, WasmYAML::ProducerEntry &ProducerEntry) {
310-
IO.mapRequired("Name", ProducerEntry.Name);
311-
IO.mapRequired("Version", ProducerEntry.Version);
312-
}
313-
314296
void MappingTraits<WasmYAML::SegmentInfo>::mapping(
315297
IO &IO, WasmYAML::SegmentInfo &SegmentInfo) {
316298
IO.mapRequired("Index", SegmentInfo.Index);

llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "WebAssemblyMCInstLower.h"
2323
#include "WebAssemblyMachineFunctionInfo.h"
2424
#include "WebAssemblyRegisterInfo.h"
25-
#include "llvm/ADT/SmallSet.h"
2625
#include "llvm/ADT/StringExtras.h"
2726
#include "llvm/CodeGen/Analysis.h"
2827
#include "llvm/CodeGen/AsmPrinter.h"
@@ -147,35 +146,6 @@ void WebAssemblyAsmPrinter::EmitEndOfAsmFile(Module &M) {
147146
OutStreamer->PopSection();
148147
}
149148
}
150-
151-
if (const NamedMDNode *Ident = M.getNamedMetadata("llvm.ident")) {
152-
llvm::SmallSet<StringRef, 4> SeenTools;
153-
llvm::SmallVector<std::pair<StringRef, StringRef>, 4> Tools;
154-
for (size_t i = 0, e = Ident->getNumOperands(); i < e; ++i) {
155-
const auto *S = cast<MDString>(Ident->getOperand(i)->getOperand(0));
156-
std::pair<StringRef, StringRef> Field = S->getString().split("version");
157-
StringRef Name = Field.first.trim();
158-
StringRef Version = Field.second.trim();
159-
if (!SeenTools.insert(Name).second)
160-
continue;
161-
Tools.emplace_back(Name, Version);
162-
}
163-
MCSectionWasm *Producers = OutContext.getWasmSection(
164-
".custom_section.producers", SectionKind::getMetadata());
165-
OutStreamer->PushSection();
166-
OutStreamer->SwitchSection(Producers);
167-
OutStreamer->EmitULEB128IntValue(1);
168-
OutStreamer->EmitULEB128IntValue(strlen("processed-by"));
169-
OutStreamer->EmitBytes("processed-by");
170-
OutStreamer->EmitULEB128IntValue(Tools.size());
171-
for (auto &Tool : Tools) {
172-
OutStreamer->EmitULEB128IntValue(Tool.first.size());
173-
OutStreamer->EmitBytes(Tool.first);
174-
OutStreamer->EmitULEB128IntValue(Tool.second.size());
175-
OutStreamer->EmitBytes(Tool.second);
176-
}
177-
OutStreamer->PopSection();
178-
}
179149
}
180150

181151
void WebAssemblyAsmPrinter::EmitConstantPool() {

llvm/test/CodeGen/WebAssembly/custom-sections.ll

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ target triple = "wasm32-unknown-unknown"
1010
!2 = !{ !"green", !"qux" }
1111
!wasm.custom_sections = !{ !0, !1, !2 }
1212

13-
!llvm.ident = !{!3}
14-
!3 = !{!"clang version 123"}
15-
1613
; CHECK: .section .custom_section.red,"",@
1714
; CHECK-NEXT: .ascii "foo"
1815

@@ -21,13 +18,3 @@ target triple = "wasm32-unknown-unknown"
2118

2219
; CHECK: .section .custom_section.green,"",@
2320
; CHECK-NEXT: .ascii "qux"
24-
25-
; CHECK: .section .custom_section.producers,"",@
26-
; CHECK-NEXT: .int8 1
27-
; CHECK-NEXT: .int8 12
28-
; CHECK-NEXT: .ascii "processed-by"
29-
; CHECK-NEXT: .int8 1
30-
; CHECK-NEXT: .int8 5
31-
; CHECK-NEXT: .ascii "clang"
32-
; CHECK-NEXT: .int8 3
33-
; CHECK-NEXT: .ascii "123"

llvm/test/MC/WebAssembly/custom-sections.ll

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ target triple = "wasm32-unknown-unknown"
99
!2 = !{ !"green", !"qux" }
1010
!wasm.custom_sections = !{ !0, !1, !2 }
1111

12-
!3 = !{ !"clang version 123"}
13-
!llvm.ident = !{!3}
14-
1512
; CHECK: Section {
1613
; CHECK: Type: CUSTOM (0x0)
1714
; CHECK: Size: 3
@@ -24,9 +21,3 @@ target triple = "wasm32-unknown-unknown"
2421
; CHECK: Offset: 85
2522
; CHECK: Name: green
2623
; CHECK: }
27-
; CHECK: Section {
28-
; CHECK: Type: CUSTOM (0x0)
29-
; CHECK: Size: 25
30-
; CHECK: Offset: 118
31-
; CHECK: Name: producers
32-
; CHECK: }

llvm/test/MC/WebAssembly/debug-info.ll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@
124124
; CHECK-NEXT: Offset: 991
125125
; CHECK-NEXT: Name: reloc..debug_line
126126
; CHECK-NEXT: }
127-
; CHECK-NEXT: Section {
128-
; CHECK-NEXT: Type: CUSTOM (0x0)
129-
; CHECK-NEXT: Size: 62
130-
; CHECK-NEXT: Offset: 1021
131-
; CHECK-NEXT: Name: producers
132-
; CHECK-NEXT: }
133127
; CHECK-NEXT:]
134128
; CHECK-NEXT:Relocations [
135129
; CHECK-NEXT: Section (6) DATA {

0 commit comments

Comments
 (0)