aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2024-11-14 16:15:09 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2024-11-14 16:15:09 +0000
commit89c7ebdee1177ee8131bb50dc2c8fc6217c66d9e (patch)
treefa22bf1a67a9c666c081e291aa4deacce4d5310a /gcc
parent41479351d638ed469bd6d8975dcacc4e72e503b3 (diff)
downloadgcc-89c7ebdee1177ee8131bb50dc2c8fc6217c66d9e.zip
gcc-89c7ebdee1177ee8131bb50dc2c8fc6217c66d9e.tar.gz
gcc-89c7ebdee1177ee8131bb50dc2c8fc6217c66d9e.tar.bz2
aarch64: Add non-local goto and jump tests for GCS
These are scan asm tests only, relying on existing execution tests for runtime coverage. gcc/testsuite/ChangeLog: * gcc.target/aarch64/gcs-nonlocal-1.c: New test. * gcc.target/aarch64/gcs-nonlocal-1-track-speculation.c: New test. * gcc.target/aarch64/gcs-nonlocal-2.c: New test. * gcc.target/aarch64/gcs-nonlocal-2-track-speculation.c: New test. * gcc.target/aarch64/gcs-nonlocal-1.h: New header file. * gcc.target/aarch64/gcs-nonlocal-2.h: New header file.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1-track-speculation.c7
-rw-r--r--gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.c7
-rw-r--r--gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.h20
-rw-r--r--gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2-track-speculation.c7
-rw-r--r--gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.c7
-rw-r--r--gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.h16
6 files changed, 64 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1-track-speculation.c b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1-track-speculation.c
new file mode 100644
index 0000000..4ee05ca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1-track-speculation.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=gcs -mtrack-speculation" } */
+/* { dg-final { scan-assembler-times "hint\\t40 // chkfeat x16" 2 } } */
+/* { dg-final { scan-assembler-times "mrs\\tx\[0-9\]+, s3_3_c2_c5_1 // gcspr_el0" 2 } } */
+/* { dg-final { scan-assembler-times "sysl\\txzr, #3, c7, c7, #1 // gcspopm" 1 } } */
+
+#include "gcs-nonlocal-1.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.c b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.c
new file mode 100644
index 0000000..57d8655
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=gcs" } */
+/* { dg-final { scan-assembler-times "hint\\t40 // chkfeat x16" 2 } } */
+/* { dg-final { scan-assembler-times "mrs\\tx\[0-9\]+, s3_3_c2_c5_1 // gcspr_el0" 2 } } */
+/* { dg-final { scan-assembler-times "sysl\\txzr, #3, c7, c7, #1 // gcspopm" 1 } } */
+
+#include "gcs-nonlocal-1.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.h b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.h
new file mode 100644
index 0000000..6a3e47d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.h
@@ -0,0 +1,20 @@
+
+int bar1 (int);
+int bar2 (int);
+
+void foo (int cmd)
+{
+ __label__ start;
+ int x = 0;
+
+ void nonlocal_goto (void)
+ {
+ x++;
+ goto start;
+ }
+
+start:
+ while (bar1 (x))
+ if (bar2 (x))
+ nonlocal_goto ();
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2-track-speculation.c b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2-track-speculation.c
new file mode 100644
index 0000000..fdf9e61
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2-track-speculation.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=gcs -mtrack-speculation" } */
+/* { dg-final { scan-assembler-times "hint\\t40 // chkfeat x16" 2 } } */
+/* { dg-final { scan-assembler-times "mrs\\tx\[0-9\]+, s3_3_c2_c5_1 // gcspr_el0" 2 } } */
+/* { dg-final { scan-assembler-times "sysl\\txzr, #3, c7, c7, #1 // gcspopm" 1 } } */
+
+#include "gcs-nonlocal-2.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.c b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.c
new file mode 100644
index 0000000..2414332
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=gcs" } */
+/* { dg-final { scan-assembler-times "hint\\t40 // chkfeat x16" 2 } } */
+/* { dg-final { scan-assembler-times "mrs\\tx\[0-9\]+, s3_3_c2_c5_1 // gcspr_el0" 2 } } */
+/* { dg-final { scan-assembler-times "sysl\\txzr, #3, c7, c7, #1 // gcspopm" 1 } } */
+
+#include "gcs-nonlocal-2.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.h b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.h
new file mode 100644
index 0000000..dd6e307
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.h
@@ -0,0 +1,16 @@
+
+void longj (void *buf)
+{
+ __builtin_longjmp (buf, 1);
+}
+
+void foo (void);
+void bar (void);
+
+void setj (void *buf)
+{
+ if (__builtin_setjmp (buf))
+ foo ();
+ else
+ bar ();
+}