mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-03 08:51:43 +00:00
Use std::unique_ptr to handle ownership of DwarfUnits in DwarfFile.
So Chandler - how about those range algorithms? (would really love a dereferencing range adapter for this sort of stuff) llvm-svn: 206921
This commit is contained in:
parent
2962a8cf09
commit
ef0c701473
@ -225,9 +225,9 @@ static MCSymbol *emitSectionSym(AsmPrinter *Asm, const MCSection *Section,
|
||||
return TmpSym;
|
||||
}
|
||||
|
||||
DwarfFile::DwarfFile(AsmPrinter *AP, const char *Pref, BumpPtrAllocator &DA)
|
||||
: Asm(AP), StringPool(DA), NextStringPoolNumber(0), StringPref(Pref) {}
|
||||
DwarfFile::~DwarfFile() {
|
||||
for (DwarfUnit *DU : CUs)
|
||||
delete DU;
|
||||
}
|
||||
|
||||
MCSymbol *DwarfFile::getStringPoolSym() {
|
||||
@ -280,6 +280,10 @@ void DwarfFile::assignAbbrevNumber(DIEAbbrev &Abbrev) {
|
||||
}
|
||||
}
|
||||
|
||||
void DwarfFile::addUnit(DwarfUnit *CU) {
|
||||
CUs.push_back(std::unique_ptr<DwarfUnit>(CU));
|
||||
}
|
||||
|
||||
static bool isObjCClass(StringRef Name) {
|
||||
return Name.startswith("+") || Name.startswith("-");
|
||||
}
|
||||
@ -927,7 +931,7 @@ void DwarfDebug::finalizeModuleInfo() {
|
||||
|
||||
// Handle anything that needs to be done on a per-unit basis after
|
||||
// all other generation.
|
||||
for (DwarfUnit *TheU : getUnits()) {
|
||||
for (const auto &TheU : getUnits()) {
|
||||
// Emit DW_AT_containing_type attribute to connect types with their
|
||||
// vtable holding type.
|
||||
TheU->constructContainingTypeDIEs();
|
||||
@ -964,26 +968,27 @@ void DwarfDebug::finalizeModuleInfo() {
|
||||
// FIXME: We should use ranges allow reordering of code ala
|
||||
// .subsections_via_symbols in mach-o. This would mean turning on
|
||||
// ranges for all subprogram DIEs for mach-o.
|
||||
DwarfCompileUnit *U = SkCU ? SkCU : static_cast<DwarfCompileUnit *>(TheU);
|
||||
DwarfCompileUnit &U =
|
||||
SkCU ? *SkCU : static_cast<DwarfCompileUnit &>(*TheU);
|
||||
unsigned NumRanges = TheU->getRanges().size();
|
||||
if (NumRanges) {
|
||||
if (NumRanges > 1) {
|
||||
addSectionLabel(Asm, U, U->getUnitDie(), dwarf::DW_AT_ranges,
|
||||
Asm->GetTempSymbol("cu_ranges", U->getUniqueID()),
|
||||
addSectionLabel(Asm, &U, U.getUnitDie(), dwarf::DW_AT_ranges,
|
||||
Asm->GetTempSymbol("cu_ranges", U.getUniqueID()),
|
||||
DwarfDebugRangeSectionSym);
|
||||
|
||||
// A DW_AT_low_pc attribute may also be specified in combination with
|
||||
// DW_AT_ranges to specify the default base address for use in
|
||||
// location lists (see Section 2.6.2) and range lists (see Section
|
||||
// 2.17.3).
|
||||
U->addUInt(U->getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
|
||||
0);
|
||||
U.addUInt(U.getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
|
||||
0);
|
||||
} else {
|
||||
RangeSpan &Range = TheU->getRanges().back();
|
||||
U->addLocalLabelAddress(U->getUnitDie(), dwarf::DW_AT_low_pc,
|
||||
Range.getStart());
|
||||
U->addLabelDelta(U->getUnitDie(), dwarf::DW_AT_high_pc,
|
||||
Range.getEnd(), Range.getStart());
|
||||
U.addLocalLabelAddress(U.getUnitDie(), dwarf::DW_AT_low_pc,
|
||||
Range.getStart());
|
||||
U.addLabelDelta(U.getUnitDie(), dwarf::DW_AT_high_pc, Range.getEnd(),
|
||||
Range.getStart());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1776,8 +1781,8 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S,
|
||||
llvm_unreachable("Unexpected scope info");
|
||||
|
||||
unsigned CUID = Asm->OutStreamer.getContext().getDwarfCompileUnitID();
|
||||
Src = static_cast<DwarfCompileUnit *>(InfoHolder.getUnits()[CUID])
|
||||
->getOrCreateSourceID(Fn, Dir);
|
||||
Src = static_cast<DwarfCompileUnit &>(*InfoHolder.getUnits()[CUID])
|
||||
.getOrCreateSourceID(Fn, Dir);
|
||||
}
|
||||
Asm->OutStreamer.EmitDwarfLocDirective(Src, Line, Col, Flags, 0,
|
||||
Discriminator, Fn);
|
||||
@ -1835,7 +1840,7 @@ void DwarfFile::computeSizeAndOffsets() {
|
||||
|
||||
// Iterate over each compile unit and set the size and offsets for each
|
||||
// DIE within each compile unit. All offsets are CU relative.
|
||||
for (DwarfUnit *TheU : CUs) {
|
||||
for (const auto &TheU : CUs) {
|
||||
TheU->setDebugInfoOffset(SecOffset);
|
||||
|
||||
// CU-relative offset is reset to 0 here.
|
||||
@ -1941,7 +1946,7 @@ void DwarfDebug::emitDIE(DIE &Die) {
|
||||
// Emit the various dwarf units to the unit section USection with
|
||||
// the abbreviations going into ASection.
|
||||
void DwarfFile::emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym) {
|
||||
for (DwarfUnit *TheU : CUs) {
|
||||
for (const auto &TheU : CUs) {
|
||||
DIE *Die = TheU->getUnitDie();
|
||||
const MCSection *USection = TheU->getSection();
|
||||
Asm->OutStreamer.SwitchSection(USection);
|
||||
@ -2022,7 +2027,7 @@ void DwarfDebug::emitEndOfLineMatrix(unsigned SectionEnd) {
|
||||
void DwarfDebug::emitAccelNames() {
|
||||
DwarfAccelTable AT(
|
||||
DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4));
|
||||
for (DwarfUnit *TheU : getUnits()) {
|
||||
for (const auto &TheU : getUnits()) {
|
||||
for (const auto &GI : TheU->getAccelNames()) {
|
||||
StringRef Name = GI.getKey();
|
||||
for (const DIE *D : GI.second)
|
||||
@ -2045,7 +2050,7 @@ void DwarfDebug::emitAccelNames() {
|
||||
void DwarfDebug::emitAccelObjC() {
|
||||
DwarfAccelTable AT(
|
||||
DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4));
|
||||
for (DwarfUnit *TheU : getUnits()) {
|
||||
for (const auto &TheU : getUnits()) {
|
||||
for (const auto &GI : TheU->getAccelObjC()) {
|
||||
StringRef Name = GI.getKey();
|
||||
for (const DIE *D : GI.second)
|
||||
@ -2067,7 +2072,7 @@ void DwarfDebug::emitAccelObjC() {
|
||||
void DwarfDebug::emitAccelNamespaces() {
|
||||
DwarfAccelTable AT(
|
||||
DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4));
|
||||
for (DwarfUnit *TheU : getUnits()) {
|
||||
for (const auto &TheU : getUnits()) {
|
||||
for (const auto &GI : TheU->getAccelNamespace()) {
|
||||
StringRef Name = GI.getKey();
|
||||
for (const DIE *D : GI.second)
|
||||
@ -2095,7 +2100,7 @@ void DwarfDebug::emitAccelTypes() {
|
||||
Atoms.push_back(
|
||||
DwarfAccelTable::Atom(dwarf::DW_ATOM_type_flags, dwarf::DW_FORM_data1));
|
||||
DwarfAccelTable AT(Atoms);
|
||||
for (DwarfUnit *TheU : getUnits()) {
|
||||
for (const auto &TheU : getUnits()) {
|
||||
for (const auto &GI : TheU->getAccelTypes()) {
|
||||
StringRef Name = GI.getKey();
|
||||
for (const auto &DI : GI.second)
|
||||
|
@ -145,7 +145,7 @@ class DwarfFile {
|
||||
std::vector<DIEAbbrev *> Abbreviations;
|
||||
|
||||
// A pointer to all units in the section.
|
||||
SmallVector<DwarfUnit *, 1> CUs;
|
||||
SmallVector<std::unique_ptr<DwarfUnit>, 1> CUs;
|
||||
|
||||
// Collection of strings for this unit and assorted symbols.
|
||||
// A String->Symbol mapping of strings used by indirect
|
||||
@ -168,12 +168,11 @@ class DwarfFile {
|
||||
AddrPool AddressPool;
|
||||
|
||||
public:
|
||||
DwarfFile(AsmPrinter *AP, const char *Pref, BumpPtrAllocator &DA)
|
||||
: Asm(AP), StringPool(DA), NextStringPoolNumber(0), StringPref(Pref) {}
|
||||
DwarfFile(AsmPrinter *AP, const char *Pref, BumpPtrAllocator &DA);
|
||||
|
||||
~DwarfFile();
|
||||
|
||||
const SmallVectorImpl<DwarfUnit *> &getUnits() { return CUs; }
|
||||
const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { return CUs; }
|
||||
|
||||
/// \brief Compute the size and offset of a DIE given an incoming Offset.
|
||||
unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
|
||||
@ -185,7 +184,7 @@ public:
|
||||
void assignAbbrevNumber(DIEAbbrev &Abbrev);
|
||||
|
||||
/// \brief Add a unit to the list of CUs.
|
||||
void addUnit(DwarfUnit *CU) { CUs.push_back(CU); }
|
||||
void addUnit(DwarfUnit *CU);
|
||||
|
||||
/// \brief Emit all of the units to the section listed with the given
|
||||
/// abbreviation section.
|
||||
@ -413,7 +412,7 @@ class DwarfDebug : public AsmPrinterHandler {
|
||||
|
||||
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
|
||||
|
||||
const SmallVectorImpl<DwarfUnit *> &getUnits() {
|
||||
const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
|
||||
return InfoHolder.getUnits();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user