[llvm] r338527 - [MC] Report fatal error for DWARF types for non-ELF object files

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 1 05:53:06 PDT 2018


Author: jdevlieghere
Date: Wed Aug  1 05:53:06 2018
New Revision: 338527

URL: http://llvm.org/viewvc/llvm-project?rev=338527&view=rev
Log:
[MC] Report fatal error for DWARF types for non-ELF object files

Getting the DWARF types section is only implemented for ELF object
files. We already disabled emitting debug types in clang (r337717), but
now we also report an fatal error (rather than crashing) when trying to
obtain this section in MC. Additionally we ignore the generate debug
types flag for unsupported target triples.

See PR38190 for more information.

Differential revision: https://reviews.llvm.org/D50057

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/MC/MCObjectFileInfo.cpp
    llvm/trunk/test/DebugInfo/X86/accel-tables-dwarf5.ll
    llvm/trunk/test/DebugInfo/X86/accel-tables.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=338527&r1=338526&r2=338527&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Aug  1 05:53:06 2018
@@ -364,7 +364,9 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Mo
   else
     UseSectionsAsReferences = DwarfSectionsAsReferences == Enable;
 
-  GenerateTypeUnits = GenerateDwarfTypeUnits;
+  // Don't generate type units for unsupported object file formats.
+  GenerateTypeUnits =
+      A->TM.getTargetTriple().isOSBinFormatELF() && GenerateDwarfTypeUnits;
 
   TheAccelTableKind = computeAccelTableKind(
       DwarfVersion, GenerateTypeUnits, DebuggerTuning, A->TM.getTargetTriple());

Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=338527&r1=338526&r2=338527&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Wed Aug  1 05:53:06 2018
@@ -950,8 +950,18 @@ void MCObjectFileInfo::InitMCObjectFileI
 }
 
 MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
-  return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
-                            0, utostr(Hash));
+  switch (TT.getObjectFormat()) {
+  case Triple::ELF:
+    return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
+                              0, utostr(Hash));
+  case Triple::MachO:
+  case Triple::COFF:
+  case Triple::Wasm:
+  case Triple::UnknownObjectFormat:
+    report_fatal_error("Cannot get DWARF types section for this object file "
+                       "format: not implemented.");
+    break;
+  }
 }
 
 MCSection *

Modified: llvm/trunk/test/DebugInfo/X86/accel-tables-dwarf5.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/accel-tables-dwarf5.ll?rev=338527&r1=338526&r2=338527&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/accel-tables-dwarf5.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/accel-tables-dwarf5.ll Wed Aug  1 05:53:06 2018
@@ -15,8 +15,11 @@
 ; type units. Change this once DWARF v5 type units are implemented.
 ; RUN: llc -mtriple=x86_64-pc-linux -filetype=obj -generate-type-units -debugger-tune=lldb < %s \
 ; RUN:   | llvm-readobj -sections - | FileCheck --check-prefix=NONE %s
+
+; Debug types are ignored for non-ELF targets which means it shouldn't affect
+; accelerator table generation.
 ; RUN: llc -mtriple=x86_64-apple-darwin12 -generate-type-units -filetype=obj < %s \
-; RUN:   | llvm-readobj -sections - | FileCheck --check-prefix=NONE %s
+; RUN:   | llvm-readobj -sections - | FileCheck --check-prefix=DEBUG_NAMES %s
 
 ; NONE-NOT: apple_names
 ; NONE-NOT: debug_names

Modified: llvm/trunk/test/DebugInfo/X86/accel-tables.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/accel-tables.ll?rev=338527&r1=338526&r2=338527&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/accel-tables.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/accel-tables.ll Wed Aug  1 05:53:06 2018
@@ -12,12 +12,15 @@
 ; RUN: llc -mtriple=x86_64-pc-linux -filetype=obj -debugger-tune=lldb < %s \
 ; RUN:   | llvm-readobj -sections - | FileCheck --check-prefix=DEBUG_NAMES %s
 
-; Neither target has accelerator tables if type units are enabled, as DWARF v4
-; type units are not compatible with accelerator tables.
+; No accelerator tables if type units are enabled, as DWARF v4 type units are
+; not compatible with accelerator tables.
 ; RUN: llc -mtriple=x86_64-pc-linux -filetype=obj -generate-type-units -debugger-tune=lldb < %s \
 ; RUN:   | llvm-readobj -sections - | FileCheck --check-prefix=NONE %s
+
+; Debug types are ignored for non-ELF targets which means it shouldn't affect
+; accelerator table generation.
 ; RUN: llc -mtriple=x86_64-apple-darwin12 -generate-type-units -filetype=obj < %s \
-; RUN:   | llvm-readobj -sections - | FileCheck --check-prefix=NONE %s
+; RUN:   | llvm-readobj -sections - | FileCheck --check-prefix=APPLE %s
 
 ; APPLE-NOT: debug_names
 ; APPLE: apple_names




More information about the llvm-commits mailing list