]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Add eh_return compile tests
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 2 Jun 2023 13:17:02 +0000 (14:17 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Mon, 27 Nov 2023 15:52:48 +0000 (15:52 +0000)
gcc/testsuite/ChangeLog:

* gcc.target/aarch64/eh_return-2.c: New test.
* gcc.target/aarch64/eh_return-3.c: New test.

gcc/testsuite/gcc.target/aarch64/eh_return-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/eh_return-3.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.target/aarch64/eh_return-2.c b/gcc/testsuite/gcc.target/aarch64/eh_return-2.c
new file mode 100644 (file)
index 0000000..4a9d124
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-final { scan-assembler "add\tsp, sp, x5" } } */
+/* { dg-final { scan-assembler "br\tx6" } } */
+
+void
+foo (unsigned long off, void *handler)
+{
+  __builtin_eh_return (off, handler);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/eh_return-3.c b/gcc/testsuite/gcc.target/aarch64/eh_return-3.c
new file mode 100644 (file)
index 0000000..a17baa8
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=pac-ret+leaf -fno-schedule-insns -fno-schedule-insns2" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+/*
+**foo:
+**     hint    25 // paciasp
+**     ...
+**     cbz     w2, .*
+**     mov     x4, 0
+**     ...
+**     cbz     x4, .*
+**     add     sp, sp, x5
+**     br      x6
+**     hint    29 // autiasp
+**     ret
+**     mov     x5, x0
+**     mov     x4, 1
+**     mov     x6, x1
+**     b       .*
+*/
+void
+foo (unsigned long off, void *handler, int c)
+{
+  if (c)
+    return;
+  __builtin_eh_return (off, handler);
+}