rv64_large_frame_8k.c (563B)
1 /* Large stack frame: forces the rv64 prologue/epilogue to grow the 2 * stack via more than a single 12-bit ADDI step. Exercises the 3 * frame-setup path for frames > 2048 bytes. */ 4 static int frame_consumer(volatile int* big, int n) { 5 int sum = 0; 6 for (int i = 0; i < n; ++i) sum += big[i]; 7 return sum; 8 } 9 int test_main(void) { 10 volatile int buf[2048]; /* 8 KiB locals */ 11 for (int i = 0; i < 2048; ++i) buf[i] = i + 1; 12 int s = frame_consumer(buf, 2048); 13 /* 1 + 2 + ... + 2048 = 2048 * 2049 / 2 = 2098176 */ 14 if (s != 2098176) return 1; 15 return 42; 16 }