From 113b5688297256c4c8c43733d511dd8493461fa5 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 5 Aug 2022 12:54:29 -0700 Subject: [PATCH] [lld][WebAssembly] Rename SymbolTable::getSymbols to match ELF backend. NFC The ELF backend originally used `getSymbols()` but went though a sequence of changes that resulted in this method being called `symbols()`. d8f8abbd4a2823f223bd7bc56445541fb221b512 replaced `getSymbols()` with `forEachSymbol`. a2fc96441788fba1e4709d63677f34ed8e321dae replaced `forEachSymbol` with `llvm::iterator_range`. e9262edf0d11a907763098d8e101219ccd9c43e9 replaced `llvm::iterator_range` with `symbols()`. Differential Revision: https://reviews.llvm.org/D131284 --- lld/wasm/Driver.cpp | 2 +- lld/wasm/MarkLive.cpp | 2 +- lld/wasm/SymbolTable.cpp | 2 +- lld/wasm/SymbolTable.h | 4 ++-- lld/wasm/SyntheticSections.cpp | 2 +- lld/wasm/Writer.cpp | 8 ++++---- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp index 9972509..2794319 100644 --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -572,7 +572,7 @@ static void handleLibcall(StringRef name) { // Equivalent of demote demoteSharedAndLazySymbols() in the ELF linker static void demoteLazySymbols() { - for (Symbol *sym : symtab->getSymbols()) { + for (Symbol *sym : symtab->symbols()) { if (auto* s = dyn_cast(sym)) { if (s->signature) { LLVM_DEBUG(llvm::dbgs() diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp index 3e5d234e..2b8c8e1 100644 --- a/lld/wasm/MarkLive.cpp +++ b/lld/wasm/MarkLive.cpp @@ -90,7 +90,7 @@ void MarkLive::run() { enqueue(symtab->find(config->entry)); // We need to preserve any no-strip or exported symbol - for (Symbol *sym : symtab->getSymbols()) + for (Symbol *sym : symtab->symbols()) if (sym->isNoStrip() || sym->isExported()) enqueue(sym); diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp index db52931..60cfd83 100644 --- a/lld/wasm/SymbolTable.cpp +++ b/lld/wasm/SymbolTable.cpp @@ -854,7 +854,7 @@ void SymbolTable::replaceWithUndefined(Symbol *sym) { // will abort at runtime, so that relocations can still provided an operand to // the call instruction that passes Wasm validation. void SymbolTable::handleWeakUndefines() { - for (Symbol *sym : getSymbols()) { + for (Symbol *sym : symbols()) { if (sym->isUndefWeak() && sym->isUsedInRegularObj) { if (sym->getSignature()) { replaceWithUndefined(sym); diff --git a/lld/wasm/SymbolTable.h b/lld/wasm/SymbolTable.h index 80e2ace..af90a48 100644 --- a/lld/wasm/SymbolTable.h +++ b/lld/wasm/SymbolTable.h @@ -37,14 +37,14 @@ class InputSegment; // There is one add* function per symbol type. class SymbolTable { public: + ArrayRef symbols() const { return symVector; } + void wrap(Symbol *sym, Symbol *real, Symbol *wrap); void addFile(InputFile *file); void compileBitcodeFiles(); - ArrayRef getSymbols() const { return symVector; } - Symbol *find(StringRef name); void replace(StringRef name, Symbol* sym); diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp index bce7c0b..af940ef 100644 --- a/lld/wasm/SyntheticSections.cpp +++ b/lld/wasm/SyntheticSections.cpp @@ -88,7 +88,7 @@ void DylinkSection::writeBody() { // so that knows not to report an error for such symbols. std::vector importInfo; std::vector exportInfo; - for (const Symbol *sym : symtab->getSymbols()) { + for (const Symbol *sym : symtab->symbols()) { if (sym->isLive()) { if (sym->isExported() && sym->isTLS() && isa(sym)) { exportInfo.push_back(sym); diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp index f98c955..9604f52 100644 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -624,7 +624,7 @@ void Writer::calculateImports() { shouldImport(WasmSym::indirectFunctionTable)) out.importSec->addImport(WasmSym::indirectFunctionTable); - for (Symbol *sym : symtab->getSymbols()) { + for (Symbol *sym : symtab->symbols()) { if (!shouldImport(sym)) continue; if (sym == WasmSym::indirectFunctionTable) @@ -645,7 +645,7 @@ void Writer::calculateExports() { unsigned globalIndex = out.importSec->getNumImportedGlobals() + out.globalSec->numGlobals(); - for (Symbol *sym : symtab->getSymbols()) { + for (Symbol *sym : symtab->symbols()) { if (!sym->isExported()) continue; if (!sym->isLive()) @@ -689,7 +689,7 @@ void Writer::populateSymtab() { if (!config->relocatable && !config->emitRelocs) return; - for (Symbol *sym : symtab->getSymbols()) + for (Symbol *sym : symtab->symbols()) if (sym->isUsedInRegularObj && sym->isLive()) out.linkingSec->addToSymtab(sym); @@ -743,7 +743,7 @@ void Writer::createCommandExportWrappers() { std::vector toWrap; - for (Symbol *sym : symtab->getSymbols()) + for (Symbol *sym : symtab->symbols()) if (sym->isExported()) if (auto *f = dyn_cast(sym)) toWrap.push_back(f); -- 2.7.4