DWARF: debug_names: Don't emit entries for skeleton type units
When a type unit is emitted, the CU referencing the type unit ends up with a little DW_TAG_*_type with the DW_AT_signature and DW_AT_declaration sometimes referred to (by me? maybe other people?) as a skeleton type. We shouldn't produce .debug_names reference to these - only to the actual type definition in the type unit. So this patch does that. But, inversely, the .debug_gnu_pubtypes /does/ need to reference the skeleton type (& gcc does this too, when it produces a skeleton type (gcc doesn't always produce these - if the type is only referenced once via DW_AT_type, gcc uses a direct DW_FORM_ref_sig8 on the DW_AT_type without the intermediate skeleton type)) - so there's a little special case added in to preserve that behavior which is covered by existing tests.
This commit is contained in:
@@ -1539,8 +1539,8 @@ void DwarfCompileUnit::addGlobalNameForTypeUnit(StringRef Name,
|
||||
}
|
||||
|
||||
/// Add a new global type to the unit.
|
||||
void DwarfCompileUnit::addGlobalType(const DIType *Ty, const DIE &Die,
|
||||
const DIScope *Context) {
|
||||
void DwarfCompileUnit::addGlobalTypeImpl(const DIType *Ty, const DIE &Die,
|
||||
const DIScope *Context) {
|
||||
if (!hasDwarfPubSections())
|
||||
return;
|
||||
std::string FullName = getParentContextString(Context) + Ty->getName().str();
|
||||
|
||||
@@ -335,8 +335,8 @@ public:
|
||||
void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context);
|
||||
|
||||
/// Add a new global type to the compile unit.
|
||||
void addGlobalType(const DIType *Ty, const DIE &Die,
|
||||
const DIScope *Context) override;
|
||||
void addGlobalTypeImpl(const DIType *Ty, const DIE &Die,
|
||||
const DIScope *Context) override;
|
||||
|
||||
/// Add a new global type present in a type unit to this compile unit.
|
||||
void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context);
|
||||
|
||||
@@ -578,28 +578,33 @@ DIE *DwarfUnit::createTypeDIE(const DIScope *Context, DIE &ContextDIE,
|
||||
// Create new type.
|
||||
DIE &TyDIE = createAndAddDIE(Ty->getTag(), ContextDIE, Ty);
|
||||
|
||||
updateAcceleratorTables(Context, Ty, TyDIE);
|
||||
auto construct = [&](const auto *Ty) {
|
||||
updateAcceleratorTables(Context, Ty, TyDIE);
|
||||
constructTypeDIE(TyDIE, Ty);
|
||||
};
|
||||
|
||||
if (auto *BT = dyn_cast<DIBasicType>(Ty))
|
||||
constructTypeDIE(TyDIE, BT);
|
||||
else if (auto *ST = dyn_cast<DIStringType>(Ty))
|
||||
constructTypeDIE(TyDIE, ST);
|
||||
else if (auto *STy = dyn_cast<DISubroutineType>(Ty))
|
||||
constructTypeDIE(TyDIE, STy);
|
||||
else if (auto *CTy = dyn_cast<DICompositeType>(Ty)) {
|
||||
if (auto *CTy = dyn_cast<DICompositeType>(Ty)) {
|
||||
if (DD->generateTypeUnits() && !Ty->isForwardDecl() &&
|
||||
(Ty->getRawName() || CTy->getRawIdentifier())) {
|
||||
// Skip updating the accelerator tables since this is not the full type.
|
||||
if (MDString *TypeId = CTy->getRawIdentifier())
|
||||
if (MDString *TypeId = CTy->getRawIdentifier()) {
|
||||
addGlobalType(Ty, TyDIE, Context);
|
||||
DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy);
|
||||
else
|
||||
} else {
|
||||
updateAcceleratorTables(Context, Ty, TyDIE);
|
||||
finishNonUnitTypeDIE(TyDIE, CTy);
|
||||
}
|
||||
return &TyDIE;
|
||||
}
|
||||
constructTypeDIE(TyDIE, CTy);
|
||||
} else {
|
||||
constructTypeDIE(TyDIE, cast<DIDerivedType>(Ty));
|
||||
}
|
||||
construct(CTy);
|
||||
} else if (auto *BT = dyn_cast<DIBasicType>(Ty))
|
||||
construct(BT);
|
||||
else if (auto *ST = dyn_cast<DIStringType>(Ty))
|
||||
construct(ST);
|
||||
else if (auto *STy = dyn_cast<DISubroutineType>(Ty))
|
||||
construct(STy);
|
||||
else
|
||||
construct(cast<DIDerivedType>(Ty));
|
||||
|
||||
return &TyDIE;
|
||||
}
|
||||
@@ -650,9 +655,14 @@ void DwarfUnit::updateAcceleratorTables(const DIScope *Context,
|
||||
DD->addAccelType(*this, CUNode->getNameTableKind(), Ty->getName(), TyDIE,
|
||||
Flags);
|
||||
|
||||
addGlobalType(Ty, TyDIE, Context);
|
||||
}
|
||||
|
||||
void DwarfUnit::addGlobalType(const DIType *Ty, const DIE &TyDIE,
|
||||
const DIScope *Context) {
|
||||
if (!Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) ||
|
||||
isa<DINamespace>(Context) || isa<DICommonBlock>(Context))
|
||||
addGlobalType(Ty, TyDIE, Context);
|
||||
addGlobalTypeImpl(Ty, TyDIE, Context);
|
||||
}
|
||||
|
||||
void DwarfUnit::addType(DIE &Entity, const DIType *Ty,
|
||||
@@ -1849,8 +1859,8 @@ void DwarfTypeUnit::addGlobalName(StringRef Name, const DIE &Die,
|
||||
getCU().addGlobalNameForTypeUnit(Name, Context);
|
||||
}
|
||||
|
||||
void DwarfTypeUnit::addGlobalType(const DIType *Ty, const DIE &Die,
|
||||
const DIScope *Context) {
|
||||
void DwarfTypeUnit::addGlobalTypeImpl(const DIType *Ty, const DIE &Die,
|
||||
const DIScope *Context) {
|
||||
getCU().addGlobalTypeUnitType(Ty, Context);
|
||||
}
|
||||
|
||||
|
||||
@@ -128,8 +128,10 @@ public:
|
||||
const DIScope *Context) = 0;
|
||||
|
||||
/// Add a new global type to the compile unit.
|
||||
virtual void addGlobalType(const DIType *Ty, const DIE &Die,
|
||||
const DIScope *Context) = 0;
|
||||
virtual void addGlobalTypeImpl(const DIType *Ty, const DIE &Die,
|
||||
const DIScope *Context) = 0;
|
||||
|
||||
void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context);
|
||||
|
||||
/// Returns the DIE map slot for the specified debug variable.
|
||||
///
|
||||
@@ -397,8 +399,8 @@ public:
|
||||
}
|
||||
void addGlobalName(StringRef Name, const DIE &Die,
|
||||
const DIScope *Context) override;
|
||||
void addGlobalType(const DIType *Ty, const DIE &Die,
|
||||
const DIScope *Context) override;
|
||||
void addGlobalTypeImpl(const DIType *Ty, const DIE &Die,
|
||||
const DIScope *Context) override;
|
||||
DwarfCompileUnit &getCU() override { return CU; }
|
||||
};
|
||||
} // end llvm namespace
|
||||
|
||||
@@ -48,11 +48,6 @@
|
||||
; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
|
||||
; CHECK-NEXT: DW_IDX_parent: DW_FORM_flag_present
|
||||
; CHECK-NEXT: }
|
||||
; CHECK-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
|
||||
; CHECK-NEXT: Tag: DW_TAG_structure_type
|
||||
; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
|
||||
; CHECK-NEXT: DW_IDX_parent: DW_FORM_flag_present
|
||||
; CHECK-NEXT: }
|
||||
; CHECK-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
|
||||
; CHECK-NEXT: Tag: DW_TAG_subprogram
|
||||
; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
|
||||
@@ -88,12 +83,6 @@
|
||||
; CHECK-NEXT: DW_IDX_die_offset: 0x00000023
|
||||
; CHECK-NEXT: DW_IDX_parent: <parent not indexed>
|
||||
; CHECK-NEXT: }
|
||||
; CHECK-NEXT: Entry @ {{.+}} {
|
||||
; CHECK-NEXT: Abbrev: [[ABBREV1]]
|
||||
; CHECK-NEXT: Tag: DW_TAG_structure_type
|
||||
; CHECK-NEXT: DW_IDX_die_offset: 0x00000042
|
||||
; CHECK-NEXT: DW_IDX_parent: <parent not indexed>
|
||||
; CHECK-NEXT: }
|
||||
; CHECK-NEXT: }
|
||||
; CHECK-NEXT: ]
|
||||
; CHECK-NEXT: Bucket 2 [
|
||||
@@ -130,7 +119,7 @@
|
||||
; CHECK-SPLIT: Foreign TU count: 1
|
||||
; CHECK-SPLIT-NEXT: Bucket count: 4
|
||||
; CHECK-SPLIT-NEXT: Name count: 4
|
||||
; CHECK-SPLIT-NEXT: Abbreviations table size: 0x2D
|
||||
; CHECK-SPLIT-NEXT: Abbreviations table size: 0x25
|
||||
; CHECK-SPLIT-NEXT: Augmentation: 'LLVM0700'
|
||||
; CHECK-SPLIT-NEXT: }
|
||||
; CHECK-SPLIT-NEXT: Compilation Unit offsets [
|
||||
@@ -151,11 +140,6 @@
|
||||
; CHECK-SPLIT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
|
||||
; CHECK-SPLIT-NEXT: DW_IDX_parent: DW_FORM_flag_present
|
||||
; CHECK-SPLIT-NEXT: }
|
||||
; CHECK-SPLIT-NEXT: Abbreviation [[ABBREV:0x[0-9a-f]*]] {
|
||||
; CHECK-SPLIT-NEXT: Tag: DW_TAG_structure_type
|
||||
; CHECK-SPLIT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
|
||||
; CHECK-SPLIT-NEXT: DW_IDX_parent: DW_FORM_flag_present
|
||||
; CHECK-SPLIT-NEXT: }
|
||||
; CHECK-SPLIT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
|
||||
; CHECK-SPLIT-NEXT: Tag: DW_TAG_subprogram
|
||||
; CHECK-SPLIT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
|
||||
@@ -191,12 +175,6 @@
|
||||
; CHECK-SPLIT-NEXT: DW_IDX_die_offset: 0x00000021
|
||||
; CHECK-SPLIT-NEXT: DW_IDX_parent: <parent not indexed>
|
||||
; CHECK-SPLIT-NEXT: }
|
||||
; CHECK-SPLIT-NEXT: Entry @ {{.*}} {
|
||||
; CHECK-SPLIT-NEXT: Abbrev: [[ABBREV]]
|
||||
; CHECK-SPLIT-NEXT: Tag: DW_TAG_structure_type
|
||||
; CHECK-SPLIT-NEXT: DW_IDX_die_offset: 0x00000039
|
||||
; CHECK-SPLIT-NEXT: DW_IDX_parent: <parent not indexed>
|
||||
; CHECK-SPLIT-NEXT: }
|
||||
; CHECK-SPLIT-NEXT: }
|
||||
; CHECK-SPLIT-NEXT: ]
|
||||
; CHECK-SPLIT-NEXT: Bucket 2 [
|
||||
|
||||
Reference in New Issue
Block a user