DwarfUnit: Rename "Node" to "CUNode" and propagate it through DwarfTypeUnit as well.

Since we'll now also need the split dwarf file name along with the
language in DwarfTypeUnits, just use the whole DICompileUnit rather than
explicitly handling each field needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198842 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2014-01-09 03:23:41 +00:00
parent 75a032dc00
commit 2af945d2cd
4 changed files with 18 additions and 22 deletions

View File

@ -2938,12 +2938,12 @@ DwarfCompileUnit *DwarfDebug::constructSkeletonCU(const DwarfCompileUnit *CU) {
DIE *Die = new DIE(dwarf::DW_TAG_compile_unit); DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
DwarfCompileUnit *NewCU = new DwarfCompileUnit( DwarfCompileUnit *NewCU = new DwarfCompileUnit(
CU->getUniqueID(), Die, CU->getNode(), Asm, this, &SkeletonHolder); CU->getUniqueID(), Die, CU->getCUNode(), Asm, this, &SkeletonHolder);
NewCU->initSection(Asm->getObjFileLowering().getDwarfInfoSection(), NewCU->initSection(Asm->getObjFileLowering().getDwarfInfoSection(),
DwarfInfoSectionSym); DwarfInfoSectionSym);
NewCU->addLocalString(Die, dwarf::DW_AT_GNU_dwo_name, NewCU->addLocalString(Die, dwarf::DW_AT_GNU_dwo_name,
CU->getNode().getSplitDebugFilename()); CU->getCUNode().getSplitDebugFilename());
// Relocate to the beginning of the addr_base section, else 0 for the // Relocate to the beginning of the addr_base section, else 0 for the
// beginning of the one for this compile unit. // beginning of the one for this compile unit.
@ -2999,19 +2999,20 @@ void DwarfDebug::emitDebugStrDWO() {
OffSec, StrSym); OffSec, StrSym);
} }
void DwarfDebug::addDwarfTypeUnitType(uint16_t Language, StringRef Identifier, void DwarfDebug::addDwarfTypeUnitType(DICompileUnit CUNode,
DIE *RefDie, DICompositeType CTy) { StringRef Identifier, DIE *RefDie,
DICompositeType CTy) {
const DwarfTypeUnit *&TU = DwarfTypeUnits[CTy]; const DwarfTypeUnit *&TU = DwarfTypeUnits[CTy];
if (!TU) { if (!TU) {
DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit); DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit);
DwarfTypeUnit *NewTU = DwarfTypeUnit *NewTU =
new DwarfTypeUnit(InfoHolder.getUnits().size(), UnitDie, Language, Asm, new DwarfTypeUnit(InfoHolder.getUnits().size(), UnitDie, CUNode, Asm,
this, &InfoHolder); this, &InfoHolder);
TU = NewTU; TU = NewTU;
InfoHolder.addUnit(NewTU); InfoHolder.addUnit(NewTU);
NewTU->addUInt(UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2, NewTU->addUInt(UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
Language); CUNode.getLanguage());
DIE *Die = NewTU->createTypeDIE(CTy); DIE *Die = NewTU->createTypeDIE(CTy);

View File

@ -695,8 +695,8 @@ public:
/// \brief Add a DIE to the set of types that we're going to pull into /// \brief Add a DIE to the set of types that we're going to pull into
/// type units. /// type units.
void addDwarfTypeUnitType(uint16_t Language, StringRef Identifier, DIE *Die, void addDwarfTypeUnitType(DICompileUnit CUNode, StringRef Identifier,
DICompositeType CTy); DIE *Die, DICompositeType CTy);
/// \brief Add a label so that arange data can be generated for it. /// \brief Add a label so that arange data can be generated for it.
void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); } void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }

View File

