[PATCH] D38528: Parallelize tail-merge string table construction.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 01:44:42 PDT 2019


ruiu marked an inline comment as done.
ruiu added inline comments.


================
Comment at: lld/ELF/SyntheticSections.cpp:2276
 
+static uint32_t tailHash(StringRef S) {
+  if (S.size() < 4)
----------------
inglorion wrote:
> What if you did the equivalent of:
> 
>   size_t N = std::min(4, S.size());
>   uint32_t X = 0;
>   memcpy(&X, S.data() + S.size() - N, N);
>   return hash_value(X);
> 
> That would allow you to handle strings of any length and should be super efficient.
> 
> If you need the hash to not depend on the endianness of the host you could use ulittle32_t, but I think in this case you don't need to care what the actual values produced by the hash function are so ignoring endianness seems fine.
After simplifying this function it became too short, so I inlined the function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D38528/new/

https://reviews.llvm.org/D38528





More information about the llvm-commits mailing list