[PATCH] D42176: [WebAssembly] Optimise relocation iteration to remove n^2 loop. NFC.

Nicholas Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 16:31:22 PST 2018


ncw added a comment.

In https://reviews.llvm.org/D42176#1017836, @ruiu wrote:

> Ah, sorry. If that's the case, I misunderstood this patch. But why do you have to explicitly set relocations to chunks? Chunks knows which file they are created from, and Files have pointers to relocations, so Chunks doesn't have to be told what relocations they have, no?


That's all true... the chunks already know the file, and the file already knows the relocations - but the file stores a big list of //all// the relocations (in one array). They are sorted by chunk, but when we write out the (non-discarded) chunks we have to know which relocations go with which chunk.

Alternatives:

- Don't remember the association between chunks and relocs. Do a binary search for every chunk, to find the relocs that are relevant to it. Could make LLD slower.
- Change WasmObjectFile so the reloc list in WasmObjectFile is per-chunk, not per-file; not really any better than this commit, it just pushes the same code into a different class.
- Change the actual Wasm file format, so we store relocs per-chunk on disk, rather than per-file (Sam was suggesting this one actually). Could result in marginally higher memory usage? I'm not too bothered by the current format; relocs in one list sorted by chunk seems a reasonable file format.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D42176





More information about the llvm-commits mailing list