kit

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

callx_indirect_retval.c (425B)


      1 /* Indirect call whose return value is consumed by the caller. The volatile
      2  * function-pointer local defeats devirtualization, forcing `blr`, and the
      3  * result is reused in arithmetic so it cannot collapse into a tail call.
      4  * triple(13) = 39, then +3 = 42. */
      5 __attribute__((noinline)) static int triple(int x) { return x * 3; }
      6 int test_main(void) {
      7   int (*volatile fp)(int) = triple;
      8   int r = fp(13);
      9   return r + 3;
     10 }