Skip to content

Commit 22c9236

Browse files
authored
IRSymtab: Use StringSet instead of DenseMap for preserved symbols (#149836)
Microbenchmarking shows this is faster
1 parent 314e22b commit 22c9236

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/Object/IRSymtab.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
#include "llvm/Object/IRSymtab.h"
1010
#include "llvm/ADT/ArrayRef.h"
11-
#include "llvm/ADT/DenseMap.h"
1211
#include "llvm/ADT/SmallPtrSet.h"
1312
#include "llvm/ADT/SmallString.h"
1413
#include "llvm/ADT/SmallVector.h"
1514
#include "llvm/ADT/StringRef.h"
15+
#include "llvm/ADT/StringSet.h"
1616
#include "llvm/Bitcode/BitcodeReader.h"
1717
#include "llvm/Config/llvm-config.h"
1818
#include "llvm/IR/Comdat.h"
@@ -213,9 +213,10 @@ Expected<int> Builder::getComdatIndex(const Comdat *C, const Module *M) {
213213
return P.first->second;
214214
}
215215

216-
static DenseSet<StringRef> buildPreservedSymbolsSet(const Triple &TT) {
217-
DenseSet<StringRef> PreservedSymbolSet(std::begin(PreservedSymbols),
218-
std::end(PreservedSymbols));
216+
static StringSet<> buildPreservedSymbolsSet(const Triple &TT) {
217+
StringSet<> PreservedSymbolSet;
218+
PreservedSymbolSet.insert(std::begin(PreservedSymbols),
219+
std::end(PreservedSymbols));
219220
// FIXME: Do we need to pass in ABI fields from TargetOptions?
220221
RTLIB::RuntimeLibcallsInfo Libcalls(TT);
221222
for (RTLIB::LibcallImpl Impl : Libcalls.getLibcallImpls()) {
@@ -280,7 +281,7 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab,
280281

281282
setStr(Sym.IRName, GV->getName());
282283

283-
static const DenseSet<StringRef> PreservedSymbolsSet =
284+
static const StringSet<> PreservedSymbolsSet =
284285
buildPreservedSymbolsSet(GV->getParent()->getTargetTriple());
285286
bool IsPreservedSymbol = PreservedSymbolsSet.contains(GV->getName());
286287

0 commit comments

Comments
 (0)