[PATCH] D41304: [WebAssembly] Base imports on Symtab. NFC.

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 11:21:54 PST 2017


sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff, jfb.

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


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D41304

Files:
  wasm/Symbols.h
  wasm/Writer.cpp


Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -550,18 +550,16 @@
 }
 
 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);
     }
   }
 }
Index: wasm/Symbols.h
===================================================================
--- wasm/Symbols.h
+++ wasm/Symbols.h
@@ -78,9 +78,6 @@
   // 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41304.127164.patch
Type: text/x-patch
Size: 1480 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171215/a04d7818/attachment.bin>


More information about the llvm-commits mailing list