From patchwork Wed Oct 23 11:05:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 99420 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB27B3857C6E for ; Wed, 23 Oct 2024 11:10:31 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 2547F3858D3C; Wed, 23 Oct 2024 11:07:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2547F3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2547F3858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729681649; cv=none; b=XSGPmCBG58JCySjDnK3PgEsLSwlbDhXKpc4w8cuBSpz8RzNW3pyGhJQF7tgwfVwtRGaJnmIeBM01kAh5upgCziEm3i9pGLb3ef98aQW6YotwJDqJBsJGwnTcVufLm8x+jifYT+BAlQ2TCvggfO7tiIbKq12AWzVstREB9z4j+6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729681649; c=relaxed/simple; bh=CxFKRKeKnmtsakSSXBG7UO619XKVpq7nm9DKi72v+SQ=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=EDTURUbHf7sVcuDkVx41Cfec2VdMEptsdM9NdlFhS5PVmD5/0wHhBUQBzE263hn4XEhXgC4Wdd5EYBlqQ6fKWsUEAwQq2tOZgoWgryoZDqoOVebd71g/qYkVdSUamwQurjbAv8gjyU6W5bNHXEGhcpFQCUNluQ7H0Qm/83eUJtE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9553B497; Wed, 23 Oct 2024 04:07:49 -0700 (PDT) Received: from udebian.localdomain (unknown [10.1.39.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3A80B3F528; Wed, 23 Oct 2024 04:07:19 -0700 (PDT) From: Yury Khrustalev To: gcc-patches@gcc.gnu.org Cc: nsz@gcc.gnu.org, richard.earnshaw@arm.com, matthieu.longo@arm.com, richard.ball@arm.com Subject: [PATCH 10/22] aarch64: Add non-local goto and jump tests for GCS Date: Wed, 23 Oct 2024 12:05:16 +0100 Message-Id: <20241023110528.487830-11-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241023110528.487830-1-yury.khrustalev@arm.com> References: <20241023110528.487830-1-yury.khrustalev@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Szabolcs Nagy 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. --- .../gcc.target/aarch64/gcs-nonlocal-1.c | 25 +++++++++++++++++++ .../gcc.target/aarch64/gcs-nonlocal-2.c | 21 ++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.c create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.c 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 00000000000..821fab816f9 --- /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 00000000000..63dbce36e1e --- /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 (); +}