[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 14:15:43 PST 2018


ncw added inline comments.


================
Comment at: wasm/InputFiles.cpp:195
+template<class T>
+static void setRelocs(const std::vector<T *> &Chunks,
+                      const WasmSection *Section) {
----------------
ruiu wrote:
> I read this part of code recently and found the current code does something very weird. It copies relocations for no obvious reason. Instead of copying relocations and attach it to a Chunk, you could directly consume mmap'ed relocation section. So, I think "copy" or "set" relocation should be eliminated, instead of making it efficient.
I agree - in fact, I think that's exactly what I've done! I've renamed the methods from "copy" to "set" because the copy is eliminated - see the std::vector in InputChunk that's been replaced with an ArrayRef that points directly into the WasmObjectFile (OK, so WasmObjectFile does a copy to unserialise the relocations, so it's not quite a direct pointer into the input file... but it's closer).

I think that with this change, there are no longer any copies of relocations in Wasm-LLD. All we're doing here is giving each InputChunk a single pointer to that chunk's relocs in the InputFile's array.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D42176





More information about the llvm-commits mailing list