[PATCH] D52049: [ThinLTOCodeGenerator] Avoid Rehash StringMap in ThreadPool
Daniel Grumberg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 13 16:54:19 PDT 2018
dang added a comment.
In https://reviews.llvm.org/D52049#1233740, @steven_wu wrote:
> I can't find a super clean solution for this. Here is one possible solution, which is to iterate and insert the entry before entering thread pool
>
> Alternatives are:
>
> - Using lookup, which might copy construct std::map
> - Using find, together with some default constructed value.
> - Pre-allocate a larger StringMap, and hope rehash doesn't happen.
>
> Let me know which one is preferred or there are better ones.
Either way, you still have to default construct the missing values once, I looked at StringMap and it won't copy construct the value it uses find underneath (and default constructs if not found) so option 1 and 2 are really the same. I personally prefer using the lookup technique, because there is less "weird" code, but I don't really have a strong opinion. I guess it is a matter of which is cheaper, iterating over the Modules and touching every entry in the maps or taking the cost of constructing a const_iterator when a value is missing. TBH, I doubt it makes a big difference but this needs to be verified, so I am more inclined towards the lookup option.
Repository:
rL LLVM
https://reviews.llvm.org/D52049
More information about the llvm-commits
mailing list