diff options
author | Nick Kledzik <kledzik@apple.com> | 2013-01-15 00:17:57 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2013-01-15 00:17:57 +0000 |
commit | 233f5377999892630b8869a6010638b5d9b6ddc7 (patch) | |
tree | 45e61291693a01d4e4efb033610d7baaf21f0602 /lld/lib/Core/SymbolTable.cpp | |
parent | cb8a9a61f4355578cbc3f45aacfcbb27e30023fc (diff) | |
download | bcm5719-llvm-233f5377999892630b8869a6010638b5d9b6ddc7.tar.gz bcm5719-llvm-233f5377999892630b8869a6010638b5d9b6ddc7.zip |
Add new merge-by-content Merge attribute for use by anonymous
constants and string literals which the linker should coalesce.
llvm-svn: 172495
Diffstat (limited to 'lld/lib/Core/SymbolTable.cpp')
-rw-r--r-- | lld/lib/Core/SymbolTable.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp index b3fe8e8a50e..1c7ea99ff05 100644 --- a/lld/lib/Core/SymbolTable.cpp +++ b/lld/lib/Core/SymbolTable.cpp @@ -46,11 +46,16 @@ void SymbolTable::add(const AbsoluteAtom &atom) { } void SymbolTable::add(const DefinedAtom &atom) { - assert(atom.scope() != DefinedAtom::scopeTranslationUnit); - if ( !atom.name().empty() ) { + if (!atom.name().empty() && + (atom.scope() != DefinedAtom::scopeTranslationUnit)) { + // Named atoms cannot be merged by content. + assert(atom.merge() != DefinedAtom::mergeByContent); + // Track named atoms that are not scoped to file (static). this->addByName(atom); } - else { + else if ( atom.merge() == DefinedAtom::mergeByContent ) { + // Named atoms cannot be merged by content. + assert(atom.name().empty()); this->addByContent(atom); } } @@ -123,6 +128,7 @@ static MergeResolution mergeSelect(DefinedAtom::Merge first, void SymbolTable::addByName(const Atom & newAtom) { StringRef name = newAtom.name(); + assert(!name.empty()); const Atom *existing = this->findByName(name); if (existing == nullptr) { // Name is not in symbol table yet, add it associate with this atom. @@ -283,6 +289,8 @@ bool SymbolTable::AtomMappingInfo::isEqual(const DefinedAtom * const l, } void SymbolTable::addByContent(const DefinedAtom & newAtom) { + // Currently only read-only constants can be merged. + assert(newAtom.permissions() == DefinedAtom::permR__); AtomContentSet::iterator pos = _contentTable.find(&newAtom); if ( pos == _contentTable.end() ) { _contentTable.insert(&newAtom); |