summaryrefslogtreecommitdiffstats
path: root/lld
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-06-05 07:37:29 +0000
committerRui Ueyama <ruiu@google.com>2014-06-05 07:37:29 +0000
commit733b45f3b05a7e2971656dd0b90fe7ddcd45311f (patch)
tree1ed98f2f1f04abd20ddb3cb85b09a2d47aa70c3c /lld
parent52edc4903136edda614e31bf08c5d5118ba071bf (diff)
downloadbcm5719-llvm-733b45f3b05a7e2971656dd0b90fe7ddcd45311f.tar.gz
bcm5719-llvm-733b45f3b05a7e2971656dd0b90fe7ddcd45311f.zip
Add SymbolTable::isCoalescedAway
isCoalescedAway(x) is faster than replacement(x) != x as the former does not follow the replacement atom chain. Also it's easier to use. llvm-svn: 210242
Diffstat (limited to 'lld')
-rw-r--r--lld/include/lld/Core/SymbolTable.h3
-rw-r--r--lld/lib/Core/Resolver.cpp25
-rw-r--r--lld/lib/Core/SymbolTable.cpp4
3 files changed, 11 insertions, 21 deletions
diff --git a/lld/include/lld/Core/SymbolTable.h b/lld/include/lld/Core/SymbolTable.h
index 73317070cfc..0afbc598587 100644
--- a/lld/include/lld/Core/SymbolTable.h
+++ b/lld/include/lld/Core/SymbolTable.h
@@ -72,6 +72,9 @@ public:
/// @brief if atom has been coalesced away, return replacement, else return atom
const Atom *replacement(const Atom *);
+ /// @brief if atom has been coalesced away, return true
+ bool isCoalescedAway(const Atom *);
+
/// @brief Find a group atom.
const Atom *findGroup(StringRef name);
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index 03e6596893e..95daed99cac 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -29,24 +29,6 @@
namespace lld {
-namespace {
-
-/// This is used as a filter function to std::remove_if to coalesced atoms.
-class AtomCoalescedAway {
-public:
- explicit AtomCoalescedAway(SymbolTable &sym) : _symbolTable(sym) {}
-
- bool operator()(const Atom *atom) const {
- const Atom *rep = _symbolTable.replacement(atom);
- return rep != atom;
- }
-
-private:
- SymbolTable &_symbolTable;
-};
-
-} // namespace
-
void Resolver::handleFile(const File &file) {
bool undefAdded = false;
for (const DefinedAtom *atom : file.defined())
@@ -394,7 +376,7 @@ bool Resolver::checkUndefines() {
continue;
// If the undefine is coalesced away, skip over it.
- if (_symbolTable.replacement(undefAtom) != undefAtom)
+ if (_symbolTable.isCoalescedAway(undefAtom))
continue;
// Seems like this symbol is undefined. Warn that.
@@ -416,8 +398,9 @@ bool Resolver::checkUndefines() {
// remove from _atoms all coaleseced away atoms
void Resolver::removeCoalescedAwayAtoms() {
ScopedTask task(getDefaultDomain(), "removeCoalescedAwayAtoms");
- _atoms.erase(std::remove_if(_atoms.begin(), _atoms.end(),
- AtomCoalescedAway(_symbolTable)),
+ _atoms.erase(std::remove_if(_atoms.begin(), _atoms.end(), [&](const Atom *a) {
+ return _symbolTable.isCoalescedAway(a);
+ }),
_atoms.end());
}
diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp
index ae33fe089c1..b1a1eadbc44 100644
--- a/lld/lib/Core/SymbolTable.cpp
+++ b/lld/lib/Core/SymbolTable.cpp
@@ -381,6 +381,10 @@ const Atom *SymbolTable::replacement(const Atom *atom) {
}
}
+bool SymbolTable::isCoalescedAway(const Atom *atom) {
+ return _replacedAtoms.count(atom) > 0;
+}
+
unsigned int SymbolTable::size() {
return _nameTable.size();
}
OpenPOWER on IntegriCloud