aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/riscv/pr120714.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.target/riscv/pr120714.c')
-rw-r--r--gcc/testsuite/gcc.target/riscv/pr120714.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/riscv/pr120714.c b/gcc/testsuite/gcc.target/riscv/pr120714.c
new file mode 100644
index 0000000..dd71a3e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr120714.c
@@ -0,0 +1,40 @@
+/* Test checking that the backtrace on large frame size with additional
+ SP shift in the prologue won't broken when compiled with the
+ -fstack-clash-protection option. */
+/* { dg-do run { target { *-*-linux* } } } */
+/* -O0 does not have enough optimizations.
+ -O2/-O3 does inline and reduces number of addresses in the backtrace. */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-O2" "-O3" } } */
+/* { dg-options "-g -fstack-clash-protection" } */
+
+#include <execinfo.h>
+
+#define MAX 4000
+
+void goo ()
+{
+ int addresses;
+ void *buffer[10];
+
+ addresses = backtrace (buffer, 10);
+ if (addresses != 6)
+ __builtin_abort ();
+}
+
+int foo (int a)
+{
+ long long A[MAX];
+ for (int i = 0; i < MAX; i++)
+ A[i] = i;
+
+ goo ();
+
+ return A[a % MAX];
+}
+
+int main ()
+{
+ if (foo (20) != 20)
+ __builtin_abort ();
+ return 0;
+}