DebugInfo: Rename generic unit references to "TheU" instead of TheCU now that they might be type units instead of compile units.

CR feedback from Eric Christopher on r196139.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196159 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2013-12-02 22:09:48 +00:00
parent 7d318bd116
commit 451fa97c8c
3 changed files with 65 additions and 65 deletions

View File

@ -341,26 +341,26 @@ static bool SectionSort(const MCSection *A, const MCSection *B) {
// TODO: Determine whether or not we should add names for programs
// that do not have a DW_AT_name or DW_AT_linkage_name field - this
// is only slightly different than the lookup of non-standard ObjC names.
static void addSubprogramNames(Unit *TheCU, DISubprogram SP, DIE *Die) {
static void addSubprogramNames(Unit *TheU, DISubprogram SP, DIE *Die) {
if (!SP.isDefinition())
return;
TheCU->addAccelName(SP.getName(), Die);
TheU->addAccelName(SP.getName(), Die);
// If the linkage name is different than the name, go ahead and output
// that as well into the name table.
if (SP.getLinkageName() != "" && SP.getName() != SP.getLinkageName())
TheCU->addAccelName(SP.getLinkageName(), Die);
TheU->addAccelName(SP.getLinkageName(), Die);
// If this is an Objective-C selector name add it to the ObjC accelerator
// too.
if (isObjCClass(SP.getName())) {
StringRef Class, Category;
getObjCClassCategory(SP.getName(), Class, Category);
TheCU->addAccelObjC(Class, Die);
TheU->addAccelObjC(Class, Die);
if (Category != "")
TheCU->addAccelObjC(Category, Die);
TheU->addAccelObjC(Category, Die);
// Also add the base method name to the name table.
TheCU->addAccelName(getObjCMethodName(SP.getName()), Die);
TheU->addAccelName(getObjCMethodName(SP.getName()), Die);
}
}
@ -390,7 +390,8 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU, DISubprogram SP) {
// concrete DIE twice.
if (DIE *AbsSPDIE = AbstractSPDies.lookup(SP)) {
// Pick up abstract subprogram DIE.
SPDie = SPCU->createAndAddDIE(dwarf::DW_TAG_subprogram, *SPCU->getCUDie());
SPDie =
SPCU->createAndAddDIE(dwarf::DW_TAG_subprogram, *SPCU->getUnitDie());
SPCU->addDIEEntry(SPDie, dwarf::DW_AT_abstract_origin, AbsSPDIE);
} else {
DISubprogram SPDecl = SP.getFunctionDeclaration();
@ -421,8 +422,8 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU, DISubprogram SP) {
SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
}
DIE *SPDeclDie = SPDie;
SPDie =
SPCU->createAndAddDIE(dwarf::DW_TAG_subprogram, *SPCU->getCUDie());
SPDie = SPCU->createAndAddDIE(dwarf::DW_TAG_subprogram,
*SPCU->getUnitDie());
SPCU->addDIEEntry(SPDie, dwarf::DW_AT_specification, SPDeclDie);
}
}
@ -1066,28 +1067,27 @@ void DwarfDebug::finalizeModuleInfo() {
for (SmallVectorImpl<Unit *>::const_iterator I = getUnits().begin(),
E = getUnits().end();
I != E; ++I) {
Unit *TheCU = *I;
Unit *TheU = *I;
// Emit DW_AT_containing_type attribute to connect types with their
// vtable holding type.
TheCU->constructContainingTypeDIEs();
TheU->constructContainingTypeDIEs();
// If we're splitting the dwarf out now that we've got the entire
// CU then construct a skeleton CU based upon it.
if (useSplitDwarf() &&
TheCU->getCUDie()->getTag() == dwarf::DW_TAG_compile_unit) {
TheU->getUnitDie()->getTag() == dwarf::DW_TAG_compile_unit) {
uint64_t ID = 0;
if (GenerateCUHash) {
DIEHash CUHash;
ID = CUHash.computeCUSignature(*TheCU->getCUDie());
ID = CUHash.computeCUSignature(*TheU->getUnitDie());
}
// This should be a unique identifier when we want to build .dwp files.
TheCU->addUInt(TheCU->getCUDie(), dwarf::DW_AT_GNU_dwo_id,
dwarf::DW_FORM_data8, ID);
TheU->addUInt(TheU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
dwarf::DW_FORM_data8, ID);
// Now construct the skeleton CU associated.
CompileUnit *SkCU =
constructSkeletonCU(static_cast<CompileUnit *>(TheCU));
CompileUnit *SkCU = constructSkeletonCU(static_cast<CompileUnit *>(TheU));
// This should be a unique identifier when we want to build .dwp files.
SkCU->addUInt(SkCU->getCUDie(), dwarf::DW_AT_GNU_dwo_id,
SkCU->addUInt(SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
dwarf::DW_FORM_data8, ID);
}
}
@ -1965,7 +1965,7 @@ void DwarfUnits::computeSizeAndOffsets() {
// EndOffset here is CU-relative, after laying out
// all of the CU DIE.
unsigned EndOffset = computeSizeAndOffset((*I)->getCUDie(), Offset);
unsigned EndOffset = computeSizeAndOffset((*I)->getUnitDie(), Offset);
SecOffset += EndOffset;
}
}
@ -2134,22 +2134,22 @@ void DwarfUnits::emitUnits(DwarfDebug *DD, const MCSection *USection,
Asm->OutStreamer.SwitchSection(USection);
for (SmallVectorImpl<Unit *>::iterator I = CUs.begin(), E = CUs.end(); I != E;
++I) {
Unit *TheCU = *I;
DIE *Die = TheCU->getCUDie();
Unit *TheU = *I;
DIE *Die = TheU->getUnitDie();
// Emit the compile units header.
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol(USection->getLabelBeginName(),
TheCU->getUniqueID()));
Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol(USection->getLabelBeginName(), TheU->getUniqueID()));
// Emit size of content not including length itself
Asm->OutStreamer.AddComment("Length of Unit");
Asm->EmitInt32(TheCU->getHeaderSize() + Die->getSize());
Asm->EmitInt32(TheU->getHeaderSize() + Die->getSize());
TheCU->emitHeader(ASection, ASectionSym);
TheU->emitHeader(ASection, ASectionSym);
DD->emitDIE(Die, Abbreviations);
Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol(USection->getLabelEndName(), TheCU->getUniqueID()));
Asm->GetTempSymbol(USection->getLabelEndName(), TheU->getUniqueID()));
}
}
@ -2232,8 +2232,8 @@ void DwarfDebug::emitAccelNames() {
for (SmallVectorImpl<Unit *>::const_iterator I = getUnits().begin(),
E = getUnits().end();
I != E; ++I) {
Unit *TheCU = *I;
const StringMap<std::vector<const DIE *> > &Names = TheCU->getAccelNames();
Unit *TheU = *I;
const StringMap<std::vector<const DIE *> > &Names = TheU->getAccelNames();
for (StringMap<std::vector<const DIE *> >::const_iterator
GI = Names.begin(),
GE = Names.end();
@ -2265,8 +2265,8 @@ void DwarfDebug::emitAccelObjC() {
for (SmallVectorImpl<Unit *>::const_iterator I = getUnits().begin(),
E = getUnits().end();
I != E; ++I) {
Unit *TheCU = *I;
const StringMap<std::vector<const DIE *> > &Names = TheCU->getAccelObjC();
Unit *TheU = *I;
const StringMap<std::vector<const DIE *> > &Names = TheU->getAccelObjC();
for (StringMap<std::vector<const DIE *> >::const_iterator
GI = Names.begin(),
GE = Names.end();
@ -2297,9 +2297,9 @@ void DwarfDebug::emitAccelNamespaces() {
for (SmallVectorImpl<Unit *>::const_iterator I = getUnits().begin(),
E = getUnits().end();
I != E; ++I) {
Unit *TheCU = *I;
Unit *TheU = *I;
const StringMap<std::vector<const DIE *> > &Names =
TheCU->getAccelNamespace();
TheU->getAccelNamespace();
for (StringMap<std::vector<const DIE *> >::const_iterator
GI = Names.begin(),
GE = Names.end();
@ -2336,9 +2336,9 @@ void DwarfDebug::emitAccelTypes() {
for (SmallVectorImpl<Unit *>::const_iterator I = getUnits().begin(),
E = getUnits().end();
I != E; ++I) {
Unit *TheCU = *I;
Unit *TheU = *I;
const StringMap<std::vector<std::pair<const DIE *, unsigned> > > &Names =
TheCU->getAccelTypes();
TheU->getAccelTypes();
for (StringMap<
std::vector<std::pair<const DIE *, unsigned> > >::const_iterator
GI = Names.begin(),
@ -2433,8 +2433,8 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) {
for (SmallVectorImpl<Unit *>::const_iterator I = getUnits().begin(),
E = getUnits().end();
I != E; ++I) {
Unit *TheCU = *I;
unsigned ID = TheCU->getUniqueID();
Unit *TheU = *I;
unsigned ID = TheU->getUniqueID();
// Start the dwarf pubnames section.
Asm->OutStreamer.SwitchSection(PSec);
@ -2442,7 +2442,7 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) {
// Emit a label so we can reference the beginning of this pubname section.
if (GnuStyle)
Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol("gnu_pubnames", TheCU->getUniqueID()));
Asm->GetTempSymbol("gnu_pubnames", TheU->getUniqueID()));
// Emit the header.
Asm->OutStreamer.AddComment("Length of Public Names Info");
@ -2464,7 +2464,7 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) {
4);
// Emit the pubnames for this compilation unit.
const StringMap<const DIE *> &Globals = TheCU->getGlobalNames();
const StringMap<const DIE *> &Globals = TheU->getGlobalNames();
for (StringMap<const DIE *>::const_iterator GI = Globals.begin(),
GE = Globals.end();
GI != GE; ++GI) {
@ -2475,7 +2475,7 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) {
Asm->EmitInt32(Entity->getOffset());
if (GnuStyle) {
dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheCU, Entity);
dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheU, Entity);
Asm->OutStreamer.AddComment(
Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
@ -2502,23 +2502,23 @@ void DwarfDebug::emitDebugPubTypes(bool GnuStyle) {
for (SmallVectorImpl<Unit *>::const_iterator I = getUnits().begin(),
E = getUnits().end();
I != E; ++I) {
Unit *TheCU = *I;
Unit *TheU = *I;
// Start the dwarf pubtypes section.
Asm->OutStreamer.SwitchSection(PSec);
// Emit a label so we can reference the beginning of this pubtype section.
if (GnuStyle)
Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol("gnu_pubtypes", TheCU->getUniqueID()));
Asm->GetTempSymbol("gnu_pubtypes", TheU->getUniqueID()));
// Emit the header.
Asm->OutStreamer.AddComment("Length of Public Types Info");
Asm->EmitLabelDifference(
Asm->GetTempSymbol("pubtypes_end", TheCU->getUniqueID()),
Asm->GetTempSymbol("pubtypes_begin", TheCU->getUniqueID()), 4);
Asm->GetTempSymbol("pubtypes_end", TheU->getUniqueID()),
Asm->GetTempSymbol("pubtypes_begin", TheU->getUniqueID()), 4);
Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol("pubtypes_begin", TheCU->getUniqueID()));
Asm->GetTempSymbol("pubtypes_begin", TheU->getUniqueID()));
if (Asm->isVerbose())
Asm->OutStreamer.AddComment("DWARF Version");
@ -2526,16 +2526,16 @@ void DwarfDebug::emitDebugPubTypes(bool GnuStyle) {
Asm->OutStreamer.AddComment("Offset of Compilation Unit Info");
Asm->EmitSectionOffset(
Asm->GetTempSymbol(ISec->getLabelBeginName(), TheCU->getUniqueID()),
Asm->GetTempSymbol(ISec->getLabelBeginName(), TheU->getUniqueID()),
DwarfInfoSectionSym);
Asm->OutStreamer.AddComment("Compilation Unit Length");
Asm->EmitLabelDifference(
Asm->GetTempSymbol(ISec->getLabelEndName(), TheCU->getUniqueID()),
Asm->GetTempSymbol(ISec->getLabelBeginName(), TheCU->getUniqueID()), 4);
Asm->GetTempSymbol(ISec->getLabelEndName(), TheU->getUniqueID()),
Asm->GetTempSymbol(ISec->getLabelBeginName(), TheU->getUniqueID()), 4);
// Emit the pubtypes.
const StringMap<const DIE *> &Globals = TheCU->getGlobalTypes();
const StringMap<const DIE *> &Globals = TheU->getGlobalTypes();
for (StringMap<const DIE *>::const_iterator GI = Globals.begin(),
GE = Globals.end();
GI != GE; ++GI) {
@ -2547,7 +2547,7 @@ void DwarfDebug::emitDebugPubTypes(bool GnuStyle) {
Asm->EmitInt32(Entity->getOffset());
if (GnuStyle) {
dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheCU, Entity);
dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheU, Entity);
Asm->OutStreamer.AddComment(
Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
@ -2564,7 +2564,7 @@ void DwarfDebug::emitDebugPubTypes(bool GnuStyle) {
Asm->OutStreamer.AddComment("End Mark");
Asm->EmitInt32(0);
Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol("pubtypes_end", TheCU->getUniqueID()));
Asm->GetTempSymbol("pubtypes_end", TheU->getUniqueID()));
}
}

View File

@ -37,10 +37,10 @@ static cl::opt<bool> GenerateTypeUnits("generate-type-units", cl::Hidden,
cl::desc("Generate DWARF4 type units."),
cl::init(false));
/// Unit - Compile unit constructor.
/// Unit - Unit constructor.
Unit::Unit(unsigned UID, DIE *D, DICompileUnit Node, AsmPrinter *A,
DwarfDebug *DW, DwarfUnits *DWU)
: UniqueID(UID), Node(Node), CUDie(D), DebugInfoOffset(0), Asm(A), DD(DW),
: UniqueID(UID), Node(Node), UnitDie(D), DebugInfoOffset(0), Asm(A), DD(DW),
DU(DWU), IndexTyDie(0) {
DIEIntegerOne = new (DIEValueAllocator) DIEInteger(1);
}
@ -322,9 +322,9 @@ void Unit::addDIEEntry(DIE *Die, dwarf::Attribute Attribute, DIEEntry *Entry) {
const DIE *EntryCU = Entry->getEntry()->getUnitOrNull();
if (!DieCU)
// We assume that Die belongs to this CU, if it is not linked to any CU yet.
DieCU = getCUDie();
DieCU = getUnitDie();
if (!EntryCU)
EntryCU = getCUDie();
EntryCU = getUnitDie();
Die->addValue(Attribute, EntryCU == DieCU ? dwarf::DW_FORM_ref4
: dwarf::DW_FORM_ref_addr,
Entry);
@ -894,7 +894,7 @@ void Unit::addTemplateParams(DIE &Buffer, DIArray TParams) {
/// getOrCreateContextDIE - Get context owner's DIE.
DIE *Unit::getOrCreateContextDIE(DIScope Context) {
if (!Context || Context.isFile())
return getCUDie();
return getUnitDie();
if (Context.isType())
return getOrCreateTypeDIE(DIType(Context));
if (Context.isNameSpace())
@ -1413,7 +1413,7 @@ DIE *Unit::getOrCreateSubprogramDIE(DISubprogram SP) {
DISubprogram SPDecl = SP.getFunctionDeclaration();
if (SPDecl.isSubprogram())
// Add subprogram definitions to the CU die directly.
ContextDIE = CUDie.get();
ContextDIE = UnitDie.get();
// DW_TAG_inlined_subroutine may refer to this DIE.
SPDie = createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, SP);
@ -1616,7 +1616,7 @@ void CompileUnit::createGlobalVariableDIE(DIGlobalVariable GV) {
if (GVContext && GV.isDefinition() && !GVContext.isCompileUnit() &&
!GVContext.isFile() && !DD->isSubprogramContext(GVContext)) {
// Create specification DIE.
VariableSpecDIE = createAndAddDIE(dwarf::DW_TAG_variable, *CUDie);
VariableSpecDIE = createAndAddDIE(dwarf::DW_TAG_variable, *UnitDie);
addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, VariableDIE);
addBlock(VariableSpecDIE, dwarf::DW_AT_location, Block);
// A static member's declaration is already flagged as such.
@ -1712,7 +1712,7 @@ void Unit::constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy) {
DIE *IdxTy = getIndexTyDie();
if (!IdxTy) {
// Construct an anonymous type for index type.
IdxTy = createAndAddDIE(dwarf::DW_TAG_base_type, *CUDie.get());
IdxTy = createAndAddDIE(dwarf::DW_TAG_base_type, *UnitDie);
addString(IdxTy, dwarf::DW_AT_name, "int");
addUInt(IdxTy, dwarf::DW_AT_byte_size, None, sizeof(int32_t));
addUInt(IdxTy, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,

View File

@ -42,10 +42,10 @@ protected:
/// Node - MDNode for the compile unit.
DICompileUnit Node;
/// CUDie - Compile unit debug information entry.
const OwningPtr<DIE> CUDie;
/// Unit debug information entry.
const OwningPtr<DIE> UnitDie;
/// Offset of the CUDie from beginning of debug info section.
/// Offset of the UnitDie from beginning of debug info section.
unsigned DebugInfoOffset;
/// Asm - Target of Dwarf emission.
@ -55,7 +55,7 @@ protected:
DwarfDebug *DD;
DwarfUnits *DU;
/// IndexTyDie - An anonymous type for index type. Owned by CUDie.
/// IndexTyDie - An anonymous type for index type. Owned by UnitDie.
DIE *IndexTyDie;
/// MDNodeToDieMap - Tracks the mapping of unit level debug information
@ -108,7 +108,7 @@ public:
unsigned getUniqueID() const { return UniqueID; }
virtual uint16_t getLanguage() const = 0;
DICompileUnit getNode() const { return Node; }
DIE *getCUDie() const { return CUDie.get(); }
DIE *getUnitDie() const { return UnitDie.get(); }
const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
@ -130,7 +130,7 @@ public:
void setDebugInfoOffset(unsigned DbgInfoOff) { DebugInfoOffset = DbgInfoOff; }
/// hasContent - Return true if this compile unit has something to write out.
bool hasContent() const { return !CUDie->getChildren().empty(); }
bool hasContent() const { return !UnitDie->getChildren().empty(); }
/// getParentContextString - Get a string containing the language specific
/// context for a global name.
@ -170,7 +170,7 @@ public:
/// addDie - Adds or interns the DIE to the compile unit.
///
void addDie(DIE *Buffer) { CUDie->addChild(Buffer); }
void addDie(DIE *Buffer) { UnitDie->addChild(Buffer); }
/// addFlag - Add a flag that is true to the DIE.
void addFlag(DIE *Die, dwarf::Attribute Attribute);