[lld] 2cd4cd9 - [lld][ELF] Rename SymbolTable::symbols() to SymbolTable::getSymbols(). NFC
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 14:56:19 PDT 2022
Author: Sam Clegg
Date: 2022-08-19T14:56:08-07:00
New Revision: 2cd4cd9a326fd918374ce9330fc3a4e2c642e1b0
URL: https://github.com/llvm/llvm-project/commit/2cd4cd9a326fd918374ce9330fc3a4e2c642e1b0
DIFF: https://github.com/llvm/llvm-project/commit/2cd4cd9a326fd918374ce9330fc3a4e2c642e1b0.diff
LOG: [lld][ELF] Rename SymbolTable::symbols() to SymbolTable::getSymbols(). NFC
This change renames this method match its original name and the name
used in the wasm linker.
Back in d8f8abbd4a2823f223bd7bc56445541fb221b512 the ELF SymbolTable
method `getSymbols()` was replaced with `forEachSymbol`.
Then in a2fc96441788fba1e4709d63677f34ed8e321dae `forEachSymbol` was
replaced with a `llvm::iterator_range`.
Then in e9262edf0d11a907763098d8e101219ccd9c43e9 we came full circle
and the `llvm::iterator_range` was replaced with a `symbols()` accessor
that was identical the original `getSymbols()`.
`getSymbols` also matches the name used elsewhere in the ELF linker as
well as in both COFF and wasm backend (e.g. `InputFiles.h` and
`SyntheticSections.h`)
Differential Revision: https://reviews.llvm.org/D130787
Added:
Modified:
lld/ELF/Driver.cpp
lld/ELF/ICF.cpp
lld/ELF/LTO.cpp
lld/ELF/MarkLive.cpp
lld/ELF/Relocations.cpp
lld/ELF/SymbolTable.h
lld/ELF/Writer.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 2828caa9fdb04..650b3cce24611 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1810,7 +1810,7 @@ static void handleUndefinedGlob(StringRef arg) {
// Calling sym->extract() in the loop is not safe because it may add new
// symbols to the symbol table, invalidating the current iterator.
SmallVector<Symbol *, 0> syms;
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
if (!sym->isPlaceholder() && pat->match(sym->getName()))
syms.push_back(sym);
@@ -1996,7 +1996,7 @@ static void replaceCommonSymbols() {
// --no-allow-shlib-undefined diagnostics. Similarly, demote lazy symbols.
static void demoteSharedAndLazySymbols() {
llvm::TimeTraceScope timeScope("Demote shared and lazy symbols");
- for (Symbol *sym : symtab->symbols()) {
+ for (Symbol *sym : symtab->getSymbols()) {
auto *s = dyn_cast<SharedSymbol>(sym);
if (!(s && !cast<SharedFile>(s->file)->isNeeded) && !sym->isLazy())
continue;
@@ -2043,7 +2043,7 @@ static void findKeepUniqueSections(opt::InputArgList &args) {
// Symbols in the dynsym could be address-significant in other executables
// or DSOs, so we conservatively mark them as address-significant.
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
if (sym->includeInDynsym())
markAddrsig(sym);
@@ -2301,7 +2301,7 @@ static void redirectSymbols(ArrayRef<WrappedSymbol> wrapped) {
// symbols with a non-default version (foo at v1) and check whether it should be
// combined with foo or foo@@v1.
if (config->versionDefinitions.size() > 2)
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
if (sym->hasVersionSuffix)
combineVersionedSymbol(*sym, map);
diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index 9322c75006755..5cd399f4f3161 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -460,7 +460,7 @@ template <class ELFT> void ICF<ELFT>::run() {
// cannot be merged with the later computeIsPreemptible() pass which is used
// by scanRelocations().
if (config->hasDynSymTab)
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
sym->isPreemptible = computeIsPreemptible(*sym);
// Two text sections may have identical content and relocations but
diff erent
@@ -558,7 +558,7 @@ template <class ELFT> void ICF<ELFT>::run() {
d->folded = true;
}
};
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
fold(sym);
parallelForEach(ctx->objectFiles, [&](ELFFileBase *file) {
for (Symbol *sym : file->getLocalSymbols())
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index b8019bd7d2401..7bdeac8da0354 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -211,7 +211,7 @@ BitcodeCompiler::BitcodeCompiler() {
// Initialize usedStartStop.
if (ctx->bitcodeFiles.empty())
return;
- for (Symbol *sym : symtab->symbols()) {
+ for (Symbol *sym : symtab->getSymbols()) {
if (sym->isPlaceholder())
continue;
StringRef s = sym->getName();
diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp
index c72b0409818bd..87946edb3c09f 100644
--- a/lld/ELF/MarkLive.cpp
+++ b/lld/ELF/MarkLive.cpp
@@ -220,7 +220,7 @@ template <class ELFT> void MarkLive<ELFT>::run() {
// Preserve externally-visible symbols if the symbols defined by this
// file can interrupt other ELF file's symbols at runtime.
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
if (sym->includeInDynsym() && sym->partition == partition)
markSymbol(sym);
@@ -361,7 +361,7 @@ template <class ELFT> void elf::markLive() {
// If --gc-sections is not given, retain all input sections.
if (!config->gcSections) {
// If a DSO defines a symbol referenced in a regular object, it is needed.
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
if (auto *s = dyn_cast<SharedSymbol>(sym))
if (s->isUsedInRegularObj && !s->isWeak())
cast<SharedFile>(s->file)->isNeeded = true;
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 5d545270d0359..a8f57996dc65c 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -673,7 +673,7 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
for (auto &it : map)
if (name.equals_insensitive(it.first))
return it.second;
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
if (!sym->isUndefined() && name.equals_insensitive(sym->getName()))
return sym;
@@ -699,7 +699,7 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
break;
}
if (!s)
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
if (canSuggestExternCForCXX(name, sym->getName())) {
s = sym;
break;
@@ -1697,7 +1697,7 @@ void elf::postScanRelocations() {
}
assert(symAux.empty());
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
fn(*sym);
// Local symbols may need the aforementioned non-preemptible ifunc and GOT
diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h
index 142ec7186a53f..77d8ded0b011a 100644
--- a/lld/ELF/SymbolTable.h
+++ b/lld/ELF/SymbolTable.h
@@ -32,7 +32,7 @@ class SharedFile;
// is one add* function per symbol type.
class SymbolTable {
public:
- ArrayRef<Symbol *> symbols() const { return symVector; }
+ ArrayRef<Symbol *> getSymbols() const { return symVector; }
void wrap(Symbol *sym, Symbol *real, Symbol *wrap);
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 9675eb43e88e8..a0c743b56c32b 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1275,7 +1275,7 @@ static DenseMap<const InputSectionBase *, int> buildSectionOrder() {
// We want both global and local symbols. We get the global ones from the
// symbol table and iterate the object files for the local ones.
- for (Symbol *sym : symtab->symbols())
+ for (Symbol *sym : symtab->getSymbols())
addSym(*sym);
for (ELFFileBase *file : ctx->objectFiles)
@@ -1891,7 +1891,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
}
if (config->hasDynSymTab) {
- parallelForEach(symtab->symbols(), [](Symbol *sym) {
+ parallelForEach(symtab->getSymbols(), [](Symbol *sym) {
sym->isPreemptible = computeIsPreemptible(*sym);
});
}
@@ -1963,7 +1963,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
llvm::TimeTraceScope timeScope("Add symbols to symtabs");
// 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()) {
+ for (Symbol *sym : symtab->getSymbols()) {
if (!sym->isUsedInRegularObj || !includeInSymtab(*sym))
continue;
if (!config->relocatable)
More information about the llvm-commits
mailing list