summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/include/lld/Core/SymbolTable.h20
-rw-r--r--lld/lib/Core/SymbolTable.cpp4
2 files changed, 18 insertions, 6 deletions
diff --git a/lld/include/lld/Core/SymbolTable.h b/lld/include/lld/Core/SymbolTable.h
index 54202b7c87d..9603374c988 100644
--- a/lld/include/lld/Core/SymbolTable.h
+++ b/lld/include/lld/Core/SymbolTable.h
@@ -16,6 +16,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/StringExtras.h"
namespace lld {
@@ -57,16 +58,27 @@ public:
const Atom *replacement(const Atom *);
private:
- typedef std::map<llvm::StringRef, const Atom *> NameToAtom;
- typedef std::map<const Atom *, const Atom *> AtomToAtom;
- struct MyMappingInfo {
+ typedef llvm::DenseMap<const Atom *, const Atom *> AtomToAtom;
+
+ struct StringRefMappingInfo {
+ static llvm::StringRef getEmptyKey() { return llvm::StringRef(); }
+ static llvm::StringRef getTombstoneKey() { return llvm::StringRef(" ", 0); }
+ static unsigned getHashValue(llvm::StringRef const val) {
+ return llvm::HashString(val); }
+ static bool isEqual(llvm::StringRef const lhs,
+ llvm::StringRef const rhs) { return lhs.equals(rhs); }
+ };
+ typedef llvm::DenseMap<llvm::StringRef, const Atom *,
+ StringRefMappingInfo> NameToAtom;
+
+ struct AtomMappingInfo {
static const DefinedAtom * getEmptyKey() { return NULL; }
static const DefinedAtom * getTombstoneKey() { return (DefinedAtom*)(-1); }
static unsigned getHashValue(const DefinedAtom * const Val);
static bool isEqual(const DefinedAtom * const LHS,
const DefinedAtom * const RHS);
};
- typedef llvm::DenseSet<const DefinedAtom*, MyMappingInfo> AtomContentSet;
+ typedef llvm::DenseSet<const DefinedAtom*, AtomMappingInfo> AtomContentSet;
void addByName(const Atom &);
void addByContent(const DefinedAtom &);
diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp
index 1b940cc88ef..cc4c935eb89 100644
--- a/lld/lib/Core/SymbolTable.cpp
+++ b/lld/lib/Core/SymbolTable.cpp
@@ -165,7 +165,7 @@ void SymbolTable::addByName(const Atom & newAtom) {
}
-unsigned SymbolTable::MyMappingInfo::getHashValue(const DefinedAtom * const atom) {
+unsigned SymbolTable::AtomMappingInfo::getHashValue(const DefinedAtom * const atom) {
unsigned hash = atom->size();
if ( atom->contentType() != DefinedAtom::typeZeroFill ) {
llvm::ArrayRef<uint8_t> content = atom->rawContent();
@@ -180,7 +180,7 @@ unsigned SymbolTable::MyMappingInfo::getHashValue(const DefinedAtom * const atom
}
-bool SymbolTable::MyMappingInfo::isEqual(const DefinedAtom * const l,
+bool SymbolTable::AtomMappingInfo::isEqual(const DefinedAtom * const l,
const DefinedAtom * const r) {
if ( l == r )
return true;
OpenPOWER on IntegriCloud