[llvm] 789e257 - [DWARF5][Debuginfo] Compilation unit type (DW_UT_skeleton) and root DIE (DW_TAG_compile_unit) do not match.
Alexey Lapshin via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 4 13:54:28 PST 2019
Author: Alexey Lapshin
Date: 2019-12-05T00:53:47+03:00
New Revision: 789e257ce0d84ef5ddbabfdf0c990b2878e67744
URL: https://github.com/llvm/llvm-project/commit/789e257ce0d84ef5ddbabfdf0c990b2878e67744
DIFF: https://github.com/llvm/llvm-project/commit/789e257ce0d84ef5ddbabfdf0c990b2878e67744.diff
LOG: [DWARF5][Debuginfo] Compilation unit type (DW_UT_skeleton) and root DIE (DW_TAG_compile_unit) do not match.
That patch fixes incompatible compilation unit type (DW_UT_skeleton) and root DIE (DW_TAG_compile_unit) error.
cat split-dwarf.cpp
int main()
{
int a = 1;
return 0;
}
clang++ -O -g -gsplit-dwarf -gdwarf-5 split-dwarf.cpp; llvm-dwarfdump --verify ./a.out | grep skeleton
error: Compilation unit type (DW_UT_skeleton) and root DIE (DW_TAG_compile_unit) do not match.
The fix is to change DW_TAG_compile_unit into DW_TAG_skeleton_unit when skeleton file is generated.
Differential Revision: https://reviews.llvm.org/D70880
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/DIE.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/CodeGen/X86/dwarf-headers.ll
llvm/test/DebugInfo/X86/debug_addr.ll
llvm/test/DebugInfo/X86/string-offsets-table-order.ll
llvm/test/DebugInfo/X86/string-offsets-table.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
index c4d5b717b25d..84b86a71fa5f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -319,8 +319,10 @@ DIEUnit::DIEUnit(uint16_t V, uint8_t A, dwarf::Tag UnitTag)
{
Die.Owner = this;
assert((UnitTag == dwarf::DW_TAG_compile_unit ||
+ UnitTag == dwarf::DW_TAG_skeleton_unit ||
UnitTag == dwarf::DW_TAG_type_unit ||
- UnitTag == dwarf::DW_TAG_partial_unit) && "expected a unit TAG");
+ UnitTag == dwarf::DW_TAG_partial_unit) &&
+ "expected a unit TAG");
}
void DIEValue::EmitValue(const AsmPrinter *AP) const {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 9578e01abdd4..4e90c10e3e9d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -52,10 +52,23 @@
using namespace llvm;
+static dwarf::Tag GetCompileUnitType(UnitKind Kind, DwarfDebug *DW) {
+
+ // According to DWARF Debugging Information Format Version 5,
+ // 3.1.2 Skeleton Compilation Unit Entries:
+ // "When generating a split DWARF object file (see Section 7.3.2
+ // on page 187), the compilation unit in the .debug_info section
+ // is a "skeleton" compilation unit with the tag DW_TAG_skeleton_unit"
+ if (DW->getDwarfVersion() >= 5 && Kind == UnitKind::Skeleton)
+ return dwarf::DW_TAG_skeleton_unit;
+
+ return dwarf::DW_TAG_compile_unit;
+}
+
DwarfCompileUnit::DwarfCompileUnit(unsigned UID, const DICompileUnit *Node,
AsmPrinter *A, DwarfDebug *DW,
- DwarfFile *DWU)
- : DwarfUnit(dwarf::DW_TAG_compile_unit, Node, A, DW, DWU), UniqueID(UID) {
+ DwarfFile *DWU, UnitKind Kind)
+ : DwarfUnit(GetCompileUnitType(Kind, DW), Node, A, DW, DWU), UniqueID(UID) {
insertDIE(Node, &getUnitDie());
MacroLabelBegin = Asm->createTempSymbol("cu_macro_begin");
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
index 1b7ea2673ac0..8491d078ed89 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
@@ -40,6 +40,8 @@ class MCExpr;
class MCSymbol;
class MDNode;
+enum class UnitKind { Skeleton, Full };
+
class DwarfCompileUnit final : public DwarfUnit {
/// A numeric ID unique among all CUs in the module
unsigned UniqueID;
@@ -104,7 +106,8 @@ class DwarfCompileUnit final : public DwarfUnit {
public:
DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A,
- DwarfDebug *DW, DwarfFile *DWU);
+ DwarfDebug *DW, DwarfFile *DWU,
+ UnitKind Kind = UnitKind::Full);
bool hasRangeLists() const { return HasRangeLists; }
unsigned getUniqueID() const { return UniqueID; }
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index a8fe6962dfca..bddb8bf35321 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2821,7 +2821,8 @@ void DwarfDebug::initSkeletonUnit(const DwarfUnit &U, DIE &Die,
DwarfCompileUnit &DwarfDebug::constructSkeletonCU(const DwarfCompileUnit &CU) {
auto OwnedUnit = std::make_unique<DwarfCompileUnit>(
- CU.getUniqueID(), CU.getCUNode(), Asm, this, &SkeletonHolder);
+ CU.getUniqueID(), CU.getCUNode(), Asm, this, &SkeletonHolder,
+ UnitKind::Skeleton);
DwarfCompileUnit &NewCU = *OwnedUnit;
NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoSection());
diff --git a/llvm/test/CodeGen/X86/dwarf-headers.ll b/llvm/test/CodeGen/X86/dwarf-headers.ll
index ef626ad7003b..6159fc29f862 100644
--- a/llvm/test/CodeGen/X86/dwarf-headers.ll
+++ b/llvm/test/CodeGen/X86/dwarf-headers.ll
@@ -75,7 +75,7 @@
; O-5: .debug_info contents:
; O-5: 0x00000000: Compile Unit: {{.*}} version = 0x0005 unit_type = DW_UT_skeleton abbr_offset
; O-5-SAME: DWO_id = 0xccd7e58ef8bf4aa6
-; O-5: 0x00000014: DW_TAG_compile_unit
+; O-5: 0x00000014: DW_TAG_skeleton_unit
;
; DWO-5: .debug_info.dwo contents:
; DWO-5: 0x00000000: Type Unit: {{.*}} version = 0x0005 unit_type = DW_UT_split_type abbr_offset
diff --git a/llvm/test/DebugInfo/X86/debug_addr.ll b/llvm/test/DebugInfo/X86/debug_addr.ll
index e6dbe7d029d9..55e24b2764c1 100644
--- a/llvm/test/DebugInfo/X86/debug_addr.ll
+++ b/llvm/test/DebugInfo/X86/debug_addr.ll
@@ -28,7 +28,7 @@
; DWARF5: .debug_info contents:
; DWARF5: Compile Unit:{{.*}}version = 0x0005
; DWARF5-NOT: Compile Unit
-; DWARF5: DW_TAG_compile_unit
+; DWARF5: DW_TAG_skeleton_unit
; DWARF5-NOT: DW_TAG_{{.*}}
; DWARF5: DW_AT_GNU_dwo_name{{.*}}test.dwo
; DWARF5: DW_AT_addr_base{{.*}}0x00000008
diff --git a/llvm/test/DebugInfo/X86/string-offsets-table-order.ll b/llvm/test/DebugInfo/X86/string-offsets-table-order.ll
index e39f70c0e309..ab54930fe916 100644
--- a/llvm/test/DebugInfo/X86/string-offsets-table-order.ll
+++ b/llvm/test/DebugInfo/X86/string-offsets-table-order.ll
@@ -12,11 +12,11 @@
; in
diff erent order.
; CHECK: .debug_info contents:
-; CHECK: DW_TAG_compile_unit
+; CHECK: DW_TAG_skeleton_unit
; CHECK: DW_AT_comp_dir [DW_FORM_strx1] (indexed (00000000) string = "X3")
-; CHECK: DW_TAG_compile_unit
+; CHECK: DW_TAG_skeleton_unit
; CHECK: DW_AT_comp_dir [DW_FORM_strx1] (indexed (00000001) string = "X2")
-; CHECK: DW_TAG_compile_unit
+; CHECK: DW_TAG_skeleton_unit
; CHECK: DW_AT_comp_dir [DW_FORM_strx1] (indexed (00000002) string = "X1")
; CHECK: .debug_info.dwo contents:
diff --git a/llvm/test/DebugInfo/X86/string-offsets-table.ll b/llvm/test/DebugInfo/X86/string-offsets-table.ll
index 9960fd833ed9..be960d1e017c 100644
--- a/llvm/test/DebugInfo/X86/string-offsets-table.ll
+++ b/llvm/test/DebugInfo/X86/string-offsets-table.ll
@@ -56,7 +56,7 @@
; SPLIT: .debug_info contents:
; SPLIT-NEXT: 0x00000000: Compile Unit:{{.*}}DW_UT_skeleton
; SPLIT-NOT: contents:
-; SPLIT: DW_TAG_compile_unit
+; SPLIT: DW_TAG_skeleton_unit
; SPLIT-NOT: {{DW_TAG|contents:}}
; SPLIT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)
; SPLIT: DW_AT_comp_dir [DW_FORM_strx1] (indexed (00000000) string = "/home/test")
More information about the llvm-commits
mailing list