[llvm] r237487 - MC: Change MCAssembler::Symbols to a vector
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri May 15 15:56:01 PDT 2015
Author: dexonsmith
Date: Fri May 15 17:56:01 2015
New Revision: 237487
URL: http://llvm.org/viewvc/llvm-project?rev=237487&view=rev
Log:
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.)
Modified:
llvm/trunk/include/llvm/MC/MCAssembler.h
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=237487&r1=237486&r2=237487&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Fri May 15 17:56:01 2015
@@ -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<MCSymbolData> {
+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<MCSectionData> SectionDataListType;
- typedef iplist<MCSymbolData> SymbolDataListType;
+ typedef std::vector<std::unique_ptr<MCSymbolData>> 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<SymbolDataListType::const_iterator>
+ const_symbol_iterator;
+ typedef pointee_iterator<SymbolDataListType::iterator> symbol_iterator;
typedef iterator_range<symbol_iterator> symbol_range;
typedef iterator_range<const_symbol_iterator> const_symbol_range;
@@ -846,7 +848,7 @@ private:
iplist<MCSectionData> Sections;
- iplist<MCSymbolData> Symbols;
+ SymbolDataListType Symbols;
DenseSet<const MCSymbol *> 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;
More information about the llvm-commits
mailing list