From patchwork Fri Nov 8 14:48:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 2008508 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XlMNt6DY1z1xyS for ; Sat, 9 Nov 2024 01:52:30 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 10C96385843B for ; Fri, 8 Nov 2024 14:52:29 +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 814983858031; Fri, 8 Nov 2024 14:50:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 814983858031 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 814983858031 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=1731077433; cv=none; b=fz6THLD1TGWY0BbPH5YnPMuwteT3AGDSWDYWhcQK2/rJ9un1DmkFoHlZK9ZYY8wOZBYUFRyGlHMGSX21gtUZMtrnWgdQfud0o/T1SPbaGyPW3kBG8/GvlPMNjW/bmzfUIT85XBz8cTw8IH4NOuAVXZ6MoOlXzlKdTRuda5m3Xy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731077433; c=relaxed/simple; bh=v1ruIuWgLrau44q1OW4C1GkNF5InjYO8R4yGNn7djh4=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=cdb9+J3kKdX0JTuzebCe4qXIn5cX3tjgmXxZTOGZiwIwfHnS1t3fadTPswgbh/goExzThNFNXAJfZx5BI99r7pQFG5YcywrlHmNEX0bXBL/9oj8dgf//tJQU9bk1fRqgKmY/PqDUTyrqJqktZheLOBCnA62fH8Tj/Qd508ezSJ0= 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 31CC8497; Fri, 8 Nov 2024 06:50:51 -0800 (PST) Received: from udebian.localdomain (unknown [10.57.26.225]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E468D3F66E; Fri, 8 Nov 2024 06:50:19 -0800 (PST) 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, richard.sandiford@arm.com, ktkachov@nvidia.com, john.brawn@arm.com Subject: [PATCH v3 12/23] aarch64: Add non-local goto and jump tests for GCS Date: Fri, 8 Nov 2024 14:48:05 +0000 Message-Id: <20241108144816.2681175-13-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241108144816.2681175-1-yury.khrustalev@arm.com> References: <20241108144816.2681175-1-yury.khrustalev@arm.com> MIME-Version: 1.0 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~incoming=patchwork.ozlabs.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-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. --- .../gcs-nonlocal-1-track-speculation.c | 7 +++++++ .../gcc.target/aarch64/gcs-nonlocal-1.c | 7 +++++++ .../gcc.target/aarch64/gcs-nonlocal-1.h | 20 +++++++++++++++++++ .../gcs-nonlocal-2-track-speculation.c | 7 +++++++ .../gcc.target/aarch64/gcs-nonlocal-2.c | 7 +++++++ .../gcc.target/aarch64/gcs-nonlocal-2.h | 16 +++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1-track-speculation.c create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.c create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.h create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2-track-speculation.c create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.c create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.h 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 00000000000..4ee05ca5503 --- /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 00000000000..57d865577ad --- /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 00000000000..6a3e47d2db0 --- /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 00000000000..fdf9e612142 --- /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 00000000000..2414332906e --- /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 00000000000..dd6e307b4bd --- /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 (); +}