diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp index 14db7a10f3109..18fc2e4d4a37b 100644 --- a/llvm/lib/Object/IRSymtab.cpp +++ b/llvm/lib/Object/IRSymtab.cpp @@ -215,6 +215,11 @@ Expected Builder::getComdatIndex(const Comdat *C, const Module *M) { return P.first->second; } +static DenseSet buildPreservedSymbolsSet() { + return DenseSet(std::begin(PreservedSymbols), + std::end(PreservedSymbols)); +} + Error Builder::addSymbol(const ModuleSymbolTable &Msymtab, const SmallPtrSet &Used, ModuleSymbolTable::Symbol Msym) { @@ -270,7 +275,9 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab, setStr(Sym.IRName, GV->getName()); - bool IsPreservedSymbol = llvm::is_contained(PreservedSymbols, GV->getName()); + static const DenseSet PreservedSymbolsSet = + buildPreservedSymbolsSet(); + bool IsPreservedSymbol = PreservedSymbolsSet.contains(GV->getName()); if (Used.count(GV) || IsPreservedSymbol) Sym.Flags |= 1 << storage::Symbol::FB_used;