From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id BBA7D385E451; Wed, 14 Feb 2024 15:37:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBA7D385E451 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707925054; bh=MTw8bzWzaJWSyKMGwEUvvx0KuWjsEr2w2/0ddgupzCE=; h=From:To:Subject:Date:From; b=NBr50/ZbsGWoQ3VLTAJI3a5ACQyNqTdx2iTFh1XR+8ScFvOCD6aGLrxIDoCDd/JdM a1TkYbxE87i3vvny1kM4EOonXvy2kIgaNY//FfQUsvn+GPhSOA5+FJMN7scAfIOv2l 1bWY0NZdBSKoUngUo+Ga91UPp26iCXE934IPmv3Y= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/gcs-13)] aarch64: Add non-local goto and jump tests for GCS X-Act-Checkin: gcc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/vendors/ARM/heads/gcs-13 X-Git-Oldrev: 654dd5066a9171fbfc9699f70c5f8c607e872e2b X-Git-Newrev: 7afd277f772e8c10f7bcbd8d0d72727250c3495d Message-Id: <20240214153734.BBA7D385E451@sourceware.org> Date: Wed, 14 Feb 2024 15:37:34 +0000 (GMT) List-Id: https://gcc.gnu.org/g:7afd277f772e8c10f7bcbd8d0d72727250c3495d commit 7afd277f772e8c10f7bcbd8d0d72727250c3495d Author: Szabolcs Nagy Date: Wed Jun 7 10:58:06 2023 +0100 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-2.c: New test. Diff: --- gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.c | 25 +++++++++++++++++++++++ gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.c | 21 +++++++++++++++++++ 2 files changed, 46 insertions(+) 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 000000000000..821fab816f9a --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.c @@ -0,0 +1,25 @@ +/* { 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 } } */ + +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.c b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.c new file mode 100644 index 000000000000..63dbce36e1ed --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.c @@ -0,0 +1,21 @@ +/* { 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 } } */ + +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 (); +}