Dropped lfsr_mptr_t as a struct

This replaces the lfsr_mptr_t struct with simple arrays.

The main motivation for this is C99's strict aliasing. It saves a
decent amount of stack to reference the mdir's internal block array as
an mptr directly, but we were only able to accomplish this in
lfsr_mdir_mptr by violating C99's strict aliasing rules.

The main downside of this is C's wonderful array-to-pointer decay
resulting in more implicit references and chances for things to get
clobbered (the original motivation for lfsr_mptr_t was due to bugs
introduced this way).

If I know one thing about C99's strict aliasing it's that it sure loves
to make code less safe.

No significant code changes, which is probably a good thing:

                     code          stack
  default before:   36436           2672
  default after:    36432 (-0.0%)   2672 (+0.0%)

  ckfetches before: 36674           2704
  ckfetches after:  36666 (-0.0%)   2704 (+0.0%)
This commit is contained in:
Christopher Haster
2024-08-14 16:00:37 -05:00
parent 770578d221
commit 2cefcbdddc
4 changed files with 69 additions and 73 deletions
+2 -6
View File
@@ -536,10 +536,6 @@ typedef struct {
lfs_size_t estimate;
} lfsr_shrub_t;
typedef struct lfsr_mptr {
lfs_block_t blocks[2];
} lfsr_mptr_t;
typedef struct lfsr_mdir {
lfsr_smid_t mid;
lfsr_rbyd_t rbyd;
@@ -706,7 +702,7 @@ typedef struct lfsr_traversal {
union {
// cycle detection state, only valid when traversing the mroot chain
struct {
lfsr_mptr_t mptr;
lfs_block_t blocks[2];
lfs_block_t step;
uint8_t power;
} mtortoise;
@@ -740,7 +736,7 @@ typedef struct lfsr_mtree {
lfsr_mid_t weight;
struct {
lfsr_mid_t weight;
lfsr_mptr_t mptr;
lfs_block_t blocks[2];
} mptr;
lfsr_btree_t btree;
} u;