[WebAssembly] Simplify COMDAT handling.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
If I understand the existing code correctly, the new code should do exactly the same as before, with less number of hash table lookups.
In my queue of about ~20 patches still to submit, I have got one similar to this! In fact it was discussed a while back in some comments on another issue; I've just built up a big backlog while the symbol table stuff was being worked on.
It's actually possible to optimise it even more; my patch involves editing the BinaryFormat/Wasm.h structures to go from struct Function { ... StringRef Comdat } to struct Function { int Comdat; }.
Then change the loop to for (Comdat : File->Comdats()) { if (add(Comdat)) markComdatIndex(Comdat); }. Then, you only do a hashtable lookup once per Comdat, rather than (in your case) once per symbol, which should be a bit of a saving for a typical inline function comdat that might have some strings or other data in the comdat as well.
I'm happy for this to go in, it's in the right direction I think.
I think that's a right direction, though that should be done as a separate patch after this.
Your change needs to change llvm/lib/Object/WasmObjectFile.cpp right? One thing I noticed there is that WasmObjectFile::parseLinkingSectionComdat does an expensive test using a set. I don't think that's we want check for name uniqueness in WasmObjectFile.cpp, as it should be a lightweight wrapper to read object files as quickly as possible.
Good point, I can look into getting rid of that at the same time, when I get to submitting that patch.
By the way, I didn't mean to be rude, my last comment might have sounded like "I've done this already and my way's better". I just meant to say what I was working on, for comparison. I think it's great by the way you're working on Wasm-LLD; when Wasm came along was it maybe someone else's idea/initiative? It's good of you to make time in your schedule to work on the Wasm toolchain if you're not using it yourself!