[PATCH] D25698: Update lld to use new LTO comdat api
Rafael Ávila de Espíndola via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 14:08:23 PDT 2016
rafael created this revision.
rafael added reviewers: mehdi_amini, pcc, davide.
rafael added a subscriber: llvm-commits.
https://reviews.llvm.org/D25698
Files:
ELF/InputFiles.cpp
Index: ELF/InputFiles.cpp
===================================================================
--- ELF/InputFiles.cpp
+++ ELF/InputFiles.cpp
@@ -693,8 +693,7 @@
}
template <class ELFT>
-static Symbol *createBitcodeSymbol(DenseSet<StringRef> &KeptComdats,
- DenseSet<StringRef> &ComdatGroups,
+static Symbol *createBitcodeSymbol(const std::vector<bool> &KeptComdats,
const lto::InputFile::Symbol &ObjSym,
StringSaver &Saver, BitcodeFile *F) {
StringRef NameRef = Saver.save(ObjSym.getName());
@@ -705,20 +704,10 @@
uint8_t Visibility = mapVisibility(ObjSym.getVisibility());
bool CanOmitFromDynSym = ObjSym.canBeOmittedFromSymbolTable();
- StringRef C = check(ObjSym.getComdat());
- 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);
-}
+ int C = check(ObjSym.getComdat());
+ if (C != -1 && !KeptComdats[C])
+ 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,
@@ -747,10 +736,16 @@
Obj = check(lto::InputFile::create(MemoryBufferRef(
MB.getBuffer(), Saver.save(ArchiveName + MB.getBufferIdentifier() +
utostr(OffsetInArchive)))));
- DenseSet<StringRef> KeptComdats;
+
+ std::vector<bool> KeptComdats;
+ for (StringRef S : Obj->getComdats()) {
+ StringRef N = Saver.save(S);
+ KeptComdats.push_back(ComdatGroups.insert(N).second);
+ }
+
for (const lto::InputFile::Symbol &ObjSym : Obj->symbols())
- Symbols.push_back(createBitcodeSymbol<ELFT>(KeptComdats, ComdatGroups,
- ObjSym, Saver, this));
+ Symbols.push_back(
+ createBitcodeSymbol<ELFT>(KeptComdats, ObjSym, Saver, this));
}
template <template <class> class T>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25698.74901.patch
Type: text/x-patch
Size: 2314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161017/d0eed5a5/attachment.bin>
More information about the llvm-commits
mailing list