[patch] Merge identical strings

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 27 23:06:33 PST 2016

On Wed, Jan 27, 2016 at 11:07 PM, Rafael EspĂ­ndola
<llvm-commits at lists.llvm.org> wrote:
> The main reason for coding this right now is that as a side effect we
> compute the string table earlier which gives me some flexibility to
> experiment with when we output each section.
> The other reason is that it avoids the need to have reserve and
> addString in sync.
> Every string should be hashed once. The addString method returns the
> offset and we remember that.
> The patch right now always merges strings, but that should be easy to
> change. The method addString could just push them to a std::vector if
> not optimizing. Do you want me to implement that?

I quickly skimmed over this patch and I think it's probably it's the
right thing to do, so, yes, I'd like to see that implemented.

> When linking clang on a Opteron this goes from 1.090608063 to
> 1.135082244 seconds (1.04X slower)
> and strtab goes from 5426172 to 5319595 bytes (1.02X smaller).
> Linking scylladb goes from 8.104377098 to 8.116767958 (1.0015X slower)
> and the strtab goes from 14824893 to 14443221 (1.026X smaller).

The savings are relatively small, but still greater than zero. For a
small increase in cost, at least for scylladb.
For clang the link time increases a little bit more but I still feel
that tolerable. We can always re-evaluate this in the future if it
shows up being a problem.

> Cheers,
> Rafael
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare

More information about the llvm-commits mailing list