[PATCH] D45571: [ELF] - Speedup MergeInputSection::splitStrings

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 26 19:19:30 PDT 2018


espindola added inline comments.


================
Comment at: ELF/InputSection.cpp:877
+  // calculate the string hash here.
+  while (reinterpret_cast<uintptr_t>(Data) & (sizeof(uint32_t) - 1)) {
+    if (!DataSize-- || !*Data)
----------------
I think I just realized a problem with this.  If you have a string that is more than 4 bytes long, its hash value depends on its address, no? For example, if the string foobarzed starts at a position 4 byte aligned, we will hash it as

foob arzed \0

but if it is offset by one byte, it will be hashed as

f ooba zed\0

You can probably just delete the initial alignment loop. This will produce slow code on cpus that don't support fast unaligned loads, but we are already very slow in those cases.



https://reviews.llvm.org/D45571





More information about the llvm-commits mailing list