index 0e3db3c50859c1fed31e563bd4a74dad71f203e4..9478453b4ca98ab95ad23478eab2e237b768e436 100644 (file)
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Mangler.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
-#include "llvm/Target/Mangler.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Target/TargetFrameLowering.h"
-#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
+#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegisterInfo.h"
-#include "llvm/Support/CommandLine.h"
using namespace llvm;
/// Unit - Unit constructor.
DwarfUnit::DwarfUnit(unsigned UID, DIE *D, DICompileUnit Node, AsmPrinter *A,
DwarfDebug *DW, DwarfFile *DWU)
- : UniqueID(UID), Node(Node), UnitDie(D), DebugInfoOffset(0), Asm(A), DD(DW),
- DU(DWU), IndexTyDie(0), Section(0), Skeleton(0) {
+ : UniqueID(UID), CUNode(Node), UnitDie(D), DebugInfoOffset(0), Asm(A),
+ DD(DW), DU(DWU), IndexTyDie(0), Section(0), Skeleton(0) {
DIEIntegerOne = new (DIEValueAllocator) DIEInteger(1);
}
insertDIE(Node, D);
}
-DwarfTypeUnit::DwarfTypeUnit(unsigned UID, DIE *D, uint16_t Language,
+DwarfTypeUnit::DwarfTypeUnit(unsigned UID, DIE *D, DICompileUnit CUNode,
AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU)
- : DwarfUnit(UID, D, DICompileUnit(), A, DW, DWU), Language(Language) {}
+ : DwarfUnit(UID, D, CUNode, A, DW, DWU) {}
/// ~Unit - Destructor for compile unit.
DwarfUnit::~DwarfUnit() {
return TyDIE;
}
-/// Return true if the type is appropriately scoped to be contained inside
-/// its own type unit.
-static bool isDwarfTypeUnitScoped(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 shouldCreateDwarfTypeUnit(DICompositeType CTy,
- const DwarfDebug *DD) {
- if (!GenerateDwarfTypeUnits)
- 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() && isDwarfTypeUnitScoped(CTy, DD);
- default:
- return false;
- }
-}
-
/// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
/// given DIType.
DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
constructTypeDIE(*TyDIE, DIBasicType(Ty));
else if (Ty.isCompositeType()) {
DICompositeType CTy(Ty);
- if (shouldCreateDwarfTypeUnit(CTy, DD)) {
- DD->addDwarfTypeUnitType(getLanguage(), TyDIE, CTy);
- // Skip updating the accellerator tables since this is not the full type
- return TyDIE;
- }
+ if (GenerateDwarfTypeUnits && !Ty.isForwardDecl())
+ if (MDString *TypeId = CTy.getIdentifier()) {
+ DD->addDwarfTypeUnitType(getCUNode(), TypeId->getString(), TyDIE, CTy);
+ // Skip updating the accellerator tables since this is not the full type
+ return TyDIE;
+ }
constructTypeDIE(*TyDIE, CTy);
} else {
assert(Ty.isDerivedType() && "Unknown kind of DIType");
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
DIDescriptor Element = Elements.getElement(i);
DIE *ElemDie = NULL;
- if (Element.isSubprogram()) {
- DISubprogram SP(Element);
- ElemDie = getOrCreateSubprogramDIE(SP);
- if (SP.isProtected())
- addUInt(ElemDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
- dwarf::DW_ACCESS_protected);
- else if (SP.isPrivate())
- addUInt(ElemDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
- dwarf::DW_ACCESS_private);
- else
- addUInt(ElemDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
- dwarf::DW_ACCESS_public);
- if (SP.isExplicit())
- addFlag(ElemDie, dwarf::DW_AT_explicit);
- } else if (Element.isDerivedType()) {
+ if (Element.isSubprogram())
+ ElemDie = getOrCreateSubprogramDIE(DISubprogram(Element));
+ else if (Element.isDerivedType()) {
DIDerivedType DDTy(Element);
if (DDTy.getTag() == dwarf::DW_TAG_friend) {
ElemDie = createAndAddDIE(dwarf::DW_TAG_friend, Buffer);
ElemDie = createAndAddDIE(Property.getTag(), Buffer);
StringRef PropertyName = Property.getObjCPropertyName();
addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
- addType(ElemDie, Property.getType());
+ if (Property.getType())
+ addType(ElemDie, Property.getType());
addSourceLine(ElemDie, Property);
StringRef GetterName = Property.getObjCPropertyGetterName();
if (!GetterName.empty())
if (SP.isRValueReference())
addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
+ if (SP.isProtected())
+ addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
+ dwarf::DW_ACCESS_protected);
+ else if (SP.isPrivate())
+ addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
+ dwarf::DW_ACCESS_private);
+ else
+ addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
+ dwarf::DW_ACCESS_public);
+
+ if (SP.isExplicit())
+ addFlag(SPDie, dwarf::DW_AT_explicit);
+
return SPDie;
}
Offset = FieldSize - (Offset + Size);
addUInt(MemberDie, dwarf::DW_AT_bit_offset, None, Offset);
- // Here WD_AT_data_member_location points to the anonymous
+ // Here DW_AT_data_member_location points to the anonymous
// field that includes this bit field.
OffsetInBytes = FieldOffset >> 3;
} else
Asm->OutStreamer.AddComment("Type Signature");
Asm->OutStreamer.EmitIntValue(TypeSignature, sizeof(TypeSignature));
Asm->OutStreamer.AddComment("Type DIE Offset");
- Asm->OutStreamer.EmitIntValue(Ty->getOffset(), sizeof(Ty->getOffset()));
+ // In a skeleton type unit there is no type DIE so emit a zero offset.
+ Asm->OutStreamer.EmitIntValue(Ty ? Ty->getOffset() : 0,
+ sizeof(Ty->getOffset()));
}
void DwarfTypeUnit::initSection(const MCSection *Section) {