[lld] r320847 - [WebAssembly] Base imports on Symtab. NFC.

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 11:23:49 PST 2017


Author: sbc
Date: Fri Dec 15 11:23:49 2017
New Revision: 320847

URL: http://llvm.org/viewvc/llvm-project?rev=320847&view=rev
Log:
[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

Modified:
    lld/trunk/wasm/Symbols.h
    lld/trunk/wasm/Writer.cpp

Modified: lld/trunk/wasm/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Symbols.h?rev=320847&r1=320846&r2=320847&view=diff
==============================================================================
--- lld/trunk/wasm/Symbols.h (original)
+++ lld/trunk/wasm/Symbols.h Fri Dec 15 11:23:49 2017
@@ -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);

Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=320847&r1=320846&r2=320847&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Fri Dec 15 11:23:49 2017
@@ -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);
     }
   }
 }




More information about the llvm-commits mailing list