kit

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

mem_volatile.c (495B)


      1 /* mem: repeated volatile accesses. Each read/write of a volatile object must
      2  * produce a real load/store (no elision, no forwarding), so the same 32-bit
      3  * str/ldr pair is emitted several times. Round-trip must preserve every one.
      4  * Exit: 42. */
      5 int test_main(void) {
      6   volatile int v = 0;
      7   v = 10;     /* str w */
      8   int a = v;  /* ldr w */
      9   v = a + 11; /* ldr-add-str: 21 */
     10   int b = v;  /* ldr w  -> 21 */
     11   v = b + v;  /* two loads of v + store: 42 */
     12   return v;   /* ldr w -> 42 */
     13 }