Skip to content

Commit 518df4d

Browse files
benlangmuircachemeifyoucan
authored andcommitted
[llvm][cas] Remove SubtrieHandle's NumUnusedBits
The "unused" bits were always zero, so remove the code around them to make it easier to understand. The size of the header is not changed, because we still want it to be 8 bytes (it is always followed by an 8-byte-aligned value anyway). (cherry picked from commit cad7bdf)
1 parent ee74fc6 commit 518df4d

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

llvm/lib/CAS/OnDiskHashMappedTrie.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ class HashMappedTrieHandle;
324324
/// Subtrie layout:
325325
/// - 2-bytes: StartBit
326326
/// - 1-bytes: NumBits=lg(num-slots)
327-
/// - 1-bytes: NumUnusedBits=lg(num-slots-unused)
328-
/// - 4-bytes: 0-pad
327+
/// - 5-bytes: 0-pad
329328
/// - <slots>
330329
class SubtrieHandle {
331330
public:
@@ -336,11 +335,8 @@ class SubtrieHandle {
336335
/// The number of bits this subtrie handles. It has 2^NumBits slots.
337336
uint8_t NumBits;
338337

339-
/// The number of extra bits this allocation *could* handle, due to
340-
/// over-allocation. It has 2^NumUnusedBits unused slots.
341-
uint8_t NumUnusedBits;
342-
343338
/// 0-pad to 8B.
339+
uint8_t ZeroPad1B;
344340
uint32_t ZeroPad4B;
345341
};
346342

@@ -408,11 +404,9 @@ class SubtrieHandle {
408404
Header &getHeader() const { return *H; }
409405
uint32_t getStartBit() const { return H->StartBit; }
410406
uint32_t getNumBits() const { return H->NumBits; }
411-
uint32_t getNumUnusedBits() const { return H->NumUnusedBits; }
412407

413408
static Expected<SubtrieHandle> create(MappedFileRegionBumpPtr &Alloc,
414-
uint32_t StartBit, uint32_t NumBits,
415-
uint32_t NumUnusedBits = 0);
409+
uint32_t StartBit, uint32_t NumBits);
416410

417411
static SubtrieHandle getFromFileOffset(MappedFileRegion &Region,
418412
FileOffset Offset) {
@@ -558,19 +552,17 @@ struct OnDiskHashMappedTrie::ImplType {
558552

559553
Expected<SubtrieHandle> SubtrieHandle::create(MappedFileRegionBumpPtr &Alloc,
560554
uint32_t StartBit,
561-
uint32_t NumBits,
562-
uint32_t NumUnusedBits) {
555+
uint32_t NumBits) {
563556
assert(StartBit <= HashMappedTrieHandle::MaxNumHashBits);
564557
assert(NumBits <= UINT8_MAX);
565-
assert(NumUnusedBits <= UINT8_MAX);
566-
assert(NumBits + NumUnusedBits <= HashMappedTrieHandle::MaxNumRootBits);
558+
assert(NumBits <= HashMappedTrieHandle::MaxNumRootBits);
567559

568-
auto Mem = Alloc.allocate(getSize(NumBits + NumUnusedBits));
560+
auto Mem = Alloc.allocate(getSize(NumBits));
569561
if (LLVM_UNLIKELY(!Mem))
570562
return Mem.takeError();
571563
auto *H =
572564
new (*Mem) SubtrieHandle::Header{(uint16_t)StartBit, (uint8_t)NumBits,
573-
(uint8_t)NumUnusedBits, /*ZeroPad4B=*/0};
565+
/*ZeroPad1B=*/0, /*ZeroPad4B=*/0};
574566
SubtrieHandle S(Alloc.getRegion(), *H);
575567
for (auto I = S.Slots.begin(), E = S.Slots.end(); I != E; ++I)
576568
new (I) SlotT(0);

0 commit comments

Comments
 (0)