1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Pass DIEs to DwarfUnit constructors by unique_ptr.

llvm-svn: 207447
This commit is contained in:
David Blaikie 2014-04-28 21:04:29 +00:00
parent 1fe9e6bc34
commit 2977225bc4
3 changed files with 45 additions and 42 deletions

View File

@ -652,10 +652,12 @@ 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);
auto OwnedUnit = make_unique<DwarfCompileUnit>( auto OwnedUnit = make_unique<DwarfCompileUnit>(
InfoHolder.getUnits().size(), Die, DIUnit, Asm, this, &InfoHolder); InfoHolder.getUnits().size(),
make_unique<DIE>(dwarf::DW_TAG_compile_unit), DIUnit, Asm, this,
&InfoHolder);
DwarfCompileUnit &NewCU = *OwnedUnit; DwarfCompileUnit &NewCU = *OwnedUnit;
DIE &Die = NewCU.getUnitDie();
InfoHolder.addUnit(std::move(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.
@ -666,10 +668,10 @@ DwarfCompileUnit &DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
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);
@ -677,20 +679,20 @@ DwarfCompileUnit &DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
// 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)
@ -705,7 +707,7 @@ DwarfCompileUnit &DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
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;
} }
@ -2423,16 +2425,16 @@ void DwarfDebug::initSkeletonUnit(const DwarfUnit &U, DIE &Die,
// 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);
auto OwnedUnit = make_unique<DwarfCompileUnit>( auto OwnedUnit = make_unique<DwarfCompileUnit>(
CU.getUniqueID(), Die, CU.getCUNode(), Asm, this, &SkeletonHolder); CU.getUniqueID(), make_unique<DIE>(dwarf::DW_TAG_compile_unit),
CU.getCUNode(), Asm, this, &SkeletonHolder);
DwarfCompileUnit &NewCU = *OwnedUnit; DwarfCompileUnit &NewCU = *OwnedUnit;
NewCU.initSection(Asm->getObjFileLowering().getDwarfInfoSection(), NewCU.initSection(Asm->getObjFileLowering().getDwarfInfoSection(),
DwarfInfoSectionSym); DwarfInfoSectionSym);
NewCU.initStmtList(DwarfLineSectionSym); NewCU.initStmtList(DwarfLineSectionSym);
initSkeletonUnit(CU, *Die, std::move(OwnedUnit)); initSkeletonUnit(CU, NewCU.getUnitDie(), std::move(OwnedUnit));
return NewCU; return NewCU;
} }
@ -2443,8 +2445,8 @@ 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); auto OwnedUnit = make_unique<DwarfTypeUnit>(
auto OwnedUnit = make_unique<DwarfTypeUnit>(TU.getUniqueID(), Die, CU, Asm, TU.getUniqueID(), make_unique<DIE>(dwarf::DW_TAG_type_unit), CU, Asm,
this, &SkeletonHolder); this, &SkeletonHolder);
DwarfTypeUnit &NewTU = *OwnedUnit; DwarfTypeUnit &NewTU = *OwnedUnit;
NewTU.setTypeSignature(TU.getTypeSignature()); NewTU.setTypeSignature(TU.getTypeSignature());
@ -2452,7 +2454,7 @@ DwarfTypeUnit &DwarfDebug::constructSkeletonTU(DwarfTypeUnit &TU) {
NewTU.initSection( NewTU.initSection(
Asm->getObjFileLowering().getDwarfTypesSection(TU.getTypeSignature())); Asm->getObjFileLowering().getDwarfTypesSection(TU.getTypeSignature()));
initSkeletonUnit(TU, *Die, std::move(OwnedUnit)); initSkeletonUnit(TU, NewTU.getUnitDie(), std::move(OwnedUnit));
return NewTU; return NewTU;
} }
@ -2528,23 +2530,23 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
bool TopLevelType = TypeUnitsUnderConstruction.empty(); bool TopLevelType = TypeUnitsUnderConstruction.empty();
AddrPool.resetUsedFlag(); AddrPool.resetUsedFlag();
DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit); auto OwnedUnit = make_unique<DwarfTypeUnit>(
auto OwnedUnit = InfoHolder.getUnits().size(), make_unique<DIE>(dwarf::DW_TAG_type_unit),
make_unique<DwarfTypeUnit>(InfoHolder.getUnits().size(), UnitDie, CU, Asm, CU, Asm, this, &InfoHolder, getDwoLineTable(CU));
this, &InfoHolder, getDwoLineTable(CU));
DwarfTypeUnit &NewTU = *OwnedUnit; DwarfTypeUnit &NewTU = *OwnedUnit;
DIE &UnitDie = NewTU.getUnitDie();
TU = &NewTU; TU = &NewTU;
TypeUnitsUnderConstruction.push_back( TypeUnitsUnderConstruction.push_back(
std::make_pair(std::move(OwnedUnit), CTy)); std::make_pair(std::move(OwnedUnit), CTy));
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());
uint64_t Signature = makeTypeSignature(Identifier); uint64_t Signature = makeTypeSignature(Identifier);
NewTU.setTypeSignature(Signature); NewTU.setTypeSignature(Signature);
if (!useSplitDwarf()) if (!useSplitDwarf())
CU.applyStmtList(*UnitDie); CU.applyStmtList(UnitDie);
NewTU.initSection( NewTU.initSection(
useSplitDwarf() useSplitDwarf()

View File

@ -41,25 +41,26 @@ GenerateDwarfTypeUnits("generate-type-units", cl::Hidden,
cl::init(false)); cl::init(false));
/// Unit - Unit constructor. /// Unit - Unit constructor.
DwarfUnit::DwarfUnit(unsigned UID, DIE *D, DICompileUnit Node, AsmPrinter *A, DwarfUnit::DwarfUnit(unsigned UID, std::unique_ptr<DIE> D, DICompileUnit Node,
DwarfDebug *DW, DwarfFile *DWU) AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU)
: UniqueID(UID), CUNode(Node), UnitDie(D), DebugInfoOffset(0), Asm(A), : UniqueID(UID), CUNode(Node), UnitDie(std::move(D)), DebugInfoOffset(0),
DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr), Asm(A), DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr),
Skeleton(nullptr) { Skeleton(nullptr) {
DIEIntegerOne = new (DIEValueAllocator) DIEInteger(1); DIEIntegerOne = new (DIEValueAllocator) DIEInteger(1);
} }
DwarfCompileUnit::DwarfCompileUnit(unsigned UID, DIE *D, DICompileUnit Node, DwarfCompileUnit::DwarfCompileUnit(unsigned UID, std::unique_ptr<DIE> D,
AsmPrinter *A, DwarfDebug *DW, DICompileUnit Node, AsmPrinter *A,
DwarfFile *DWU) DwarfDebug *DW, DwarfFile *DWU)
: DwarfUnit(UID, D, Node, A, DW, DWU) { : DwarfUnit(UID, std::move(D), Node, A, DW, DWU) {
insertDIE(Node, D); insertDIE(Node, &getUnitDie());
} }
DwarfTypeUnit::DwarfTypeUnit(unsigned UID, DIE *D, DwarfCompileUnit &CU, DwarfTypeUnit::DwarfTypeUnit(unsigned UID, std::unique_ptr<DIE> D,
AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, DwarfCompileUnit &CU, AsmPrinter *A,
DwarfDebug *DW, DwarfFile *DWU,
MCDwarfDwoLineTable *SplitLineTable) MCDwarfDwoLineTable *SplitLineTable)
: DwarfUnit(UID, D, CU.getCUNode(), A, DW, DWU), CU(CU), : DwarfUnit(UID, std::move(D), CU.getCUNode(), A, DW, DWU), CU(CU),
SplitLineTable(SplitLineTable) { SplitLineTable(SplitLineTable) {
if (SplitLineTable) if (SplitLineTable)
addSectionOffset(*UnitDie, dwarf::DW_AT_stmt_list, 0); addSectionOffset(*UnitDie, dwarf::DW_AT_stmt_list, 0);

View File

@ -144,8 +144,8 @@ protected:
/// Skeleton unit associated with this unit. /// Skeleton unit associated with this unit.
DwarfUnit *Skeleton; DwarfUnit *Skeleton;
DwarfUnit(unsigned UID, DIE *D, DICompileUnit CU, AsmPrinter *A, DwarfUnit(unsigned UID, std::unique_ptr<DIE> D, DICompileUnit CU,
DwarfDebug *DW, DwarfFile *DWU); AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU);
public: public:
virtual ~DwarfUnit(); virtual ~DwarfUnit();
@ -533,8 +533,8 @@ class DwarfCompileUnit : public DwarfUnit {
unsigned stmtListIndex; unsigned stmtListIndex;
public: public:
DwarfCompileUnit(unsigned UID, DIE *D, DICompileUnit Node, AsmPrinter *A, DwarfCompileUnit(unsigned UID, std::unique_ptr<DIE> D, DICompileUnit Node,
DwarfDebug *DW, DwarfFile *DWU); AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU);
void initStmtList(MCSymbol *DwarfLineSectionSym); void initStmtList(MCSymbol *DwarfLineSectionSym);
@ -567,8 +567,8 @@ private:
MCDwarfDwoLineTable *SplitLineTable; MCDwarfDwoLineTable *SplitLineTable;
public: public:
DwarfTypeUnit(unsigned UID, DIE *D, DwarfCompileUnit &CU, AsmPrinter *A, DwarfTypeUnit(unsigned UID, std::unique_ptr<DIE> D, DwarfCompileUnit &CU,
DwarfDebug *DW, DwarfFile *DWU, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU,
MCDwarfDwoLineTable *SplitLineTable = nullptr); MCDwarfDwoLineTable *SplitLineTable = nullptr);
void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; } void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }