Debian Codegraph @

gcc/testsuite/gcc.target/riscv/pr120714.c

raw
1 /* Test checking that the backtrace on large frame size with additional
2 SP shift in the prologue won't broken when compiled with the
3 -fstack-clash-protection option. */
4 /* { dg-do run { target { *-*-linux* } } } */
5 /* -O0 does not have enough optimizations.
6 -O2/-O3 does inline and reduces number of addresses in the backtrace. */
7 /* { dg-skip-if "" { *-*-* } { "-O0" "-O2" "-O3" } } */
8 /* { dg-options "-g -fstack-clash-protection" } */
9
10 #include <execinfo.h>
11
12 #define MAX 4000
13
14 void goo ()
15 {
16 int addresses;
17 void *buffer[10];
18
19 addresses = backtrace (buffer, 10);
20 if (addresses != 6)
21 __builtin_abort ();
22 }
23
24 int foo (int a)
25 {
26 long long A[MAX];
27 for (int i = 0; i < MAX; i++)
28 A[i] = i;
29
30 goo ();
31
32 return A[a % MAX];
33 }
34
35 int main ()
36 {
37 if (foo (20) != 20)
38 __builtin_abort ();
39 return 0;
40 }