From: David Blaikie Date: Fri, 25 Apr 2014 18:35:57 +0000 (+0000) Subject: Return DIE by reference instead of pointer from DwarfUnit::getUnitDie X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=5410b5acda1c8a9726d008a46b382eaa83a52443 Return DIE by reference instead of pointer from DwarfUnit::getUnitDie git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207255 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 9b4ffa8e526..a8936bad2be 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -322,7 +322,7 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, // concrete DIE twice. if (DIE *AbsSPDIE = AbstractSPDies.lookup(SP)) { // Pick up abstract subprogram DIE. - SPDie = SPCU.createAndAddDIE(dwarf::DW_TAG_subprogram, *SPCU.getUnitDie()); + SPDie = SPCU.createAndAddDIE(dwarf::DW_TAG_subprogram, SPCU.getUnitDie()); SPCU.addDIEEntry(*SPDie, dwarf::DW_AT_abstract_origin, AbsSPDIE); } else { DISubprogram SPDecl = SP.getFunctionDeclaration(); @@ -345,7 +345,7 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, SPCU.constructSubprogramArguments(*SPDie, Args); DIE *SPDeclDie = SPDie; SPDie = - SPCU.createAndAddDIE(dwarf::DW_TAG_subprogram, *SPCU.getUnitDie()); + SPCU.createAndAddDIE(dwarf::DW_TAG_subprogram, SPCU.getUnitDie()); SPCU.addDIEEntry(*SPDie, dwarf::DW_AT_specification, SPDeclDie); } } @@ -885,27 +885,27 @@ void DwarfDebug::finalizeModuleInfo() { TheU->constructContainingTypeDIEs(); // Add CU specific attributes if we need to add any. - if (TheU->getUnitDie()->getTag() == dwarf::DW_TAG_compile_unit) { + if (TheU->getUnitDie().getTag() == dwarf::DW_TAG_compile_unit) { // If we're splitting the dwarf out now that we've got the entire // CU then add the dwo id to it. DwarfCompileUnit *SkCU = static_cast(TheU->getSkeleton()); if (useSplitDwarf()) { // Emit a unique identifier for this CU. - uint64_t ID = DIEHash(Asm).computeCUSignature(*TheU->getUnitDie()); - TheU->addUInt(*TheU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id, + uint64_t ID = DIEHash(Asm).computeCUSignature(TheU->getUnitDie()); + TheU->addUInt(TheU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id, dwarf::DW_FORM_data8, ID); - SkCU->addUInt(*SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id, + SkCU->addUInt(SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id, dwarf::DW_FORM_data8, ID); // We don't keep track of which addresses are used in which CU so this // is a bit pessimistic under LTO. if (!AddrPool.isEmpty()) - addSectionLabel(*Asm, *SkCU, *SkCU->getUnitDie(), + addSectionLabel(*Asm, *SkCU, SkCU->getUnitDie(), dwarf::DW_AT_GNU_addr_base, DwarfAddrSectionSym, DwarfAddrSectionSym); if (!TheU->getRangeLists().empty()) - addSectionLabel(*Asm, *SkCU, *SkCU->getUnitDie(), + addSectionLabel(*Asm, *SkCU, SkCU->getUnitDie(), dwarf::DW_AT_GNU_ranges_base, DwarfDebugRangeSectionSym, DwarfDebugRangeSectionSym); } @@ -921,7 +921,7 @@ void DwarfDebug::finalizeModuleInfo() { unsigned NumRanges = TheU->getRanges().size(); if (NumRanges) { 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()), DwarfDebugRangeSectionSym); @@ -929,13 +929,13 @@ void DwarfDebug::finalizeModuleInfo() { // 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, + 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, + U.addLocalLabelAddress(U.getUnitDie(), dwarf::DW_AT_low_pc, Range.getStart()); - U.addLabelDelta(*U.getUnitDie(), dwarf::DW_AT_high_pc, Range.getEnd(), + U.addLabelDelta(U.getUnitDie(), dwarf::DW_AT_high_pc, Range.getEnd(), Range.getStart()); } } diff --git a/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/lib/CodeGen/AsmPrinter/DwarfFile.cpp index 06349358ddf..131d7fb8145 100644 --- a/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -75,7 +75,7 @@ void DwarfFile::addUnit(std::unique_ptr U) { // the abbreviations going into ASection. void DwarfFile::emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym) { for (const auto &TheU : CUs) { - DIE *Die = TheU->getUnitDie(); + DIE &Die = TheU->getUnitDie(); const MCSection *USection = TheU->getSection(); Asm->OutStreamer.SwitchSection(USection); @@ -84,11 +84,11 @@ void DwarfFile::emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym) { // Emit size of content not including length itself Asm->OutStreamer.AddComment("Length of Unit"); - Asm->EmitInt32(TheU->getHeaderSize() + Die->getSize()); + Asm->EmitInt32(TheU->getHeaderSize() + Die.getSize()); TheU->emitHeader(ASectionSym); - DD->emitDIE(*Die); + DD->emitDIE(Die); Asm->OutStreamer.EmitLabel(TheU->getLabelEnd()); } } @@ -108,7 +108,7 @@ void DwarfFile::computeSizeAndOffsets() { // EndOffset here is CU-relative, after laying out // all of the CU DIE. - unsigned EndOffset = computeSizeAndOffset(*TheU->getUnitDie(), Offset); + unsigned EndOffset = computeSizeAndOffset(TheU->getUnitDie(), Offset); SecOffset += EndOffset; } } diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index b7bde972aa8..3195126bfae 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -370,9 +370,9 @@ void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute, 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 = getUnitDie(); + DieCU = &getUnitDie(); if (!EntryCU) - EntryCU = getUnitDie(); + EntryCU = &getUnitDie(); Die.addValue(Attribute, EntryCU == DieCU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr, Entry); @@ -944,7 +944,7 @@ void DwarfUnit::addTemplateParams(DIE &Buffer, DIArray TParams) { /// getOrCreateContextDIE - Get context owner's DIE. DIE *DwarfUnit::getOrCreateContextDIE(DIScope Context) { if (!Context || Context.isFile()) - return getUnitDie(); + return &getUnitDie(); if (Context.isType()) return getOrCreateTypeDIE(DIType(Context)); if (Context.isNameSpace()) diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.h b/lib/CodeGen/AsmPrinter/DwarfUnit.h index 7f485fe7399..96ef40d94dd 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -215,7 +215,7 @@ public: unsigned getUniqueID() const { return UniqueID; } uint16_t getLanguage() const { return CUNode.getLanguage(); } DICompileUnit getCUNode() const { return CUNode; } - DIE *getUnitDie() const { return UnitDie.get(); } + DIE &getUnitDie() const { return *UnitDie; } const StringMap &getGlobalNames() const { return GlobalNames; } const StringMap &getGlobalTypes() const { return GlobalTypes; }