Skip to content

Commit

Permalink
[WebAssembly] MC: Create and use first class section symbols
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D46335

llvm-svn: 331413
  • Loading branch information
sbc100 committed May 2, 2018
1 parent 87cc4db commit 4d57fbd
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 204 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/MC/MCContext.cpp
Expand Up @@ -516,8 +516,10 @@ MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind Kind,
StringRef CachedName = Entry.first.SectionName;

MCSymbol *Begin = nullptr;
if (BeginSymName)
Begin = createTempSymbol(BeginSymName, false);
if (BeginSymName) {
Begin = createSymbol(BeginSymName, false, false);
cast<MCSymbolWasm>(Begin)->setType(wasm::WASM_SYMBOL_TYPE_SECTION);
}

MCSectionWasm *Result = new (WasmAllocator.Allocate())
MCSectionWasm(CachedName, Kind, GroupSym, UniqueID, Begin);
Expand Down
12 changes: 6 additions & 6 deletions llvm/lib/MC/MCObjectFileInfo.cpp
Expand Up @@ -866,19 +866,19 @@ void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
DataSection = Ctx->getWasmSection(".data", SectionKind::getData());

// TODO: Set the section types and flags.
DwarfLineSection = Ctx->getWasmSection(".debug_line", SectionKind::getMetadata());
DwarfLineSection = Ctx->getWasmSection(".debug_line", SectionKind::getMetadata(), ".debug_line");
DwarfLineStrSection =
Ctx->getWasmSection(".debug_line_str", SectionKind::getMetadata());
DwarfStrSection = Ctx->getWasmSection(".debug_str", SectionKind::getMetadata());
DwarfStrSection = Ctx->getWasmSection(".debug_str", SectionKind::getMetadata(), ".debug_str");
DwarfLocSection = Ctx->getWasmSection(".debug_loc", SectionKind::getMetadata());
DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", SectionKind::getMetadata(), "section_abbrev");
DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", SectionKind::getMetadata(), ".section_abbrev");
DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", SectionKind::getMetadata());
DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", SectionKind::getMetadata(), "debug_range");
DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", SectionKind::getMetadata(), "debug_macinfo");
DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", SectionKind::getMetadata(), ".debug_range");
DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", SectionKind::getMetadata(), ".debug_macinfo");
DwarfAddrSection = Ctx->getWasmSection(".debug_addr", SectionKind::getMetadata());
DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata());
DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", SectionKind::getMetadata());
DwarfInfoSection = Ctx->getWasmSection(".debug_info", SectionKind::getMetadata(), "section_info");
DwarfInfoSection = Ctx->getWasmSection(".debug_info", SectionKind::getMetadata(), ".debug_info");
DwarfFrameSection = Ctx->getWasmSection(".debug_frame", SectionKind::getMetadata());
DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", SectionKind::getMetadata());
DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", SectionKind::getMetadata());
Expand Down
13 changes: 2 additions & 11 deletions llvm/lib/MC/MCWasmStreamer.cpp
Expand Up @@ -156,17 +156,8 @@ void MCWasmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
}

void MCWasmStreamer::EmitIdent(StringRef IdentString) {
MCSection *Comment = getAssembler().getContext().getWasmSection(
".comment", SectionKind::getMetadata());
PushSection();
SwitchSection(Comment);
if (!SeenIdent) {
EmitIntValue(0, 1);
SeenIdent = true;
}
EmitBytes(IdentString);
EmitIntValue(0, 1);
PopSection();
// TODO(sbc): Add the ident section once we support mergable strings
// sections in the object format
}

void MCWasmStreamer::EmitInstToFragment(const MCInst &Inst,
Expand Down

0 comments on commit 4d57fbd

Please sign in to comment.