summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-12-15 19:23:49 +0000
committerSam Clegg <sbc@chromium.org>2017-12-15 19:23:49 +0000
commit574d7ce95412c95242a936bcfd54f414449ae365 (patch)
treed241fd99d53c6224e9f055b8302706828ca7192e
parent23c348850f1f8be70a0502bd0a1f0fe76a0fb9f1 (diff)
downloadbcm5719-llvm-574d7ce95412c95242a936bcfd54f414449ae365.tar.gz
bcm5719-llvm-574d7ce95412c95242a936bcfd54f414449ae365.zip
[WebAssembly] Base imports on Symtab. NFC.
Since imports are undefined symbols we know we can find all of them my looking at the symbol table alone. (i.e. imports cannot be have local binding). This will be strictly faster and also allows us to to remove a method from Symbol class Differential Revision: https://reviews.llvm.org/D41304 llvm-svn: 320847
-rw-r--r--lld/wasm/Symbols.h3
-rw-r--r--lld/wasm/Writer.cpp20
2 files changed, 9 insertions, 14 deletions
diff --git a/lld/wasm/Symbols.h b/lld/wasm/Symbols.h
index 744d8a95c6c..8194bcaca38 100644
--- a/lld/wasm/Symbols.h
+++ b/lld/wasm/Symbols.h
@@ -78,9 +78,6 @@ public:
// Only works for globals, not functions.
uint32_t getVirtualAddress() const;
- // Returns true if an output index has been set for this symbol
- bool hasOutputIndex() const { return OutputIndex.hasValue(); }
-
// Set the output index of the symbol (in the function or global index
// space of the output object.
void setOutputIndex(uint32_t Index);
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 4d9d9239adc..82197547523 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -550,18 +550,16 @@ void Writer::calculateOffsets() {
}
void Writer::calculateImports() {
- for (ObjFile *File : Symtab->ObjectFiles) {
- for (Symbol *Sym : File->getSymbols()) {
- if (Sym->hasOutputIndex() || Sym->isDefined() || Sym->isWeak())
- continue;
+ for (Symbol *Sym : Symtab->getSymbols()) {
+ if (Sym->isDefined() || Sym->isWeak())
+ continue;
- if (Sym->isFunction()) {
- Sym->setOutputIndex(FunctionImports.size());
- FunctionImports.push_back(Sym);
- } else {
- Sym->setOutputIndex(GlobalImports.size());
- GlobalImports.push_back(Sym);
- }
+ if (Sym->isFunction()) {
+ Sym->setOutputIndex(FunctionImports.size());
+ FunctionImports.push_back(Sym);
+ } else {
+ Sym->setOutputIndex(GlobalImports.size());
+ GlobalImports.push_back(Sym);
}
}
}
OpenPOWER on IntegriCloud