[PATCH] D88603: [WebAssembly] Add support for DWARF type units
Derek Schuff via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 28 17:17:54 PDT 2020
dschuff updated this revision to Diff 301486.
dschuff added a comment.
use getOrCreate
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88603/new/
https://reviews.llvm.org/D88603
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/debug-options.c
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/MC/MCObjectFileInfo.cpp
llvm/lib/MC/WasmObjectWriter.cpp
Index: llvm/lib/MC/WasmObjectWriter.cpp
===================================================================
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -1378,9 +1378,6 @@
MCSymbol *Begin = Sec.getBeginSymbol();
if (Begin) {
WasmIndices[cast<MCSymbolWasm>(Begin)] = CustomSections.size();
- if (SectionName != Begin->getName())
- report_fatal_error("section name and begin symbol should match: " +
- Twine(SectionName));
}
// Separate out the producers and target features sections
Index: llvm/lib/MC/MCObjectFileInfo.cpp
===================================================================
--- llvm/lib/MC/MCObjectFileInfo.cpp
+++ llvm/lib/MC/MCObjectFileInfo.cpp
@@ -963,9 +963,11 @@
case Triple::ELF:
return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, ELF::SHF_GROUP, 0,
utostr(Hash));
+ case Triple::Wasm:
+ return Ctx->getWasmSection(Name, SectionKind::getMetadata(), utostr(Hash),
+ MCContext::GenericSectionID);
case Triple::MachO:
case Triple::COFF:
- case Triple::Wasm:
case Triple::GOFF:
case Triple::XCOFF:
case Triple::UnknownObjectFormat:
Index: llvm/lib/MC/MCContext.cpp
===================================================================
--- llvm/lib/MC/MCContext.cpp
+++ llvm/lib/MC/MCContext.cpp
@@ -644,7 +644,7 @@
StringRef CachedName = Entry.first.SectionName;
- MCSymbol *Begin = createSymbol(CachedName, false, false);
+ MCSymbol *Begin = getOrCreateSymbol(CachedName);
cast<MCSymbolWasm>(Begin)->setType(wasm::WASM_SYMBOL_TYPE_SECTION);
MCSectionWasm *Result = new (WasmAllocator.Allocate())
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -394,8 +394,9 @@
UseSectionsAsReferences = DwarfSectionsAsReferences == Enable;
// Don't generate type units for unsupported object file formats.
- GenerateTypeUnits =
- A->TM.getTargetTriple().isOSBinFormatELF() && GenerateDwarfTypeUnits;
+ GenerateTypeUnits = (A->TM.getTargetTriple().isOSBinFormatELF() ||
+ A->TM.getTargetTriple().isOSBinFormatWasm()) &&
+ GenerateDwarfTypeUnits;
TheAccelTableKind = computeAccelTableKind(
DwarfVersion, GenerateTypeUnits, DebuggerTuning, A->TM.getTargetTriple());
Index: clang/test/Driver/debug-options.c
===================================================================
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -214,6 +214,9 @@
// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \
// RUN: | FileCheck -check-prefix=NOFDTS %s
//
+// RUN: %clang -### -fdebug-types-section -target wasm32-unknown-unknown %s 2>&1 \
+// RUN: | FileCheck -check-prefix=FDTS %s
+//
// RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \
// RUN: | FileCheck -check-prefix=FDTSE %s
//
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3989,7 +3989,7 @@
if (Args.hasFlag(options::OPT_fdebug_types_section,
options::OPT_fno_debug_types_section, false)) {
- if (!T.isOSBinFormatELF()) {
+ if (!(T.isOSBinFormatELF() || T.isOSBinFormatWasm())) {
D.Diag(diag::err_drv_unsupported_opt_for_target)
<< Args.getLastArg(options::OPT_fdebug_types_section)
->getAsString(Args)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88603.301486.patch
Type: text/x-patch
Size: 3765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201029/558a8e34/attachment.bin>
More information about the cfe-commits
mailing list