[dsymutil] Identify each CompileUnit with a unique ID.

The ID can eg. de used in MCSymbol names to differentiate the ones
that need to be created for every unit.
The ID is a constructor parameter and not a static class member so
there is no issue with counter updates if we decide to thread that
code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232245 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Frederic Riss 2015-03-14 03:46:40 +00:00
parent fb5115d02a
commit 1d6cc768e5

View File

@ -72,8 +72,8 @@ public:
bool InDebugMap; ///< Was this DIE's entity found in the map?
};
CompileUnit(DWARFUnit &OrigUnit)
: OrigUnit(OrigUnit), LowPc(UINT64_MAX), HighPc(0), RangeAlloc(),
CompileUnit(DWARFUnit &OrigUnit, unsigned ID)
: OrigUnit(OrigUnit), ID(ID), LowPc(UINT64_MAX), HighPc(0), RangeAlloc(),
Ranges(RangeAlloc), UnitRangeAttribute(nullptr) {
Info.resize(OrigUnit.getNumDIEs());
}
@ -89,6 +89,8 @@ public:
DWARFUnit &getOrigUnit() const { return OrigUnit; }
unsigned getUniqueID() const { return ID; }
DIE *getOutputUnitDIE() const { return CUDie.get(); }
void setOutputUnitDIE(DIE *Die) { CUDie.reset(Die); }
@ -133,6 +135,7 @@ public:
private:
DWARFUnit &OrigUnit;
unsigned ID;
std::vector<DIEInfo> Info; ///< DIE info indexed by DIE index.
std::unique_ptr<DIE> CUDie; ///< Root of the linked DIE tree.
@ -1728,7 +1731,8 @@ bool DwarfLinker::link(const DebugMap &Map) {
// Size of the DIEs (and headers) generated for the linked output.
uint64_t OutputDebugInfoSize = 0;
// A unique ID that identifies each compile unit.
unsigned UnitID = 0;
for (const auto &Obj : Map.objects()) {
CurrentDebugObject = Obj.get();
@ -1759,7 +1763,7 @@ bool DwarfLinker::link(const DebugMap &Map) {
outs() << "Input compilation unit:";
CUDie->dump(outs(), CU.get(), 0);
}
Units.emplace_back(*CU);
Units.emplace_back(*CU, UnitID++);
gatherDIEParents(CUDie, 0, Units.back());
}