summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2018-11-09 19:06:09 +0000
committerPaul Robinson <paul.robinson@sony.com>2018-11-09 19:06:09 +0000
commitddbde9a4add367c12b4ff8bda5e7a6b351b645c6 (patch)
tree29081d6179b75582c07b6cd5eb4e00fc3bd592a2
parent731ea7dbc1da611beed2e492446df3408c85e638 (diff)
downloadbcm5719-llvm-ddbde9a4add367c12b4ff8bda5e7a6b351b645c6.tar.gz
bcm5719-llvm-ddbde9a4add367c12b4ff8bda5e7a6b351b645c6.zip
[DWARFv5] Emit normal type units in .debug_info comdats.
Differential Revision: https://reviews.llvm.org/D54282 llvm-svn: 346540
-rw-r--r--llvm/include/llvm/MC/MCObjectFileInfo.h8
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp7
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp9
-rw-r--r--llvm/test/CodeGen/X86/dwarf-headers.ll12
-rw-r--r--llvm/test/DebugInfo/X86/string-offsets-multiple-cus.ll55
5 files changed, 52 insertions, 39 deletions
diff --git a/llvm/include/llvm/MC/MCObjectFileInfo.h b/llvm/include/llvm/MC/MCObjectFileInfo.h
index 729aa23ef33..97c1f270ba3 100644
--- a/llvm/include/llvm/MC/MCObjectFileInfo.h
+++ b/llvm/include/llvm/MC/MCObjectFileInfo.h
@@ -241,6 +241,9 @@ public:
MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
+ MCSection *getDwarfInfoSection(uint64_t Hash) const {
+ return getDwarfComdatSection(".debug_info", Hash);
+ }
MCSection *getDwarfLineSection() const { return DwarfLineSection; }
MCSection *getDwarfLineStrSection() const { return DwarfLineStrSection; }
MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
@@ -277,7 +280,9 @@ public:
return DwarfAccelTypesSection;
}
MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
- MCSection *getDwarfTypesSection(uint64_t Hash) const;
+ MCSection *getDwarfTypesSection(uint64_t Hash) const {
+ return getDwarfComdatSection(".debug_types", Hash);
+ }
MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
@@ -390,6 +395,7 @@ private:
void initELFMCObjectFileInfo(const Triple &T, bool Large);
void initCOFFMCObjectFileInfo(const Triple &T);
void initWasmMCObjectFileInfo(const Triple &T);
+ MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
public:
const Triple &getTargetTriple() const { return TT; }
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 070b8fe4ec1..5d50f34d77d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2610,9 +2610,14 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
Ins.first->second = Signature;
if (useSplitDwarf())
+ // FIXME: v5 split type units belong in .debug_info.dwo.
NewTU.setSection(Asm->getObjFileLowering().getDwarfTypesDWOSection());
else {
- NewTU.setSection(Asm->getObjFileLowering().getDwarfTypesSection(Signature));
+ MCSection *Section =
+ getDwarfVersion() <= 4
+ ? Asm->getObjFileLowering().getDwarfTypesSection(Signature)
+ : Asm->getObjFileLowering().getDwarfInfoSection(Signature);
+ NewTU.setSection(Section);
// Non-split type units reuse the compile unit's line table.
CU.applyStmtList(UnitDie);
}
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index ab8e0f31db9..0513ba5a82a 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -812,16 +812,17 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,
}
}
-MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
+MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name,
+ uint64_t Hash) const {
switch (TT.getObjectFormat()) {
case Triple::ELF:
- return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
- 0, utostr(Hash));
+ return Ctx->getELFSection(Name, 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 "
+ report_fatal_error("Cannot get DWARF comdat section for this object file "
"format: not implemented.");
break;
}
diff --git a/llvm/test/CodeGen/X86/dwarf-headers.ll b/llvm/test/CodeGen/X86/dwarf-headers.ll
index fa2080d1e1d..2f20216ab0d 100644
--- a/llvm/test/CodeGen/X86/dwarf-headers.ll
+++ b/llvm/test/CodeGen/X86/dwarf-headers.ll
@@ -59,16 +59,16 @@
; DWO-4: 0x00000000: Type Unit: {{.*}} version = 0x0004 abbr_offset
; DWO-4: 0x00000017: DW_TAG_type_unit
-; Verify the v5 non-split headers.
+; Verify the v5 non-split headers. Type units come first.
+; All .debug_info sections are reported in one go, but the offset resets for
+; each new section.
;
; SINGLE-5: .debug_info contents:
-; SINGLE-5: 0x00000000: Compile Unit: {{.*}} version = 0x0005 unit_type = DW_UT_compile abbr_offset
-; SINGLE-5: 0x0000000c: DW_TAG_compile_unit
-;
-; FIXME: V5 wants type units in .debug_info not .debug_types.
-; SINGLE-5: .debug_types contents:
; SINGLE-5: 0x00000000: Type Unit: {{.*}} version = 0x0005 unit_type = DW_UT_type abbr_offset
; SINGLE-5: 0x00000018: DW_TAG_type_unit
+; SINGLE-5-NOT: contents:
+; SINGLE-5: 0x00000000: Compile Unit: {{.*}} version = 0x0005 unit_type = DW_UT_compile abbr_offset
+; SINGLE-5: 0x0000000c: DW_TAG_compile_unit
; Verify the v5 split headers.
;
diff --git a/llvm/test/DebugInfo/X86/string-offsets-multiple-cus.ll b/llvm/test/DebugInfo/X86/string-offsets-multiple-cus.ll
index 2f479fa5af0..7851dbfefd5 100644
--- a/llvm/test/DebugInfo/X86/string-offsets-multiple-cus.ll
+++ b/llvm/test/DebugInfo/X86/string-offsets-multiple-cus.ll
@@ -31,39 +31,13 @@
; with the correct offsets. Check that strings referenced by compile units 2 and 3
; are displayed correctly.
;
-; CU 1
; BOTH: .debug_info contents:
-; BOTH-NOT: .contents:
-; BOTH: DW_TAG_compile_unit
-; BOTH-NOT: {{DW_TAG|NULL}}
-; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF:[0-9a-f]+]])
-;
-; CU 2
-; BOTH-NOT: contents:
-; BOTH: DW_TAG_compile_unit
-; BOTH-NOT: {{DW_TAG|NULL}}
-; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
-; BOTH-NOT: NULL
-; BOTH: DW_TAG_variable
-; BOTH-NOT: {{DW_TAG|NULL}}
-; BOTH: DW_AT_name [DW_FORM_strx1] ( indexed (00000009) string = "glob2")
-;
-; CU 3
-; BOTH-NOT: contents:
-; BOTH: DW_TAG_compile_unit
-; BOTH-NOT: {{DW_TAG|NULL}}
-; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
-; BOTH-NOT: NULL
-; BOTH: DW_TAG_variable
-; BOTH-NOT: {{DW_TAG|NULL}}
-; BOTH: DW_AT_name [DW_FORM_strx1] ( indexed (0000000f) string = "glob3")
;
; Verify that all 3 type units have the proper DW_AT_str_offsets_base attribute.
-; TYPEUNITS: .debug_types contents:
; TYPEUNITS-NOT: contents:
; TYPEUNITS: DW_TAG_type_unit
; TYPEUNITS-NOT: {{DW_TAG|NULL}}
-; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
+; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF:[0-9a-f]+]])
; TYPEUNITS-NOT: NULL
; TYPEUNITS: DW_TAG_enumerator
; TYPEUNITS-NOT: NULL
@@ -84,6 +58,33 @@
; TYPEUNITS-NOT: NULL
; TYPEUNITS: DW_TAG_enumeration_type
; TYPEUNITS: DW_AT_name [DW_FORM_strx1] ( indexed (00000013) string = "E3")
+
+; CU 1
+; BOTH-NOT: .contents:
+; BOTH: DW_TAG_compile_unit
+; BOTH-NOT: {{DW_TAG|NULL}}
+; DEFAULT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF:[0-9a-f]+]])
+; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
+;
+; CU 2
+; BOTH-NOT: contents:
+; BOTH: DW_TAG_compile_unit
+; BOTH-NOT: {{DW_TAG|NULL}}
+; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
+; BOTH-NOT: NULL
+; BOTH: DW_TAG_variable
+; BOTH-NOT: {{DW_TAG|NULL}}
+; BOTH: DW_AT_name [DW_FORM_strx1] ( indexed (00000009) string = "glob2")
+;
+; CU 3
+; BOTH-NOT: contents:
+; BOTH: DW_TAG_compile_unit
+; BOTH-NOT: {{DW_TAG|NULL}}
+; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
+; BOTH-NOT: NULL
+; BOTH: DW_TAG_variable
+; BOTH-NOT: {{DW_TAG|NULL}}
+; BOTH: DW_AT_name [DW_FORM_strx1] ( indexed (0000000f) string = "glob3")
;
; Extract the offset of a string to verify that it is referenced in the string
; offsets section.
OpenPOWER on IntegriCloud