@@ -142,6 +142,9 @@ static SmallVector<std::string, 16> TempFiles;
142
142
// / Codegen flags for LTO backend.
143
143
static codegen::RegisterCodeGenFlags CodeGenFlags;
144
144
145
+ // / Static buffer to hold StringRef values.
146
+ static BumpPtrAllocator Alloc;
147
+
145
148
// / Magic section string that marks the existence of offloading data. The
146
149
// / section string will be formatted as `.llvm.offloading.<triple>.<arch>`.
147
150
#define OFFLOAD_SECTION_MAGIC_STR " .llvm.offloading."
@@ -861,8 +864,9 @@ Error linkBitcodeFiles(SmallVectorImpl<std::string> &InputFiles,
861
864
SmallVector<std::unique_ptr<MemoryBuffer>, 4 > SavedBuffers;
862
865
SmallVector<std::unique_ptr<lto::InputFile>, 4 > BitcodeFiles;
863
866
SmallVector<std::string, 4 > NewInputFiles;
864
- StringMap<bool > UsedInRegularObj;
865
- StringMap<bool > UsedInSharedLib;
867
+ DenseSet<StringRef> UsedInRegularObj;
868
+ DenseSet<StringRef> UsedInSharedLib;
869
+ StringSaver Saver (Alloc);
866
870
867
871
// Search for bitcode files in the input and create an LTO input file. If it
868
872
// is not a bitcode file, scan its symbol table for symbols we need to
@@ -888,9 +892,9 @@ Error linkBitcodeFiles(SmallVectorImpl<std::string> &InputFiles,
888
892
889
893
// Record if we've seen these symbols in any object or shared libraries.
890
894
if ((*ObjFile)->isRelocatableObject ())
891
- UsedInRegularObj[ *Name] = true ;
895
+ UsedInRegularObj. insert (Saver. save ( *Name)) ;
892
896
else
893
- UsedInSharedLib[ *Name] = true ;
897
+ UsedInSharedLib. insert (Saver. save ( *Name)) ;
894
898
}
895
899
} else {
896
900
Expected<std::unique_ptr<lto::InputFile>> InputFileOrErr =
@@ -950,14 +954,15 @@ Error linkBitcodeFiles(SmallVectorImpl<std::string> &InputFiles,
950
954
// We will use this as the prevailing symbol definition in LTO unless
951
955
// it is undefined or another definition has already been used.
952
956
Res.Prevailing =
953
- !Sym.isUndefined () && PrevailingSymbols.insert (Sym.getName ()).second ;
957
+ !Sym.isUndefined () &&
958
+ PrevailingSymbols.insert (Saver.save (Sym.getName ())).second ;
954
959
955
960
// We need LTO to preseve the following global symbols:
956
961
// 1) Symbols used in regular objects.
957
962
// 2) Sections that will be given a __start/__stop symbol.
958
- // 3) Prevailing symbols that are needed visibile to external libraries.
963
+ // 3) Prevailing symbols that are needed visible to external libraries.
959
964
Res.VisibleToRegularObj =
960
- UsedInRegularObj[ Sym.getName ()] ||
965
+ UsedInRegularObj. contains ( Sym.getName ()) ||
961
966
isValidCIdentifier (Sym.getSectionName ()) ||
962
967
(Res.Prevailing &&
963
968
(Sym.getVisibility () != GlobalValue::HiddenVisibility &&
@@ -967,7 +972,7 @@ Error linkBitcodeFiles(SmallVectorImpl<std::string> &InputFiles,
967
972
// referenced by other files.
968
973
Res.ExportDynamic =
969
974
Sym.getVisibility () != GlobalValue::HiddenVisibility &&
970
- (UsedInSharedLib[ Sym.getName ()] ||
975
+ (UsedInSharedLib. contains ( Sym.getName ()) ||
971
976
!Sym.canBeOmittedFromSymbolTable ());
972
977
973
978
// The final definition will reside in this linkage unit if the symbol is
0 commit comments