kit

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

a.c (953B)


      1 /* Transitive closure: test_main calls live_chain_a → live_chain_b →
      2  * live_chain_c. The dead_chain_* triple has no caller — all three
      3  * should be dropped together.
      4  *
      5  * volatile sink writes are required to stop clang from constant-folding
      6  * trivial-return chains away (which would erase the very relocs the GC
      7  * pass needs to walk). */
      8 
      9 volatile int sink;
     10 
     11 __attribute__((noinline)) int live_chain_c(void) {
     12   sink |= 0xC;
     13   return 0;
     14 }
     15 __attribute__((noinline)) int live_chain_b(void) {
     16   sink |= 0xB;
     17   return live_chain_c();
     18 }
     19 __attribute__((noinline)) int live_chain_a(void) {
     20   sink |= 0xA;
     21   return live_chain_b();
     22 }
     23 
     24 __attribute__((noinline)) int dead_chain_c(void) {
     25   sink |= 0x0C;
     26   return 0;
     27 }
     28 __attribute__((noinline)) int dead_chain_b(void) {
     29   sink |= 0x0B;
     30   return dead_chain_c();
     31 }
     32 __attribute__((noinline)) int dead_chain_a(void) {
     33   sink |= 0x0A;
     34   return dead_chain_b();
     35 }
     36 
     37 int test_main(void) { return live_chain_a(); }