[llvm] r232245 - [dsymutil] Identify each CompileUnit with a unique ID.

Frederic Riss friss at apple.com
Fri Mar 13 20:46:41 PDT 2015


Author: friss
Date: Fri Mar 13 22:46:40 2015
New Revision: 232245

URL: http://llvm.org/viewvc/llvm-project?rev=232245&view=rev
Log:
[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.

Modified:
    llvm/trunk/tools/dsymutil/DwarfLinker.cpp

Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=232245&r1=232244&r2=232245&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
+++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Fri Mar 13 22:46:40 2015
@@ -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 &M
 
   // 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 &M
         outs() << "Input compilation unit:";
         CUDie->dump(outs(), CU.get(), 0);
       }
-      Units.emplace_back(*CU);
+      Units.emplace_back(*CU, UnitID++);
       gatherDIEParents(CUDie, 0, Units.back());
     }
 





More information about the llvm-commits mailing list