From 6c1612480725d35ed7a6a8de1634b37caf91de35 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 15 May 2015 22:56:01 +0000 Subject: [PATCH] MC: Change MCAssembler::Symbols to a vector Instead of an intrusive double-linked linked list, use a `std::vector<>`. This saves a pointer per symbol and simplifies `MCSymbolData`. Otherwise, no functionality change here. While I measured a memory drop from around 1047MB to 1040MB (0.6%) -- and this is a decent cleanup in its own right -- it's primarily a preparation patch for merging `MCSymbol` and `MCSymbolData`. I'll post an updated patch for that to the list in a moment. (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237487 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAssembler.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index eb7936834f3..d83475d208b 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -17,6 +17,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist_node.h" +#include "llvm/ADT/iterator.h" #include "llvm/MC/MCDirectives.h" #include "llvm/MC/MCFixup.h" #include "llvm/MC/MCInst.h" @@ -657,7 +658,7 @@ public: }; // FIXME: Same concerns as with SectionData. -class MCSymbolData : public ilist_node { +class MCSymbolData { const MCSymbol *Symbol; /// Fragment - The fragment this symbol's value is relative to, if any. Also @@ -798,13 +799,14 @@ class MCAssembler { public: typedef iplist SectionDataListType; - typedef iplist SymbolDataListType; + typedef std::vector> SymbolDataListType; typedef SectionDataListType::const_iterator const_iterator; typedef SectionDataListType::iterator iterator; - typedef SymbolDataListType::const_iterator const_symbol_iterator; - typedef SymbolDataListType::iterator symbol_iterator; + typedef pointee_iterator + const_symbol_iterator; + typedef pointee_iterator symbol_iterator; typedef iterator_range symbol_range; typedef iterator_range const_symbol_range; @@ -846,7 +848,7 @@ private: iplist Sections; - iplist Symbols; + SymbolDataListType Symbols; DenseSet LocalsUsedInReloc; @@ -1181,8 +1183,8 @@ public: if (Created) *Created = !Entry; if (!Entry) { - Entry = new MCSymbolData(Symbol, nullptr, 0); - Symbols.push_back(Entry); + Symbols.emplace_back(new MCSymbolData(Symbol, nullptr, 0)); + Entry = Symbols.back().get(); } return *Entry; -- 2.34.1