From 1c736322a25d3a6fe4623daab7052e8b9d297223 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 28 Jun 2013 18:47:19 +0000 Subject: [PATCH] DebugInfo: Simplify the AddressPool representation git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185189 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 25 ++++++++++--------------- lib/CodeGen/AsmPrinter/DwarfDebug.h | 5 ++--- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index a6d2b17e3bd..c57cf310e69 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -248,12 +248,10 @@ unsigned DwarfUnits::getStringPoolIndex(StringRef Str) { } unsigned DwarfUnits::getAddrPoolIndex(const MCSymbol *Sym) { - std::pair &Entry = AddressPool[Sym]; - if (Entry.first) return Entry.second; - - Entry.second = NextAddrPoolNumber++; - Entry.first = Sym; - return Entry.second; + std::pair::iterator, bool> P = + AddressPool.insert(std::make_pair(Sym, NextAddrPoolNumber)); + NextAddrPoolNumber += P.second; + return P.first->second; } // Define a unique number for the abbreviation. @@ -2356,23 +2354,20 @@ void DwarfUnits::emitAddresses(const MCSection *AddrSection) { // Start the dwarf addr section. Asm->OutStreamer.SwitchSection(AddrSection); - // Get all of the string pool entries and put them in an array by their ID so + // Get all of the address pool entries and put them in an array by their ID so // we can sort them. - SmallVector *>, 64> - Entries; + SmallVector, 64> Entries; - for (DenseMap >::iterator - I = AddressPool.begin(), - E = AddressPool.end(); + for (DenseMap::iterator I = AddressPool.begin(), + E = AddressPool.end(); I != E; ++I) - Entries.push_back(std::make_pair(I->second.second, &(I->second))); + Entries.push_back(std::make_pair(I->second, I->first)); array_pod_sort(Entries.begin(), Entries.end()); for (unsigned i = 0, e = Entries.size(); i != e; ++i) { // Emit a label for reference from debug information entries. - if (const MCSymbol *Sym = Entries[i].second->first) + if (const MCSymbol *Sym = Entries[i].second) Asm->EmitLabelReference(Sym, Asm->getDataLayout().getPointerSize()); else Asm->OutStreamer.EmitIntValue(0, Asm->getDataLayout().getPointerSize()); diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index 4a395a336d3..00d48d7ecaa 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -195,10 +195,9 @@ public: typedef StringMap, BumpPtrAllocator&> StrPool; -// A Symbol->pair mapping of addresses used by indirect +// A Symbol->unsigned mapping of addresses used by indirect // references. -typedef DenseMap > - AddrPool; +typedef DenseMap AddrPool; /// \brief Collects and handles information specific to a particular /// collection of units. -- 2.11.0