[PATCH] D41315: [WebAssembly] Output functions individually

Nicholas Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 16 07:00:03 PST 2017


ncw added a comment.

(This is towards https://bugs.llvm.org/show_bug.cgi?id=35534)

It looks like you're still emitting all functions, and the output hasn't actually changed? I haven't read it thoroughly yet, but from the fact that the tests haven't changed I deduce this patch doesn't do any pruning.

The next simple/logical thing to do is to handle weak symbols - when assigning the function indices, check for duplicates. Only functions that actually provide a Symbol should be kept, and the rest discarded (if the Symbol that they would have provided points to a different Function). That's a straightforward and quick check that's probably worth having, even if GC is later used to do even more vigorous pruning of unused code.



================
Comment at: wasm/InputFiles.h:119-120
   Symbol *createDefined(const WasmSymbol &Sym,
-                        const InputSegment *Segment = nullptr);
-  Symbol *createUndefined(const WasmSymbol &Sym);
+                        const InputSegment *Segment = nullptr,
+                        InputFunction *Function = nullptr);
+  Symbol *createUndefined(const WasmSymbol &Sym,
----------------
ruiu wrote:
> What is a relation between Segment and Function? Is Function a type of Segment?
A "segment" is a data segment (a section containing data rather than text). When createDefined is used to make a function symbol, Function will not non-null and Segment null; and vice-versa when it's used for making symbols that refer to global variables, which have an associate segment containing the initial value.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D41315





More information about the llvm-commits mailing list