[PATCH] D41315: [WebAssembly] Output functions individually

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 16 11:50:23 PST 2017


sbc100 added inline comments.


================
Comment at: wasm/InputFiles.cpp:147
 
 static void CopyRelocationsRange(std::vector<WasmRelocation> &To,
                                  ArrayRef<WasmRelocation> From, size_t Start,
----------------
ruiu wrote:
> This is not a review comment to lld, but why don't you emit one relocation section for each function? IIUC, this code scans an entire relocation section each time you instantiate a function, so that's O(n*m) where n and m are the number of relocations and functions.
You are right we probably can/should do better here.

We tried to design the relocation system such that relocations would apply to the basic primitive of the object format: the wasm section.

However, the only two sections that contain relocations so far are the `code` and `data` sections, and we are not trying to split these up into GC'able chunks (a single `segment` for data and a single `function` for code).    Going back to revist the relocations in the object file it would probably make a lot more sense at this point to one relocation section per function and per data segments.  i.e. reloc.CODE.1 .. reloc.CODE.n rather than simply `reloc.CODE`.   I've opened bug in our tool-conventions repo to discuss changing this: https://github.com/WebAssembly/tool-conventions/issues/32


================
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,
----------------
ncw wrote:
> 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.
In the wasm format the CODE section is made up of a sequence of functions (essentially blobs of wasm code).  Whereas the DATA section is made up of a sequence of data segments.   We could try to treat these to equally in the abstraction here, but unlike ELF they are represented in the same way.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D41315





More information about the llvm-commits mailing list