DwarfDebug: Move ownership of CompileUnits into DwarfUnits
authorDavid Blaikie <dblaikie@gmail.com>
Sat, 23 Nov 2013 01:17:34 +0000 (01:17 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sat, 23 Nov 2013 01:17:34 +0000 (01:17 +0000)
This avoids the need for an extra list of SkeletonCUs and associated
cleanup while staging things to be cleaner for further type unit
improvements.

Also hopefully fixes a memory leak introduced in r195166.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195536 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h

index b267a2096d38878ab82be4637853711acb7e731e..90f370ccf7161be63cfdf2899d4cf57d0f138387 100644 (file)
@@ -240,6 +240,12 @@ static MCSymbol *emitSectionSym(AsmPrinter *Asm, const MCSection *Section,
   return TmpSym;
 }
 
+DwarfUnits::~DwarfUnits() {
+  for (SmallVectorImpl<CompileUnit *>::iterator I = CUs.begin(), E = CUs.end();
+       I != E; ++I)
+    delete *I;
+}
+
 MCSymbol *DwarfUnits::getStringPoolSym() {
   return Asm->GetTempSymbol(StringPref);
 }
@@ -1201,15 +1207,6 @@ void DwarfDebug::endModule() {
 
   // clean up.
   SPMap.clear();
-  for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(),
-                                                         E = CUMap.end();
-       I != E; ++I)
-    delete I->second;
-
-  for (SmallVectorImpl<CompileUnit *>::iterator I = SkeletonCUs.begin(),
-                                                E = SkeletonCUs.end();
-       I != E; ++I)
-    delete *I;
 
   // Reset these for the next Module if we have one.
   FirstCU = NULL;
@@ -3021,7 +3018,6 @@ CompileUnit *DwarfDebug::constructSkeletonCU(const CompileUnit *CU) {
   }
 
   SkeletonHolder.addUnit(NewCU);
-  SkeletonCUs.push_back(NewCU);
 
   return NewCU;
 }
index c5eca73a4b86d1cad0695124bdfe432479bcbc66..db2b92ef7af7e0de7592ea3561b53ce4fbfebd3a 100644 (file)
@@ -256,6 +256,8 @@ public:
         NextStringPoolNumber(0), StringPref(Pref), AddressPool(),
         NextAddrPoolNumber(0) {}
 
+  ~DwarfUnits();
+
   /// \brief Compute the size and offset of a DIE given an incoming Offset.
   unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
 
@@ -468,9 +470,6 @@ class DwarfDebug {
   // original object file, rather than things that are meant
   // to be in the .dwo sections.
 
-  // The CUs left in the original object file for separated debug info.
-  SmallVector<CompileUnit *, 1> SkeletonCUs;
-
   // Used to uniquely define abbreviations for the skeleton emission.
   FoldingSet<DIEAbbrev> SkeletonAbbrevSet;