summaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-11-26 00:22:37 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-11-26 00:22:37 +0000
commit999cf05d6afa85c235f5c325ff420d5f768d48d8 (patch)
tree6396760b81f261a098a19022f28e01b2d44d4061 /lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
parent0e6ec124d56b3c93dcfca2e117e67575b29c7899 (diff)
downloadllvm-999cf05d6afa85c235f5c325ff420d5f768d48d8.tar.gz
llvm-999cf05d6afa85c235f5c325ff420d5f768d48d8.tar.bz2
llvm-999cf05d6afa85c235f5c325ff420d5f768d48d8.tar.xz
DebugInfo: Avoid emitting pubtype entries for type DIEs that just indirect to a type unit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195698 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp80
1 files changed, 43 insertions, 37 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index abb550e0d1..2316301b40 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -929,6 +929,40 @@ DIE *CompileUnit::createTypeDIE(DICompositeType Ty) {
return TyDIE;
}
+/// Return true if the type is appropriately scoped to be contained inside
+/// its own type unit.
+static bool isTypeUnitScoped(DIType Ty, const DwarfDebug *DD) {
+ DIScope Parent = DD->resolve(Ty.getContext());
+ while (Parent) {
+ // Don't generate a hash for anything scoped inside a function.
+ if (Parent.isSubprogram())
+ return false;
+ Parent = DD->resolve(Parent.getContext());
+ }
+ return true;
+}
+
+/// Return true if the type should be split out into a type unit.
+static bool shouldCreateTypeUnit(DICompositeType CTy, const DwarfDebug *DD) {
+ if (!GenerateTypeUnits)
+ return false;
+
+ uint16_t Tag = CTy.getTag();
+
+ switch (Tag) {
+ case dwarf::DW_TAG_structure_type:
+ case dwarf::DW_TAG_union_type:
+ case dwarf::DW_TAG_enumeration_type:
+ case dwarf::DW_TAG_class_type:
+ // If this is a class, structure, union, or enumeration type
+ // that is a definition (not a declaration), and not scoped
+ // inside a function then separate this out as a type unit.
+ return !CTy.isForwardDecl() && isTypeUnitScoped(CTy, DD);
+ default:
+ return false;
+ }
+}
+
/// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
/// given DIType.
DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
@@ -953,9 +987,15 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
if (Ty.isBasicType())
constructTypeDIE(*TyDIE, DIBasicType(Ty));
- else if (Ty.isCompositeType())
- constructTypeDIE(*TyDIE, DICompositeType(Ty));
- else {
+ else if (Ty.isCompositeType()) {
+ DICompositeType CTy(Ty);
+ if (shouldCreateTypeUnit(CTy, DD)) {
+ DD->addTypeUnitType(TyDIE, CTy);
+ // Skip updating the accellerator tables since this is not the full type
+ return TyDIE;
+ }
+ constructTypeDIEImpl(*TyDIE, CTy);
+ } else {
assert(Ty.isDerivedType() && "Unknown kind of DIType");
constructTypeDIE(*TyDIE, DIDerivedType(Ty));
}
@@ -1127,40 +1167,6 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) {
addSourceLine(&Buffer, DTy);
}
-/// Return true if the type is appropriately scoped to be contained inside
-/// its own type unit.
-static bool isTypeUnitScoped(DIType Ty, const DwarfDebug *DD) {
- DIScope Parent = DD->resolve(Ty.getContext());
- while (Parent) {
- // Don't generate a hash for anything scoped inside a function.
- if (Parent.isSubprogram())
- return false;
- Parent = DD->resolve(Parent.getContext());
- }
- return true;
-}
-
-/// Return true if the type should be split out into a type unit.
-static bool shouldCreateTypeUnit(DICompositeType CTy, const DwarfDebug *DD) {
- if (!GenerateTypeUnits)
- return false;
-
- uint16_t Tag = CTy.getTag();
-
- switch (Tag) {
- case dwarf::DW_TAG_structure_type:
- case dwarf::DW_TAG_union_type:
- case dwarf::DW_TAG_enumeration_type:
- case dwarf::DW_TAG_class_type:
- // If this is a class, structure, union, or enumeration type
- // that is a definition (not a declaration), and not scoped
- // inside a function then separate this out as a type unit.
- return !CTy.isForwardDecl() && isTypeUnitScoped(CTy, DD);
- default:
- return false;
- }
-}
-
/// constructTypeDIE - Construct type DIE from DICompositeType.
void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
// If this is a type applicable to a type unit it then add it to the