From: David Blaikie Date: Sat, 23 Nov 2013 01:17:34 +0000 (+0000) Subject: DwarfDebug: Move ownership of CompileUnits into DwarfUnits X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=a3507d4883b8ec5fd068b28dda7e928f450ba883;p=oota-llvm.git DwarfDebug: Move ownership of CompileUnits into DwarfUnits 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 --- diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index b267a2096d3..90f370ccf71 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -240,6 +240,12 @@ static MCSymbol *emitSectionSym(AsmPrinter *Asm, const MCSection *Section, return TmpSym; } +DwarfUnits::~DwarfUnits() { + for (SmallVectorImpl::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::iterator I = CUMap.begin(), - E = CUMap.end(); - I != E; ++I) - delete I->second; - - for (SmallVectorImpl::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; } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index c5eca73a4b8..db2b92ef7af 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -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 SkeletonCUs; - // Used to uniquely define abbreviations for the skeleton emission. FoldingSet SkeletonAbbrevSet;