[PATCH] D60765: [ELF] Place SectionPiece::{Live,Hash} bit fields together

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 16 02:37:46 PDT 2019


ruiu added a comment.

This change seems fine as long as it doesn't cause any performance regression. Did you run lld with this change to see if the increase of hash collision doesn't have a negative impact?

I'm trying to add another field to the struct which is likely to conflict with this change.

So, we have 128 bits for this struct. 32 bits are used for the input offset. I want to pack the following bits to the remaining 96 bits.

- 32 bit hash value
- 1 bit for liveness
- 40 bits for the output offset (should be large enough)
- 5 bits for tail-merge shard ID

The sum is 78 bits, so we have enough bits. The problem is that accessing these bitfields are not thread-safe. So, how about defining these fields as follows

  uint32_t Hash;
  uint8_t Live : 1;
  uint8_t TailShardId : 5;
  uint8_t OutputOffHi;
  uint32_t OutputOffLo;

and then provide a few accessor functions, namely `getOutputOff` and `setOutputOff`, to this struct? Then accesses to this class become thread-safe.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D60765





More information about the llvm-commits mailing list