[PATCH] D43391: [WebAssembly] Separate out InputGlobal from InputChunk

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 16 13:54:18 PST 2018


ruiu added a comment.

I can say that handling global variables as Chunks as you did in this patch isn't an intended use of Chunk class, but in order to answer to your question as to what is a better way of abstracting it, I need to experiment various ideas until I find something that fits snugly to the entire design of lld.

The fact that global variables is a "thing" that copied from input files to an output file doesn't mean that that need to be abstracted as Chunks. Everything in the linker, except the one given via the command line, are after all created from input files, and most of them are in some way copied to the output file. Symbols are created for input files and copied to the output symbol table, for example. As I wrote, Chunk essentially represents a contiguous bytes in input files, and I'm not convinced that global variables have that property.

I'd think you are perhaps overthinking about the design. In lld, we are careful not to be too clever. We are trying to keep the class hierarchy simple and shallow, and we are trying to not abstract things too much. And I believe you can find that design principle throughout the lld code.

When we find that something needs to be abstracted in order to make program better, I'm totally fine with doing that. But I don't want to design something too much beforehand, because in many cases that's inappropriate or wouldn't be needed in the future. I'm not worried that the fundamental design of wasm lld is wrong (it's based on the proven design!), so even if we have to refactor code, that's not a big task. So, can we just keep global variables as a symbol until we find that that's not a suitable representation?


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D43391





More information about the llvm-commits mailing list