[lld] 5d0be55 - [ELF] Optimize copyLocalSymbols. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 23 00:59:34 PST 2021
Author: Fangrui Song
Date: 2021-12-23T00:59:29-08:00
New Revision: 5d0be553fafefa775518df934916b2703e353599
URL: https://github.com/llvm/llvm-project/commit/5d0be553fafefa775518df934916b2703e353599
DIFF: https://github.com/llvm/llvm-project/commit/5d0be553fafefa775518df934916b2703e353599.diff
LOG: [ELF] Optimize copyLocalSymbols. NFC
Added:
Modified:
lld/ELF/Writer.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 653a2266b531..b593a2950e53 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -674,9 +674,6 @@ static bool shouldKeepInSymtab(const Defined &sym) {
}
static bool includeInSymtab(const Symbol &b) {
- if (!b.isLocal() && !b.isUsedInRegularObj)
- return false;
-
if (auto *d = dyn_cast<Defined>(&b)) {
// Always include absolute symbols.
SectionBase *sec = d->section;
@@ -712,11 +709,8 @@ template <class ELFT> void Writer<ELFT>::copyLocalSymbols() {
// No reason to keep local undefined symbol in symtab.
if (!dr)
continue;
- if (!includeInSymtab(*b))
- continue;
- if (!shouldKeepInSymtab(*dr))
- continue;
- in.symTab->addSymbol(b);
+ if (includeInSymtab(*b) && shouldKeepInSymtab(*dr))
+ in.symTab->addSymbol(b);
}
}
}
@@ -1985,7 +1979,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
// Now that we have defined all possible global symbols including linker-
// synthesized ones. Visit all symbols to give the finishing touches.
for (Symbol *sym : symtab->symbols()) {
- if (!includeInSymtab(*sym))
+ if (!sym->isUsedInRegularObj || !includeInSymtab(*sym))
continue;
if (in.symTab)
in.symTab->addSymbol(sym);
More information about the llvm-commits
mailing list