[lld] r284413 - Avoid using getComdatSymbolTable.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 12:25:08 PDT 2016
Author: rafael
Date: Mon Oct 17 14:25:08 2016
New Revision: 284413
URL: http://llvm.org/viewvc/llvm-project?rev=284413&view=rev
Log:
Avoid using getComdatSymbolTable.
This is not particularly efficient, but does avoid exposing Comdat*
out of LTO.h.
I will send a patch for review with a more efficient interface that
should map nicely to a bitcode symbol table.
Modified:
lld/trunk/ELF/InputFiles.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=284413&r1=284412&r2=284413&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Mon Oct 17 14:25:08 2016
@@ -693,7 +693,8 @@ static uint8_t mapVisibility(GlobalValue
}
template <class ELFT>
-static Symbol *createBitcodeSymbol(const DenseSet<StringRef> &KeptComdats,
+static Symbol *createBitcodeSymbol(DenseSet<StringRef> &KeptComdats,
+ DenseSet<StringRef> &ComdatGroups,
const lto::InputFile::Symbol &ObjSym,
StringSaver &Saver, BitcodeFile *F) {
StringRef NameRef = Saver.save(ObjSym.getName());
@@ -705,9 +706,19 @@ static Symbol *createBitcodeSymbol(const
bool CanOmitFromDynSym = ObjSym.canBeOmittedFromSymbolTable();
StringRef C = check(ObjSym.getComdat());
- if (!C.empty() && !KeptComdats.count(C))
- return Symtab<ELFT>::X->addUndefined(NameRef, Binding, Visibility, Type,
- CanOmitFromDynSym, F);
+ if (!C.empty()) {
+ bool Keep = KeptComdats.count(C);
+ if (!Keep) {
+ StringRef N = Saver.save(C);
+ if (ComdatGroups.insert(N).second) {
+ Keep = true;
+ KeptComdats.insert(C);
+ }
+ }
+ if (!Keep)
+ return Symtab<ELFT>::X->addUndefined(NameRef, Binding, Visibility, Type,
+ CanOmitFromDynSym, F);
+}
if (Flags & BasicSymbolRef::SF_Undefined)
return Symtab<ELFT>::X->addUndefined(NameRef, Binding, Visibility, Type,
@@ -737,15 +748,9 @@ void BitcodeFile::parse(DenseSet<StringR
MB.getBuffer(), Saver.save(ArchiveName + MB.getBufferIdentifier() +
utostr(OffsetInArchive)))));
DenseSet<StringRef> KeptComdats;
- for (const auto &P : Obj->getComdatSymbolTable()) {
- StringRef N = Saver.save(P.first());
- if (ComdatGroups.insert(N).second)
- KeptComdats.insert(N);
- }
-
for (const lto::InputFile::Symbol &ObjSym : Obj->symbols())
- Symbols.push_back(
- createBitcodeSymbol<ELFT>(KeptComdats, ObjSym, Saver, this));
+ Symbols.push_back(createBitcodeSymbol<ELFT>(KeptComdats, ComdatGroups,
+ ObjSym, Saver, this));
}
template <template <class> class T>
More information about the llvm-commits
mailing list