@ -42,8 +42,8 @@ GenerateDwarfTypeUnits("generate-type-units", cl::Hidden,
/// Unit - Unit constructor. /// Unit - Unit constructor.
DwarfUnit::DwarfUnit(unsigned UID, DIE *D, DICompileUnit Node, AsmPrinter *A, DwarfUnit::DwarfUnit(unsigned UID, DIE *D, DICompileUnit Node, AsmPrinter *A,
DwarfDebug *DW, DwarfFile *DWU) DwarfDebug *DW, DwarfFile *DWU)
: UniqueID(UID), Node(Node), UnitDie(D), DebugInfoOffset(0), Asm(A), DD(DW), : UniqueID(UID), CUNode(Node), UnitDie(D), DebugInfoOffset(0), Asm(A),
DU(DWU), IndexTyDie(0), Section(0), Skeleton(0) { DD(DW), DU(DWU), IndexTyDie(0), Section(0), Skeleton(0) {
DIEIntegerOne = new (DIEValueAllocator) DIEInteger(1); DIEIntegerOne = new (DIEValueAllocator) DIEInteger(1);
} }
@ -54,9 +54,9 @@ DwarfCompileUnit::DwarfCompileUnit(unsigned UID, DIE *D, DICompileUnit Node,
insertDIE(Node, D); 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) 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. /// ~Unit - Destructor for compile unit.
DwarfUnit::~DwarfUnit() { DwarfUnit::~DwarfUnit() {
@ -956,8 +956,7 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
DICompositeType CTy(Ty); DICompositeType CTy(Ty);
if (GenerateDwarfTypeUnits && !Ty.isForwardDecl()) if (GenerateDwarfTypeUnits && !Ty.isForwardDecl())
if (MDString *TypeId = CTy.getIdentifier()) { if (MDString *TypeId = CTy.getIdentifier()) {
DD->addDwarfTypeUnitType(getLanguage(), TypeId->getString(), TyDIE, DD->addDwarfTypeUnitType(getCUNode(), TypeId->getString(), TyDIE, CTy);
CTy);
// Skip updating the accellerator tables since this is not the full type // Skip updating the accellerator tables since this is not the full type
return TyDIE; return TyDIE;
} }

View File

@ -66,7 +66,7 @@ protected:
unsigned UniqueID; unsigned UniqueID;
/// Node - MDNode for the compile unit. /// Node - MDNode for the compile unit.
DICompileUnit Node; DICompileUnit CUNode;
/// Unit debug information entry. /// Unit debug information entry.
const OwningPtr<DIE> UnitDie; const OwningPtr<DIE> UnitDie;
@ -218,8 +218,8 @@ public:
// Accessors. // Accessors.
unsigned getUniqueID() const { return UniqueID; } unsigned getUniqueID() const { return UniqueID; }
virtual uint16_t getLanguage() const = 0; uint16_t getLanguage() const { return CUNode.getLanguage(); }
DICompileUnit getNode() const { return Node; } DICompileUnit getCUNode() const { return CUNode; }
DIE *getUnitDie() const { return UnitDie.get(); } DIE *getUnitDie() const { return UnitDie.get(); }
const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; } const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; } const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
@ -545,18 +545,15 @@ public:
/// addLabelAddress - Add a dwarf label attribute data and value using /// addLabelAddress - Add a dwarf label attribute data and value using
/// either DW_FORM_addr or DW_FORM_GNU_addr_index. /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label); void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label);
uint16_t getLanguage() const LLVM_OVERRIDE { return getNode().getLanguage(); }
}; };
class DwarfTypeUnit : public DwarfUnit { class DwarfTypeUnit : public DwarfUnit {
private: private:
uint16_t Language;
uint64_t TypeSignature; uint64_t TypeSignature;
const DIE *Ty; const DIE *Ty;
public: public:
DwarfTypeUnit(unsigned UID, DIE *D, uint16_t Language, AsmPrinter *A, DwarfTypeUnit(unsigned UID, DIE *D, DICompileUnit CUNode, AsmPrinter *A,
DwarfDebug *DW, DwarfFile *DWU); DwarfDebug *DW, DwarfFile *DWU);
virtual ~DwarfTypeUnit() LLVM_OVERRIDE; virtual ~DwarfTypeUnit() LLVM_OVERRIDE;
@ -564,7 +561,6 @@ public:
uint64_t getTypeSignature() const { return TypeSignature; } uint64_t getTypeSignature() const { return TypeSignature; }
void setType(const DIE *Ty) { this->Ty = Ty; } void setType(const DIE *Ty) { this->Ty = Ty; }
uint16_t getLanguage() const LLVM_OVERRIDE { return Language; }
/// Emit the header for this unit, not including the initial length field. /// Emit the header for this unit, not including the initial length field.
void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym) const void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym) const
LLVM_OVERRIDE; LLVM_OVERRIDE;