kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

opt_03_addr_index_alias_store.c (943B)


      1 /* Regression: AArch64 -O1 address materialization must handle the address
      2  * result register aliasing a dead-after-use scaled index. Lua's stack_init hit
      3  * this shape in `stack[i].tag = 0`: the broken sequence computed base+base and
      4  * stored through an unmapped address. */
      5 typedef struct Slot {
      6   unsigned long long payload;
      7   unsigned char tag;
      8   unsigned char pad[7];
      9 } Slot;
     10 
     11 typedef struct State {
     12   Slot* stack;
     13 } State;
     14 
     15 static void clear_tags(State* s, int n) {
     16   for (int i = 0; i < n; ++i) {
     17     Slot* slot = s->stack + i;
     18     slot->tag = 0;
     19   }
     20 }
     21 
     22 int test_main(void) {
     23   Slot slots[45];
     24   State state;
     25   unsigned total = 0;
     26 
     27   for (int i = 0; i < 45; ++i) {
     28     slots[i].payload = (unsigned long long)(1000 + i);
     29     slots[i].tag = (unsigned char)(i + 1);
     30   }
     31 
     32   state.stack = slots;
     33   clear_tags(&state, 45);
     34 
     35   for (int i = 0; i < 45; ++i) total += slots[i].tag;
     36 
     37   return total == 0 && slots[44].payload == 1044u ? 42 : 1;
     38 }