mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-14 13:57:51 +00:00
Push memory ownership of DwarfUnits into clients of DwarfFile.
This prompted me to push references through most of DwarfDebug. Sorry for the churn. Honestly it's a bit silly that we're passing around units all over the place like that anyway and I think it's mostly due to the DIE attribute adding utility functions being utilities in DwarfUnit. I should have another go at moving them out of DwarfUnit... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206925 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
423575405d
commit
875f90e527
@ -280,8 +280,8 @@ void DwarfFile::assignAbbrevNumber(DIEAbbrev &Abbrev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfFile::addUnit(DwarfUnit *CU) {
|
void DwarfFile::addUnit(std::unique_ptr<DwarfUnit> U) {
|
||||||
CUs.push_back(std::unique_ptr<DwarfUnit>(CU));
|
CUs.push_back(std::move(U));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isObjCClass(StringRef Name) {
|
static bool isObjCClass(StringRef Name) {
|
||||||
@ -323,26 +323,26 @@ static bool SectionSort(const MCSection *A, const MCSection *B) {
|
|||||||
// TODO: Determine whether or not we should add names for programs
|
// 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
|
// 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.
|
// is only slightly different than the lookup of non-standard ObjC names.
|
||||||
static void addSubprogramNames(DwarfUnit *TheU, DISubprogram SP, DIE *Die) {
|
static void addSubprogramNames(DwarfUnit &TheU, DISubprogram SP, DIE *Die) {
|
||||||
if (!SP.isDefinition())
|
if (!SP.isDefinition())
|
||||||
return;
|
return;
|
||||||
TheU->addAccelName(SP.getName(), Die);
|
TheU.addAccelName(SP.getName(), Die);
|
||||||
|
|
||||||
// If the linkage name is different than the name, go ahead and output
|
// If the linkage name is different than the name, go ahead and output
|
||||||
// that as well into the name table.
|
// that as well into the name table.
|
||||||
if (SP.getLinkageName() != "" && SP.getName() != SP.getLinkageName())
|
if (SP.getLinkageName() != "" && SP.getName() != SP.getLinkageName())
|
||||||
TheU->addAccelName(SP.getLinkageName(), Die);
|
TheU.addAccelName(SP.getLinkageName(), Die);
|
||||||
|
|
||||||
// If this is an Objective-C selector name add it to the ObjC accelerator
|
// If this is an Objective-C selector name add it to the ObjC accelerator
|
||||||
// too.
|
// too.
|
||||||
if (isObjCClass(SP.getName())) {
|
if (isObjCClass(SP.getName())) {
|
||||||
StringRef Class, Category;
|
StringRef Class, Category;
|
||||||
getObjCClassCategory(SP.getName(), Class, Category);
|
getObjCClassCategory(SP.getName(), Class, Category);
|
||||||
TheU->addAccelObjC(Class, Die);
|
TheU.addAccelObjC(Class, Die);
|
||||||
if (Category != "")
|
if (Category != "")
|
||||||
TheU->addAccelObjC(Category, Die);
|
TheU.addAccelObjC(Category, Die);
|
||||||
// Also add the base method name to the name table.
|
// Also add the base method name to the name table.
|
||||||
TheU->addAccelName(getObjCMethodName(SP.getName()), Die);
|
TheU.addAccelName(getObjCMethodName(SP.getName()), Die);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,9 +362,9 @@ bool DwarfDebug::isSubprogramContext(const MDNode *Context) {
|
|||||||
// Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
|
// Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
|
||||||
// and DW_AT_high_pc attributes. If there are global variables in this
|
// and DW_AT_high_pc attributes. If there are global variables in this
|
||||||
// scope then create and insert DIEs for these variables.
|
// scope then create and insert DIEs for these variables.
|
||||||
DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit *SPCU,
|
DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit &SPCU,
|
||||||
DISubprogram SP) {
|
DISubprogram SP) {
|
||||||
DIE *SPDie = SPCU->getDIE(SP);
|
DIE *SPDie = SPCU.getDIE(SP);
|
||||||
|
|
||||||
assert(SPDie && "Unable to find subprogram DIE!");
|
assert(SPDie && "Unable to find subprogram DIE!");
|
||||||
|
|
||||||
@ -374,8 +374,8 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit *SPCU,
|
|||||||
if (DIE *AbsSPDIE = AbstractSPDies.lookup(SP)) {
|
if (DIE *AbsSPDIE = AbstractSPDies.lookup(SP)) {
|
||||||
// Pick up abstract subprogram DIE.
|
// Pick up abstract subprogram DIE.
|
||||||
SPDie =
|
SPDie =
|
||||||
SPCU->createAndAddDIE(dwarf::DW_TAG_subprogram, *SPCU->getUnitDie());
|
SPCU.createAndAddDIE(dwarf::DW_TAG_subprogram, *SPCU.getUnitDie());
|
||||||
SPCU->addDIEEntry(SPDie, dwarf::DW_AT_abstract_origin, AbsSPDIE);
|
SPCU.addDIEEntry(SPDie, dwarf::DW_AT_abstract_origin, AbsSPDIE);
|
||||||
} else {
|
} else {
|
||||||
DISubprogram SPDecl = SP.getFunctionDeclaration();
|
DISubprogram SPDecl = SP.getFunctionDeclaration();
|
||||||
if (!SPDecl.isSubprogram()) {
|
if (!SPDecl.isSubprogram()) {
|
||||||
@ -387,18 +387,18 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit *SPCU,
|
|||||||
DIScope SPContext = resolve(SP.getContext());
|
DIScope SPContext = resolve(SP.getContext());
|
||||||
if (SP.isDefinition() && !SPContext.isCompileUnit() &&
|
if (SP.isDefinition() && !SPContext.isCompileUnit() &&
|
||||||
!SPContext.isFile() && !isSubprogramContext(SPContext)) {
|
!SPContext.isFile() && !isSubprogramContext(SPContext)) {
|
||||||
SPCU->addFlag(SPDie, dwarf::DW_AT_declaration);
|
SPCU.addFlag(SPDie, dwarf::DW_AT_declaration);
|
||||||
|
|
||||||
// Add arguments.
|
// Add arguments.
|
||||||
DICompositeType SPTy = SP.getType();
|
DICompositeType SPTy = SP.getType();
|
||||||
DIArray Args = SPTy.getTypeArray();
|
DIArray Args = SPTy.getTypeArray();
|
||||||
uint16_t SPTag = SPTy.getTag();
|
uint16_t SPTag = SPTy.getTag();
|
||||||
if (SPTag == dwarf::DW_TAG_subroutine_type)
|
if (SPTag == dwarf::DW_TAG_subroutine_type)
|
||||||
SPCU->constructSubprogramArguments(*SPDie, Args);
|
SPCU.constructSubprogramArguments(*SPDie, Args);
|
||||||
DIE *SPDeclDie = SPDie;
|
DIE *SPDeclDie = SPDie;
|
||||||
SPDie = SPCU->createAndAddDIE(dwarf::DW_TAG_subprogram,
|
SPDie = SPCU.createAndAddDIE(dwarf::DW_TAG_subprogram,
|
||||||
*SPCU->getUnitDie());
|
*SPCU.getUnitDie());
|
||||||
SPCU->addDIEEntry(SPDie, dwarf::DW_AT_specification, SPDeclDie);
|
SPCU.addDIEEntry(SPDie, dwarf::DW_AT_specification, SPDeclDie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,7 +407,7 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit *SPCU,
|
|||||||
|
|
||||||
const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
|
const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
|
||||||
MachineLocation Location(RI->getFrameRegister(*Asm->MF));
|
MachineLocation Location(RI->getFrameRegister(*Asm->MF));
|
||||||
SPCU->addAddress(SPDie, dwarf::DW_AT_frame_base, Location);
|
SPCU.addAddress(SPDie, dwarf::DW_AT_frame_base, Location);
|
||||||
|
|
||||||
// Add name to the name table, we do this here because we're guaranteed
|
// Add name to the name table, we do this here because we're guaranteed
|
||||||
// to have concrete versions of our DW_TAG_subprogram nodes.
|
// to have concrete versions of our DW_TAG_subprogram nodes.
|
||||||
@ -437,16 +437,16 @@ bool DwarfDebug::isLexicalScopeDIENull(LexicalScope *Scope) {
|
|||||||
return !End;
|
return !End;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addSectionLabel(AsmPrinter *Asm, DwarfUnit *U, DIE *D,
|
static void addSectionLabel(AsmPrinter &Asm, DwarfUnit &U, DIE *D,
|
||||||
dwarf::Attribute A, const MCSymbol *L,
|
dwarf::Attribute A, const MCSymbol *L,
|
||||||
const MCSymbol *Sec) {
|
const MCSymbol *Sec) {
|
||||||
if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
|
if (Asm.MAI->doesDwarfUseRelocationsAcrossSections())
|
||||||
U->addSectionLabel(D, A, L);
|
U.addSectionLabel(D, A, L);
|
||||||
else
|
else
|
||||||
U->addSectionDelta(D, A, L, Sec);
|
U.addSectionDelta(D, A, L, Sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfDebug::addScopeRangeList(DwarfCompileUnit *TheCU, DIE *ScopeDIE,
|
void DwarfDebug::addScopeRangeList(DwarfCompileUnit &TheCU, DIE *ScopeDIE,
|
||||||
const SmallVectorImpl<InsnRange> &Range) {
|
const SmallVectorImpl<InsnRange> &Range) {
|
||||||
// Emit offset in .debug_range as a relocatable label. emitDIE will handle
|
// Emit offset in .debug_range as a relocatable label. emitDIE will handle
|
||||||
// emitting it appropriately.
|
// emitting it appropriately.
|
||||||
@ -455,10 +455,10 @@ void DwarfDebug::addScopeRangeList(DwarfCompileUnit *TheCU, DIE *ScopeDIE,
|
|||||||
// Under fission, ranges are specified by constant offsets relative to the
|
// Under fission, ranges are specified by constant offsets relative to the
|
||||||
// CU's DW_AT_GNU_ranges_base.
|
// CU's DW_AT_GNU_ranges_base.
|
||||||
if (useSplitDwarf())
|
if (useSplitDwarf())
|
||||||
TheCU->addSectionDelta(ScopeDIE, dwarf::DW_AT_ranges, RangeSym,
|
TheCU.addSectionDelta(ScopeDIE, dwarf::DW_AT_ranges, RangeSym,
|
||||||
DwarfDebugRangeSectionSym);
|
DwarfDebugRangeSectionSym);
|
||||||
else
|
else
|
||||||
addSectionLabel(Asm, TheCU, ScopeDIE, dwarf::DW_AT_ranges, RangeSym,
|
addSectionLabel(*Asm, TheCU, ScopeDIE, dwarf::DW_AT_ranges, RangeSym,
|
||||||
DwarfDebugRangeSectionSym);
|
DwarfDebugRangeSectionSym);
|
||||||
|
|
||||||
RangeSpanList List(RangeSym);
|
RangeSpanList List(RangeSym);
|
||||||
@ -468,12 +468,12 @@ void DwarfDebug::addScopeRangeList(DwarfCompileUnit *TheCU, DIE *ScopeDIE,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the range list to the set of ranges to be emitted.
|
// Add the range list to the set of ranges to be emitted.
|
||||||
TheCU->addRangeList(std::move(List));
|
TheCU.addRangeList(std::move(List));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct new DW_TAG_lexical_block for this scope and attach
|
// Construct new DW_TAG_lexical_block for this scope and attach
|
||||||
// DW_AT_low_pc/DW_AT_high_pc labels.
|
// DW_AT_low_pc/DW_AT_high_pc labels.
|
||||||
DIE *DwarfDebug::constructLexicalScopeDIE(DwarfCompileUnit *TheCU,
|
DIE *DwarfDebug::constructLexicalScopeDIE(DwarfCompileUnit &TheCU,
|
||||||
LexicalScope *Scope) {
|
LexicalScope *Scope) {
|
||||||
if (isLexicalScopeDIENull(Scope))
|
if (isLexicalScopeDIENull(Scope))
|
||||||
return 0;
|
return 0;
|
||||||
@ -506,7 +506,7 @@ DIE *DwarfDebug::constructLexicalScopeDIE(DwarfCompileUnit *TheCU,
|
|||||||
|
|
||||||
// This scope represents inlined body of a function. Construct DIE to
|
// This scope represents inlined body of a function. Construct DIE to
|
||||||
// represent this concrete inlined copy of the function.
|
// represent this concrete inlined copy of the function.
|
||||||
DIE *DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit *TheCU,
|
DIE *DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit &TheCU,
|
||||||
LexicalScope *Scope) {
|
LexicalScope *Scope) {
|
||||||
const SmallVectorImpl<InsnRange> &ScopeRanges = Scope->getRanges();
|
const SmallVectorImpl<InsnRange> &ScopeRanges = Scope->getRanges();
|
||||||
assert(!ScopeRanges.empty() &&
|
assert(!ScopeRanges.empty() &&
|
||||||
@ -516,14 +516,14 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit *TheCU,
|
|||||||
return NULL;
|
return NULL;
|
||||||
DIScope DS(Scope->getScopeNode());
|
DIScope DS(Scope->getScopeNode());
|
||||||
DISubprogram InlinedSP = getDISubprogram(DS);
|
DISubprogram InlinedSP = getDISubprogram(DS);
|
||||||
DIE *OriginDIE = TheCU->getDIE(InlinedSP);
|
DIE *OriginDIE = TheCU.getDIE(InlinedSP);
|
||||||
if (!OriginDIE) {
|
if (!OriginDIE) {
|
||||||
DEBUG(dbgs() << "Unable to find original DIE for an inlined subprogram.");
|
DEBUG(dbgs() << "Unable to find original DIE for an inlined subprogram.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DIE *ScopeDIE = new DIE(dwarf::DW_TAG_inlined_subroutine);
|
DIE *ScopeDIE = new DIE(dwarf::DW_TAG_inlined_subroutine);
|
||||||
TheCU->addDIEEntry(ScopeDIE, dwarf::DW_AT_abstract_origin, OriginDIE);
|
TheCU.addDIEEntry(ScopeDIE, dwarf::DW_AT_abstract_origin, OriginDIE);
|
||||||
|
|
||||||
// If we have multiple ranges, emit them into the range section.
|
// If we have multiple ranges, emit them into the range section.
|
||||||
if (ScopeRanges.size() > 1)
|
if (ScopeRanges.size() > 1)
|
||||||
@ -547,10 +547,10 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit *TheCU,
|
|||||||
|
|
||||||
// Add the call site information to the DIE.
|
// Add the call site information to the DIE.
|
||||||
DILocation DL(Scope->getInlinedAt());
|
DILocation DL(Scope->getInlinedAt());
|
||||||
TheCU->addUInt(
|
TheCU.addUInt(
|
||||||
ScopeDIE, dwarf::DW_AT_call_file, None,
|
ScopeDIE, dwarf::DW_AT_call_file, None,
|
||||||
TheCU->getOrCreateSourceID(DL.getFilename(), DL.getDirectory()));
|
TheCU.getOrCreateSourceID(DL.getFilename(), DL.getDirectory()));
|
||||||
TheCU->addUInt(ScopeDIE, dwarf::DW_AT_call_line, None, DL.getLineNumber());
|
TheCU.addUInt(ScopeDIE, dwarf::DW_AT_call_line, None, DL.getLineNumber());
|
||||||
|
|
||||||
// Add name to the name table, we do this here because we're guaranteed
|
// Add name to the name table, we do this here because we're guaranteed
|
||||||
// to have concrete versions of our DW_TAG_inlined_subprogram nodes.
|
// to have concrete versions of our DW_TAG_inlined_subprogram nodes.
|
||||||
@ -559,7 +559,7 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit *TheCU,
|
|||||||
return ScopeDIE;
|
return ScopeDIE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit *TheCU,
|
DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit &TheCU,
|
||||||
LexicalScope *Scope,
|
LexicalScope *Scope,
|
||||||
SmallVectorImpl<DIE *> &Children) {
|
SmallVectorImpl<DIE *> &Children) {
|
||||||
DIE *ObjectPointer = NULL;
|
DIE *ObjectPointer = NULL;
|
||||||
@ -569,7 +569,7 @@ DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit *TheCU,
|
|||||||
for (DbgVariable *ArgDV : CurrentFnArguments)
|
for (DbgVariable *ArgDV : CurrentFnArguments)
|
||||||
if (ArgDV)
|
if (ArgDV)
|
||||||
if (DIE *Arg =
|
if (DIE *Arg =
|
||||||
TheCU->constructVariableDIE(*ArgDV, Scope->isAbstractScope())) {
|
TheCU.constructVariableDIE(*ArgDV, Scope->isAbstractScope())) {
|
||||||
Children.push_back(Arg);
|
Children.push_back(Arg);
|
||||||
if (ArgDV->isObjectPointer())
|
if (ArgDV->isObjectPointer())
|
||||||
ObjectPointer = Arg;
|
ObjectPointer = Arg;
|
||||||
@ -587,7 +587,7 @@ DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit *TheCU,
|
|||||||
|
|
||||||
// Collect lexical scope children first.
|
// Collect lexical scope children first.
|
||||||
for (DbgVariable *DV : ScopeVariables.lookup(Scope))
|
for (DbgVariable *DV : ScopeVariables.lookup(Scope))
|
||||||
if (DIE *Variable = TheCU->constructVariableDIE(*DV,
|
if (DIE *Variable = TheCU.constructVariableDIE(*DV,
|
||||||
Scope->isAbstractScope())) {
|
Scope->isAbstractScope())) {
|
||||||
Children.push_back(Variable);
|
Children.push_back(Variable);
|
||||||
if (DV->isObjectPointer())
|
if (DV->isObjectPointer())
|
||||||
@ -600,7 +600,7 @@ DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit *TheCU,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct a DIE for this scope.
|
// Construct a DIE for this scope.
|
||||||
DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit *TheCU,
|
DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit &TheCU,
|
||||||
LexicalScope *Scope) {
|
LexicalScope *Scope) {
|
||||||
if (!Scope || !Scope->getScopeNode())
|
if (!Scope || !Scope->getScopeNode())
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -620,7 +620,7 @@ DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit *TheCU,
|
|||||||
else if (DS.isSubprogram()) {
|
else if (DS.isSubprogram()) {
|
||||||
ProcessedSPNodes.insert(DS);
|
ProcessedSPNodes.insert(DS);
|
||||||
if (Scope->isAbstractScope()) {
|
if (Scope->isAbstractScope()) {
|
||||||
ScopeDIE = TheCU->getDIE(DS);
|
ScopeDIE = TheCU.getDIE(DS);
|
||||||
// Note down abstract DIE.
|
// Note down abstract DIE.
|
||||||
if (ScopeDIE)
|
if (ScopeDIE)
|
||||||
AbstractSPDies.insert(std::make_pair(DS, ScopeDIE));
|
AbstractSPDies.insert(std::make_pair(DS, ScopeDIE));
|
||||||
@ -667,28 +667,30 @@ DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit *TheCU,
|
|||||||
ScopeDIE->addChild(I);
|
ScopeDIE->addChild(I);
|
||||||
|
|
||||||
if (DS.isSubprogram() && ObjectPointer != NULL)
|
if (DS.isSubprogram() && ObjectPointer != NULL)
|
||||||
TheCU->addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, ObjectPointer);
|
TheCU.addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, ObjectPointer);
|
||||||
|
|
||||||
return ScopeDIE;
|
return ScopeDIE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfDebug::addGnuPubAttributes(DwarfUnit *U, DIE *D) const {
|
void DwarfDebug::addGnuPubAttributes(DwarfUnit &U, DIE *D) const {
|
||||||
if (!GenerateGnuPubSections)
|
if (!GenerateGnuPubSections)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
U->addFlag(D, dwarf::DW_AT_GNU_pubnames);
|
U.addFlag(D, dwarf::DW_AT_GNU_pubnames);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new DwarfCompileUnit for the given metadata node with tag
|
// Create new DwarfCompileUnit for the given metadata node with tag
|
||||||
// DW_TAG_compile_unit.
|
// DW_TAG_compile_unit.
|
||||||
DwarfCompileUnit *DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
|
DwarfCompileUnit &DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
|
||||||
StringRef FN = DIUnit.getFilename();
|
StringRef FN = DIUnit.getFilename();
|
||||||
CompilationDir = DIUnit.getDirectory();
|
CompilationDir = DIUnit.getDirectory();
|
||||||
|
|
||||||
DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
|
DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
|
||||||
DwarfCompileUnit *NewCU = new DwarfCompileUnit(
|
auto OwnedUnit = make_unique<DwarfCompileUnit>(
|
||||||
InfoHolder.getUnits().size(), Die, DIUnit, Asm, this, &InfoHolder);
|
InfoHolder.getUnits().size(), Die, DIUnit, Asm, this, &InfoHolder);
|
||||||
InfoHolder.addUnit(NewCU);
|
DwarfCompileUnit &NewCU = *OwnedUnit;
|
||||||
|
InfoHolder.addUnit(std::move(OwnedUnit));
|
||||||
|
|
||||||
|
|
||||||
// LTO with assembly output shares a single line table amongst multiple CUs.
|
// LTO with assembly output shares a single line table amongst multiple CUs.
|
||||||
// To avoid the compilation directory being ambiguous, let the line table
|
// To avoid the compilation directory being ambiguous, let the line table
|
||||||
@ -696,53 +698,53 @@ DwarfCompileUnit *DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
|
|||||||
// compilation directory.
|
// compilation directory.
|
||||||
if (!Asm->OutStreamer.hasRawTextSupport() || SingleCU)
|
if (!Asm->OutStreamer.hasRawTextSupport() || SingleCU)
|
||||||
Asm->OutStreamer.getContext().setMCLineTableCompilationDir(
|
Asm->OutStreamer.getContext().setMCLineTableCompilationDir(
|
||||||
NewCU->getUniqueID(), CompilationDir);
|
NewCU.getUniqueID(), CompilationDir);
|
||||||
|
|
||||||
NewCU->addString(Die, dwarf::DW_AT_producer, DIUnit.getProducer());
|
NewCU.addString(Die, dwarf::DW_AT_producer, DIUnit.getProducer());
|
||||||
NewCU->addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
|
NewCU.addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
|
||||||
DIUnit.getLanguage());
|
DIUnit.getLanguage());
|
||||||
NewCU->addString(Die, dwarf::DW_AT_name, FN);
|
NewCU.addString(Die, dwarf::DW_AT_name, FN);
|
||||||
|
|
||||||
if (!useSplitDwarf()) {
|
if (!useSplitDwarf()) {
|
||||||
NewCU->initStmtList(DwarfLineSectionSym);
|
NewCU.initStmtList(DwarfLineSectionSym);
|
||||||
|
|
||||||
// If we're using split dwarf the compilation dir is going to be in the
|
// If we're using split dwarf the compilation dir is going to be in the
|
||||||
// skeleton CU and so we don't need to duplicate it here.
|
// skeleton CU and so we don't need to duplicate it here.
|
||||||
if (!CompilationDir.empty())
|
if (!CompilationDir.empty())
|
||||||
NewCU->addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
|
NewCU.addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
|
||||||
|
|
||||||
addGnuPubAttributes(NewCU, Die);
|
addGnuPubAttributes(NewCU, Die);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DIUnit.isOptimized())
|
if (DIUnit.isOptimized())
|
||||||
NewCU->addFlag(Die, dwarf::DW_AT_APPLE_optimized);
|
NewCU.addFlag(Die, dwarf::DW_AT_APPLE_optimized);
|
||||||
|
|
||||||
StringRef Flags = DIUnit.getFlags();
|
StringRef Flags = DIUnit.getFlags();
|
||||||
if (!Flags.empty())
|
if (!Flags.empty())
|
||||||
NewCU->addString(Die, dwarf::DW_AT_APPLE_flags, Flags);
|
NewCU.addString(Die, dwarf::DW_AT_APPLE_flags, Flags);
|
||||||
|
|
||||||
if (unsigned RVer = DIUnit.getRunTimeVersion())
|
if (unsigned RVer = DIUnit.getRunTimeVersion())
|
||||||
NewCU->addUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
|
NewCU.addUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
|
||||||
dwarf::DW_FORM_data1, RVer);
|
dwarf::DW_FORM_data1, RVer);
|
||||||
|
|
||||||
if (!FirstCU)
|
if (!FirstCU)
|
||||||
FirstCU = NewCU;
|
FirstCU = &NewCU;
|
||||||
|
|
||||||
if (useSplitDwarf()) {
|
if (useSplitDwarf()) {
|
||||||
NewCU->initSection(Asm->getObjFileLowering().getDwarfInfoDWOSection(),
|
NewCU.initSection(Asm->getObjFileLowering().getDwarfInfoDWOSection(),
|
||||||
DwarfInfoDWOSectionSym);
|
DwarfInfoDWOSectionSym);
|
||||||
NewCU->setSkeleton(constructSkeletonCU(NewCU));
|
NewCU.setSkeleton(constructSkeletonCU(NewCU));
|
||||||
} else
|
} else
|
||||||
NewCU->initSection(Asm->getObjFileLowering().getDwarfInfoSection(),
|
NewCU.initSection(Asm->getObjFileLowering().getDwarfInfoSection(),
|
||||||
DwarfInfoSectionSym);
|
DwarfInfoSectionSym);
|
||||||
|
|
||||||
CUMap.insert(std::make_pair(DIUnit, NewCU));
|
CUMap.insert(std::make_pair(DIUnit, &NewCU));
|
||||||
CUDieMap.insert(std::make_pair(Die, NewCU));
|
CUDieMap.insert(std::make_pair(Die, &NewCU));
|
||||||
return NewCU;
|
return NewCU;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct subprogram DIE.
|
// Construct subprogram DIE.
|
||||||
void DwarfDebug::constructSubprogramDIE(DwarfCompileUnit *TheCU,
|
void DwarfDebug::constructSubprogramDIE(DwarfCompileUnit &TheCU,
|
||||||
const MDNode *N) {
|
const MDNode *N) {
|
||||||
// FIXME: We should only call this routine once, however, during LTO if a
|
// FIXME: We should only call this routine once, however, during LTO if a
|
||||||
// program is defined in multiple CUs we could end up calling it out of
|
// program is defined in multiple CUs we could end up calling it out of
|
||||||
@ -751,7 +753,7 @@ void DwarfDebug::constructSubprogramDIE(DwarfCompileUnit *TheCU,
|
|||||||
DwarfCompileUnit *&CURef = SPMap[N];
|
DwarfCompileUnit *&CURef = SPMap[N];
|
||||||
if (CURef)
|
if (CURef)
|
||||||
return;
|
return;
|
||||||
CURef = TheCU;
|
CURef = &TheCU;
|
||||||
|
|
||||||
DISubprogram SP(N);
|
DISubprogram SP(N);
|
||||||
if (!SP.isDefinition())
|
if (!SP.isDefinition())
|
||||||
@ -759,51 +761,51 @@ void DwarfDebug::constructSubprogramDIE(DwarfCompileUnit *TheCU,
|
|||||||
// class type.
|
// class type.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DIE *SubprogramDie = TheCU->getOrCreateSubprogramDIE(SP);
|
DIE *SubprogramDie = TheCU.getOrCreateSubprogramDIE(SP);
|
||||||
|
|
||||||
// Expose as a global name.
|
// Expose as a global name.
|
||||||
TheCU->addGlobalName(SP.getName(), SubprogramDie, resolve(SP.getContext()));
|
TheCU.addGlobalName(SP.getName(), SubprogramDie, resolve(SP.getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit *TheCU,
|
void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit &TheCU,
|
||||||
const MDNode *N) {
|
const MDNode *N) {
|
||||||
DIImportedEntity Module(N);
|
DIImportedEntity Module(N);
|
||||||
assert(Module.Verify());
|
assert(Module.Verify());
|
||||||
if (DIE *D = TheCU->getOrCreateContextDIE(Module.getContext()))
|
if (DIE *D = TheCU.getOrCreateContextDIE(Module.getContext()))
|
||||||
constructImportedEntityDIE(TheCU, Module, D);
|
constructImportedEntityDIE(TheCU, Module, D);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit *TheCU,
|
void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit &TheCU,
|
||||||
const MDNode *N, DIE *Context) {
|
const MDNode *N, DIE *Context) {
|
||||||
DIImportedEntity Module(N);
|
DIImportedEntity Module(N);
|
||||||
assert(Module.Verify());
|
assert(Module.Verify());
|
||||||
return constructImportedEntityDIE(TheCU, Module, Context);
|
return constructImportedEntityDIE(TheCU, Module, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit *TheCU,
|
void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit &TheCU,
|
||||||
const DIImportedEntity &Module,
|
const DIImportedEntity &Module,
|
||||||
DIE *Context) {
|
DIE *Context) {
|
||||||
assert(Module.Verify() &&
|
assert(Module.Verify() &&
|
||||||
"Use one of the MDNode * overloads to handle invalid metadata");
|
"Use one of the MDNode * overloads to handle invalid metadata");
|
||||||
assert(Context && "Should always have a context for an imported_module");
|
assert(Context && "Should always have a context for an imported_module");
|
||||||
DIE *IMDie = TheCU->createAndAddDIE(Module.getTag(), *Context, Module);
|
DIE *IMDie = TheCU.createAndAddDIE(Module.getTag(), *Context, Module);
|
||||||
DIE *EntityDie;
|
DIE *EntityDie;
|
||||||
DIDescriptor Entity = resolve(Module.getEntity());
|
DIDescriptor Entity = resolve(Module.getEntity());
|
||||||
if (Entity.isNameSpace())
|
if (Entity.isNameSpace())
|
||||||
EntityDie = TheCU->getOrCreateNameSpace(DINameSpace(Entity));
|
EntityDie = TheCU.getOrCreateNameSpace(DINameSpace(Entity));
|
||||||
else if (Entity.isSubprogram())
|
else if (Entity.isSubprogram())
|
||||||
EntityDie = TheCU->getOrCreateSubprogramDIE(DISubprogram(Entity));
|
EntityDie = TheCU.getOrCreateSubprogramDIE(DISubprogram(Entity));
|
||||||
else if (Entity.isType())
|
else if (Entity.isType())
|
||||||
EntityDie = TheCU->getOrCreateTypeDIE(DIType(Entity));
|
EntityDie = TheCU.getOrCreateTypeDIE(DIType(Entity));
|
||||||
else
|
else
|
||||||
EntityDie = TheCU->getDIE(Entity);
|
EntityDie = TheCU.getDIE(Entity);
|
||||||
TheCU->addSourceLine(IMDie, Module.getLineNumber(),
|
TheCU.addSourceLine(IMDie, Module.getLineNumber(),
|
||||||
Module.getContext().getFilename(),
|
Module.getContext().getFilename(),
|
||||||
Module.getContext().getDirectory());
|
Module.getContext().getDirectory());
|
||||||
TheCU->addDIEEntry(IMDie, dwarf::DW_AT_import, EntityDie);
|
TheCU.addDIEEntry(IMDie, dwarf::DW_AT_import, EntityDie);
|
||||||
StringRef Name = Module.getName();
|
StringRef Name = Module.getName();
|
||||||
if (!Name.empty())
|
if (!Name.empty())
|
||||||
TheCU->addString(IMDie, dwarf::DW_AT_name, Name);
|
TheCU.addString(IMDie, dwarf::DW_AT_name, Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit all Dwarf sections that should come prior to the content. Create
|
// Emit all Dwarf sections that should come prior to the content. Create
|
||||||
@ -829,7 +831,7 @@ void DwarfDebug::beginModule() {
|
|||||||
|
|
||||||
for (MDNode *N : CU_Nodes->operands()) {
|
for (MDNode *N : CU_Nodes->operands()) {
|
||||||
DICompileUnit CUNode(N);
|
DICompileUnit CUNode(N);
|
||||||
DwarfCompileUnit *CU = constructDwarfCompileUnit(CUNode);
|
DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
|
||||||
DIArray ImportedEntities = CUNode.getImportedEntities();
|
DIArray ImportedEntities = CUNode.getImportedEntities();
|
||||||
for (unsigned i = 0, e = ImportedEntities.getNumElements(); i != e; ++i)
|
for (unsigned i = 0, e = ImportedEntities.getNumElements(); i != e; ++i)
|
||||||
ScopesWithImportedEntities.push_back(std::make_pair(
|
ScopesWithImportedEntities.push_back(std::make_pair(
|
||||||
@ -839,20 +841,20 @@ void DwarfDebug::beginModule() {
|
|||||||
ScopesWithImportedEntities.end(), less_first());
|
ScopesWithImportedEntities.end(), less_first());
|
||||||
DIArray GVs = CUNode.getGlobalVariables();
|
DIArray GVs = CUNode.getGlobalVariables();
|
||||||
for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i)
|
for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i)
|
||||||
CU->createGlobalVariableDIE(DIGlobalVariable(GVs.getElement(i)));
|
CU.createGlobalVariableDIE(DIGlobalVariable(GVs.getElement(i)));
|
||||||
DIArray SPs = CUNode.getSubprograms();
|
DIArray SPs = CUNode.getSubprograms();
|
||||||
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
|
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
|
||||||
constructSubprogramDIE(CU, SPs.getElement(i));
|
constructSubprogramDIE(CU, SPs.getElement(i));
|
||||||
DIArray EnumTypes = CUNode.getEnumTypes();
|
DIArray EnumTypes = CUNode.getEnumTypes();
|
||||||
for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)
|
for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)
|
||||||
CU->getOrCreateTypeDIE(EnumTypes.getElement(i));
|
CU.getOrCreateTypeDIE(EnumTypes.getElement(i));
|
||||||
DIArray RetainedTypes = CUNode.getRetainedTypes();
|
DIArray RetainedTypes = CUNode.getRetainedTypes();
|
||||||
for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i) {
|
for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i) {
|
||||||
DIType Ty(RetainedTypes.getElement(i));
|
DIType Ty(RetainedTypes.getElement(i));
|
||||||
// The retained types array by design contains pointers to
|
// The retained types array by design contains pointers to
|
||||||
// MDNodes rather than DIRefs. Unique them here.
|
// MDNodes rather than DIRefs. Unique them here.
|
||||||
DIType UniqueTy(resolve(Ty.getRef()));
|
DIType UniqueTy(resolve(Ty.getRef()));
|
||||||
CU->getOrCreateTypeDIE(UniqueTy);
|
CU.getOrCreateTypeDIE(UniqueTy);
|
||||||
}
|
}
|
||||||
// Emit imported_modules last so that the relevant context is already
|
// Emit imported_modules last so that the relevant context is already
|
||||||
// available.
|
// available.
|
||||||
@ -907,7 +909,7 @@ void DwarfDebug::collectDeadVariables() {
|
|||||||
assert(SPCU && "Unable to find Compile Unit!");
|
assert(SPCU && "Unable to find Compile Unit!");
|
||||||
// FIXME: See the comment in constructSubprogramDIE about duplicate
|
// FIXME: See the comment in constructSubprogramDIE about duplicate
|
||||||
// subprogram DIEs.
|
// subprogram DIEs.
|
||||||
constructSubprogramDIE(SPCU, SP);
|
constructSubprogramDIE(*SPCU, SP);
|
||||||
DIE *SPDIE = SPCU->getDIE(SP);
|
DIE *SPDIE = SPCU->getDIE(SP);
|
||||||
for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
|
for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
|
||||||
DIVariable DV(Variables.getElement(vi));
|
DIVariable DV(Variables.getElement(vi));
|
||||||
@ -953,11 +955,11 @@ void DwarfDebug::finalizeModuleInfo() {
|
|||||||
// We don't keep track of which addresses are used in which CU so this
|
// We don't keep track of which addresses are used in which CU so this
|
||||||
// is a bit pessimistic under LTO.
|
// is a bit pessimistic under LTO.
|
||||||
if (!InfoHolder.getAddrPool()->empty())
|
if (!InfoHolder.getAddrPool()->empty())
|
||||||
addSectionLabel(Asm, SkCU, SkCU->getUnitDie(),
|
addSectionLabel(*Asm, *SkCU, SkCU->getUnitDie(),
|
||||||
dwarf::DW_AT_GNU_addr_base, DwarfAddrSectionSym,
|
dwarf::DW_AT_GNU_addr_base, DwarfAddrSectionSym,
|
||||||
DwarfAddrSectionSym);
|
DwarfAddrSectionSym);
|
||||||
if (!TheU->getRangeLists().empty())
|
if (!TheU->getRangeLists().empty())
|
||||||
addSectionLabel(Asm, SkCU, SkCU->getUnitDie(),
|
addSectionLabel(*Asm, *SkCU, SkCU->getUnitDie(),
|
||||||
dwarf::DW_AT_GNU_ranges_base,
|
dwarf::DW_AT_GNU_ranges_base,
|
||||||
DwarfDebugRangeSectionSym, DwarfDebugRangeSectionSym);
|
DwarfDebugRangeSectionSym, DwarfDebugRangeSectionSym);
|
||||||
}
|
}
|
||||||
@ -973,7 +975,7 @@ void DwarfDebug::finalizeModuleInfo() {
|
|||||||
unsigned NumRanges = TheU->getRanges().size();
|
unsigned NumRanges = TheU->getRanges().size();
|
||||||
if (NumRanges) {
|
if (NumRanges) {
|
||||||
if (NumRanges > 1) {
|
if (NumRanges > 1) {
|
||||||
addSectionLabel(Asm, &U, U.getUnitDie(), dwarf::DW_AT_ranges,
|
addSectionLabel(*Asm, U, U.getUnitDie(), dwarf::DW_AT_ranges,
|
||||||
Asm->GetTempSymbol("cu_ranges", U.getUniqueID()),
|
Asm->GetTempSymbol("cu_ranges", U.getUniqueID()),
|
||||||
DwarfDebugRangeSectionSym);
|
DwarfDebugRangeSectionSym);
|
||||||
|
|
||||||
@ -1694,8 +1696,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
|
|||||||
collectVariableInfo(ProcessedVars);
|
collectVariableInfo(ProcessedVars);
|
||||||
|
|
||||||
LexicalScope *FnScope = LScopes.getCurrentFunctionScope();
|
LexicalScope *FnScope = LScopes.getCurrentFunctionScope();
|
||||||
DwarfCompileUnit *TheCU = SPMap.lookup(FnScope->getScopeNode());
|
DwarfCompileUnit &TheCU = *SPMap.lookup(FnScope->getScopeNode());
|
||||||
assert(TheCU && "Unable to find compile unit!");
|
|
||||||
|
|
||||||
// Construct abstract scopes.
|
// Construct abstract scopes.
|
||||||
for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
|
for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
|
||||||
@ -1723,13 +1724,13 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
|
|||||||
|
|
||||||
DIE *CurFnDIE = constructScopeDIE(TheCU, FnScope);
|
DIE *CurFnDIE = constructScopeDIE(TheCU, FnScope);
|
||||||
if (!CurFn->getTarget().Options.DisableFramePointerElim(*CurFn))
|
if (!CurFn->getTarget().Options.DisableFramePointerElim(*CurFn))
|
||||||
TheCU->addFlag(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr);
|
TheCU.addFlag(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr);
|
||||||
|
|
||||||
// Add the range of this function to the list of ranges for the CU.
|
// Add the range of this function to the list of ranges for the CU.
|
||||||
RangeSpan Span(FunctionBeginSym, FunctionEndSym);
|
RangeSpan Span(FunctionBeginSym, FunctionEndSym);
|
||||||
TheCU->addRange(std::move(Span));
|
TheCU.addRange(std::move(Span));
|
||||||
PrevSection = Asm->getCurrentSection();
|
PrevSection = Asm->getCurrentSection();
|
||||||
PrevCU = TheCU;
|
PrevCU = &TheCU;
|
||||||
|
|
||||||
// Clear debug info
|
// Clear debug info
|
||||||
for (auto &I : ScopeVariables)
|
for (auto &I : ScopeVariables)
|
||||||
@ -2649,52 +2650,54 @@ void DwarfDebug::emitDebugRanges() {
|
|||||||
|
|
||||||
// DWARF5 Experimental Separate Dwarf emitters.
|
// DWARF5 Experimental Separate Dwarf emitters.
|
||||||
|
|
||||||
void DwarfDebug::initSkeletonUnit(const DwarfUnit *U, DIE *Die,
|
void DwarfDebug::initSkeletonUnit(const DwarfUnit &U, DIE *Die,
|
||||||
DwarfUnit *NewU) {
|
std::unique_ptr<DwarfUnit> NewU) {
|
||||||
NewU->addLocalString(Die, dwarf::DW_AT_GNU_dwo_name,
|
NewU->addLocalString(Die, dwarf::DW_AT_GNU_dwo_name,
|
||||||
U->getCUNode().getSplitDebugFilename());
|
U.getCUNode().getSplitDebugFilename());
|
||||||
|
|
||||||
if (!CompilationDir.empty())
|
if (!CompilationDir.empty())
|
||||||
NewU->addLocalString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
|
NewU->addLocalString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
|
||||||
|
|
||||||
addGnuPubAttributes(NewU, Die);
|
addGnuPubAttributes(*NewU, Die);
|
||||||
|
|
||||||
SkeletonHolder.addUnit(NewU);
|
SkeletonHolder.addUnit(std::move(NewU));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
|
// This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
|
||||||
// DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
|
// DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
|
||||||
// DW_AT_addr_base, DW_AT_ranges_base.
|
// DW_AT_addr_base, DW_AT_ranges_base.
|
||||||
DwarfCompileUnit *DwarfDebug::constructSkeletonCU(const DwarfCompileUnit *CU) {
|
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(
|
auto OwnedUnit = make_unique<DwarfCompileUnit>(
|
||||||
CU->getUniqueID(), Die, CU->getCUNode(), Asm, this, &SkeletonHolder);
|
CU.getUniqueID(), Die, CU.getCUNode(), Asm, this, &SkeletonHolder);
|
||||||
NewCU->initSection(Asm->getObjFileLowering().getDwarfInfoSection(),
|
DwarfCompileUnit &NewCU = *OwnedUnit;
|
||||||
|
NewCU.initSection(Asm->getObjFileLowering().getDwarfInfoSection(),
|
||||||
DwarfInfoSectionSym);
|
DwarfInfoSectionSym);
|
||||||
|
|
||||||
NewCU->initStmtList(DwarfLineSectionSym);
|
NewCU.initStmtList(DwarfLineSectionSym);
|
||||||
|
|
||||||
initSkeletonUnit(CU, Die, NewCU);
|
initSkeletonUnit(CU, Die, std::move(OwnedUnit));
|
||||||
|
|
||||||
return NewCU;
|
return NewCU;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This DIE has the following attributes: DW_AT_comp_dir, DW_AT_dwo_name,
|
// This DIE has the following attributes: DW_AT_comp_dir, DW_AT_dwo_name,
|
||||||
// DW_AT_addr_base.
|
// DW_AT_addr_base.
|
||||||
DwarfTypeUnit *DwarfDebug::constructSkeletonTU(DwarfTypeUnit *TU) {
|
DwarfTypeUnit &DwarfDebug::constructSkeletonTU(DwarfTypeUnit &TU) {
|
||||||
DwarfCompileUnit &CU = static_cast<DwarfCompileUnit &>(
|
DwarfCompileUnit &CU = static_cast<DwarfCompileUnit &>(
|
||||||
*SkeletonHolder.getUnits()[TU->getCU().getUniqueID()]);
|
*SkeletonHolder.getUnits()[TU.getCU().getUniqueID()]);
|
||||||
|
|
||||||
DIE *Die = new DIE(dwarf::DW_TAG_type_unit);
|
DIE *Die = new DIE(dwarf::DW_TAG_type_unit);
|
||||||
DwarfTypeUnit *NewTU =
|
auto OwnedUnit = make_unique<DwarfTypeUnit>(TU.getUniqueID(), Die, CU, Asm,
|
||||||
new DwarfTypeUnit(TU->getUniqueID(), Die, CU, Asm, this, &SkeletonHolder);
|
this, &SkeletonHolder);
|
||||||
NewTU->setTypeSignature(TU->getTypeSignature());
|
DwarfTypeUnit &NewTU = *OwnedUnit;
|
||||||
NewTU->setType(NULL);
|
NewTU.setTypeSignature(TU.getTypeSignature());
|
||||||
NewTU->initSection(
|
NewTU.setType(NULL);
|
||||||
Asm->getObjFileLowering().getDwarfTypesSection(TU->getTypeSignature()));
|
NewTU.initSection(
|
||||||
|
Asm->getObjFileLowering().getDwarfTypesSection(TU.getTypeSignature()));
|
||||||
|
|
||||||
initSkeletonUnit(TU, Die, NewTU);
|
initSkeletonUnit(TU, Die, std::move(OwnedUnit));
|
||||||
return NewTU;
|
return NewTU;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2757,13 +2760,14 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit);
|
DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit);
|
||||||
DwarfTypeUnit *NewTU =
|
auto OwnedUnit =
|
||||||
new DwarfTypeUnit(InfoHolder.getUnits().size(), UnitDie, CU, Asm, this,
|
make_unique<DwarfTypeUnit>(InfoHolder.getUnits().size(), UnitDie, CU, Asm,
|
||||||
&InfoHolder, getDwoLineTable(CU));
|
this, &InfoHolder, getDwoLineTable(CU));
|
||||||
TU = NewTU;
|
DwarfTypeUnit &NewTU = *OwnedUnit;
|
||||||
InfoHolder.addUnit(NewTU);
|
TU = &NewTU;
|
||||||
|
InfoHolder.addUnit(std::move(OwnedUnit));
|
||||||
|
|
||||||
NewTU->addUInt(UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
|
NewTU.addUInt(UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
|
||||||
CU.getLanguage());
|
CU.getLanguage());
|
||||||
|
|
||||||
MD5 Hash;
|
MD5 Hash;
|
||||||
@ -2774,27 +2778,27 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
|
|||||||
MD5::MD5Result Result;
|
MD5::MD5Result Result;
|
||||||
Hash.final(Result);
|
Hash.final(Result);
|
||||||
uint64_t Signature = *reinterpret_cast<support::ulittle64_t *>(Result + 8);
|
uint64_t Signature = *reinterpret_cast<support::ulittle64_t *>(Result + 8);
|
||||||
NewTU->setTypeSignature(Signature);
|
NewTU.setTypeSignature(Signature);
|
||||||
if (useSplitDwarf())
|
if (useSplitDwarf())
|
||||||
NewTU->setSkeleton(constructSkeletonTU(NewTU));
|
NewTU.setSkeleton(constructSkeletonTU(NewTU));
|
||||||
else
|
else
|
||||||
CU.applyStmtList(*UnitDie);
|
CU.applyStmtList(*UnitDie);
|
||||||
|
|
||||||
NewTU->setType(NewTU->createTypeDIE(CTy));
|
NewTU.setType(NewTU.createTypeDIE(CTy));
|
||||||
|
|
||||||
NewTU->initSection(
|
NewTU.initSection(
|
||||||
useSplitDwarf()
|
useSplitDwarf()
|
||||||
? Asm->getObjFileLowering().getDwarfTypesDWOSection(Signature)
|
? Asm->getObjFileLowering().getDwarfTypesDWOSection(Signature)
|
||||||
: Asm->getObjFileLowering().getDwarfTypesSection(Signature));
|
: Asm->getObjFileLowering().getDwarfTypesSection(Signature));
|
||||||
|
|
||||||
CU.addDIETypeSignature(RefDie, *NewTU);
|
CU.addDIETypeSignature(RefDie, NewTU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfDebug::attachLowHighPC(DwarfCompileUnit *Unit, DIE *D,
|
void DwarfDebug::attachLowHighPC(DwarfCompileUnit &Unit, DIE *D,
|
||||||
MCSymbol *Begin, MCSymbol *End) {
|
MCSymbol *Begin, MCSymbol *End) {
|
||||||
Unit->addLabelAddress(D, dwarf::DW_AT_low_pc, Begin);
|
Unit.addLabelAddress(D, dwarf::DW_AT_low_pc, Begin);
|
||||||
if (DwarfVersion < 4)
|
if (DwarfVersion < 4)
|
||||||
Unit->addLabelAddress(D, dwarf::DW_AT_high_pc, End);
|
Unit.addLabelAddress(D, dwarf::DW_AT_high_pc, End);
|
||||||
else
|
else
|
||||||
Unit->addLabelDelta(D, dwarf::DW_AT_high_pc, End, Begin);
|
Unit.addLabelDelta(D, dwarf::DW_AT_high_pc, End, Begin);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "llvm/MC/MCDwarf.h"
|
#include "llvm/MC/MCDwarf.h"
|
||||||
#include "llvm/Support/Allocator.h"
|
#include "llvm/Support/Allocator.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class AsmPrinter;
|
class AsmPrinter;
|
||||||
@ -184,7 +186,7 @@ public:
|
|||||||
void assignAbbrevNumber(DIEAbbrev &Abbrev);
|
void assignAbbrevNumber(DIEAbbrev &Abbrev);
|
||||||
|
|
||||||
/// \brief Add a unit to the list of CUs.
|
/// \brief Add a unit to the list of CUs.
|
||||||
void addUnit(DwarfUnit *CU);
|
void addUnit(std::unique_ptr<DwarfUnit> U);
|
||||||
|
|
||||||
/// \brief Emit all of the units to the section listed with the given
|
/// \brief Emit all of the units to the section listed with the given
|
||||||
/// abbreviation section.
|
/// abbreviation section.
|
||||||
@ -423,7 +425,7 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
/// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
|
/// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
|
||||||
/// variables in this scope then create and insert DIEs for these
|
/// variables in this scope then create and insert DIEs for these
|
||||||
/// variables.
|
/// variables.
|
||||||
DIE *updateSubprogramScopeDIE(DwarfCompileUnit *SPCU, DISubprogram SP);
|
DIE *updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, DISubprogram SP);
|
||||||
|
|
||||||
/// \brief A helper function to check whether the DIE for a given Scope is
|
/// \brief A helper function to check whether the DIE for a given Scope is
|
||||||
/// going to be null.
|
/// going to be null.
|
||||||
@ -431,21 +433,21 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
|
|
||||||
/// \brief A helper function to construct a RangeSpanList for a given
|
/// \brief A helper function to construct a RangeSpanList for a given
|
||||||
/// lexical scope.
|
/// lexical scope.
|
||||||
void addScopeRangeList(DwarfCompileUnit *TheCU, DIE *ScopeDIE,
|
void addScopeRangeList(DwarfCompileUnit &TheCU, DIE *ScopeDIE,
|
||||||
const SmallVectorImpl<InsnRange> &Range);
|
const SmallVectorImpl<InsnRange> &Range);
|
||||||
|
|
||||||
/// \brief Construct new DW_TAG_lexical_block for this scope and
|
/// \brief Construct new DW_TAG_lexical_block for this scope and
|
||||||
/// attach DW_AT_low_pc/DW_AT_high_pc labels.
|
/// attach DW_AT_low_pc/DW_AT_high_pc labels.
|
||||||
DIE *constructLexicalScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
|
DIE *constructLexicalScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope);
|
||||||
|
|
||||||
/// \brief This scope represents inlined body of a function. Construct
|
/// \brief This scope represents inlined body of a function. Construct
|
||||||
/// DIE to represent this concrete inlined copy of the function.
|
/// DIE to represent this concrete inlined copy of the function.
|
||||||
DIE *constructInlinedScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
|
DIE *constructInlinedScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope);
|
||||||
|
|
||||||
/// \brief Construct a DIE for this scope.
|
/// \brief Construct a DIE for this scope.
|
||||||
DIE *constructScopeDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope);
|
DIE *constructScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope);
|
||||||
/// A helper function to create children of a Scope DIE.
|
/// A helper function to create children of a Scope DIE.
|
||||||
DIE *createScopeChildrenDIE(DwarfCompileUnit *TheCU, LexicalScope *Scope,
|
DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
|
||||||
SmallVectorImpl<DIE *> &Children);
|
SmallVectorImpl<DIE *> &Children);
|
||||||
|
|
||||||
/// \brief Emit initial Dwarf sections with a label at the start of each one.
|
/// \brief Emit initial Dwarf sections with a label at the start of each one.
|
||||||
@ -532,15 +534,16 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
/// DWARF 5 Experimental Split Dwarf Emitters
|
/// DWARF 5 Experimental Split Dwarf Emitters
|
||||||
|
|
||||||
/// \brief Initialize common features of skeleton units.
|
/// \brief Initialize common features of skeleton units.
|
||||||
void initSkeletonUnit(const DwarfUnit *U, DIE *Die, DwarfUnit *NewU);
|
void initSkeletonUnit(const DwarfUnit &U, DIE *Die,
|
||||||
|
std::unique_ptr<DwarfUnit> NewU);
|
||||||
|
|
||||||
/// \brief Construct the split debug info compile unit for the debug info
|
/// \brief Construct the split debug info compile unit for the debug info
|
||||||
/// section.
|
/// section.
|
||||||
DwarfCompileUnit *constructSkeletonCU(const DwarfCompileUnit *CU);
|
DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
|
||||||
|
|
||||||
/// \brief Construct the split debug info compile unit for the debug info
|
/// \brief Construct the split debug info compile unit for the debug info
|
||||||
/// section.
|
/// section.
|
||||||
DwarfTypeUnit *constructSkeletonTU(DwarfTypeUnit *TU);
|
DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU);
|
||||||
|
|
||||||
/// \brief Emit the debug info dwo section.
|
/// \brief Emit the debug info dwo section.
|
||||||
void emitDebugInfoDWO();
|
void emitDebugInfoDWO();
|
||||||
@ -556,24 +559,24 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
|
|
||||||
/// Flags to let the linker know we have emitted new style pubnames. Only
|
/// Flags to let the linker know we have emitted new style pubnames. Only
|
||||||
/// emit it here if we don't have a skeleton CU for split dwarf.
|
/// emit it here if we don't have a skeleton CU for split dwarf.
|
||||||
void addGnuPubAttributes(DwarfUnit *U, DIE *D) const;
|
void addGnuPubAttributes(DwarfUnit &U, DIE *D) const;
|
||||||
|
|
||||||
/// \brief Create new DwarfCompileUnit for the given metadata node with tag
|
/// \brief Create new DwarfCompileUnit for the given metadata node with tag
|
||||||
/// DW_TAG_compile_unit.
|
/// DW_TAG_compile_unit.
|
||||||
DwarfCompileUnit *constructDwarfCompileUnit(DICompileUnit DIUnit);
|
DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit);
|
||||||
|
|
||||||
/// \brief Construct subprogram DIE.
|
/// \brief Construct subprogram DIE.
|
||||||
void constructSubprogramDIE(DwarfCompileUnit *TheCU, const MDNode *N);
|
void constructSubprogramDIE(DwarfCompileUnit &TheCU, const MDNode *N);
|
||||||
|
|
||||||
/// \brief Construct imported_module or imported_declaration DIE.
|
/// \brief Construct imported_module or imported_declaration DIE.
|
||||||
void constructImportedEntityDIE(DwarfCompileUnit *TheCU, const MDNode *N);
|
void constructImportedEntityDIE(DwarfCompileUnit &TheCU, const MDNode *N);
|
||||||
|
|
||||||
/// \brief Construct import_module DIE.
|
/// \brief Construct import_module DIE.
|
||||||
void constructImportedEntityDIE(DwarfCompileUnit *TheCU, const MDNode *N,
|
void constructImportedEntityDIE(DwarfCompileUnit &TheCU, const MDNode *N,
|
||||||
DIE *Context);
|
DIE *Context);
|
||||||
|
|
||||||
/// \brief Construct import_module DIE.
|
/// \brief Construct import_module DIE.
|
||||||
void constructImportedEntityDIE(DwarfCompileUnit *TheCU,
|
void constructImportedEntityDIE(DwarfCompileUnit &TheCU,
|
||||||
const DIImportedEntity &Module, DIE *Context);
|
const DIImportedEntity &Module, DIE *Context);
|
||||||
|
|
||||||
/// \brief Register a source line with debug info. Returns the unique
|
/// \brief Register a source line with debug info. Returns the unique
|
||||||
@ -613,7 +616,7 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
/// \brief Return Label immediately following the instruction.
|
/// \brief Return Label immediately following the instruction.
|
||||||
MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
|
MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
|
||||||
|
|
||||||
void attachLowHighPC(DwarfCompileUnit *Unit, DIE *D, MCSymbol *Begin,
|
void attachLowHighPC(DwarfCompileUnit &Unit, DIE *D, MCSymbol *Begin,
|
||||||
MCSymbol *End);
|
MCSymbol *End);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -163,7 +163,7 @@ public:
|
|||||||
virtual ~DwarfUnit();
|
virtual ~DwarfUnit();
|
||||||
|
|
||||||
/// Set the skeleton unit associated with this unit.
|
/// Set the skeleton unit associated with this unit.
|
||||||
void setSkeleton(DwarfUnit *Skel) { Skeleton = Skel; }
|
void setSkeleton(DwarfUnit &Skel) { Skeleton = &Skel; }
|
||||||
|
|
||||||
/// Get the skeleton unit associated with this unit.
|
/// Get the skeleton unit associated with this unit.
|
||||||
DwarfUnit *getSkeleton() const { return Skeleton; }
|
DwarfUnit *getSkeleton() const { return Skeleton; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user