Message ID | 20231004025538.489F220439@pchp3.se.axis.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2504930vqb; Tue, 3 Oct 2023 20:55:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYfthzoYhYTGG/sMs370apixyWC9ISsLhA9wSSm0PhAK4kYGTmcinyrE1LV61s9DMQQUFm X-Received: by 2002:a17:906:7496:b0:9ae:72c7:73e6 with SMTP id e22-20020a170906749600b009ae72c773e6mr961003ejl.10.1696391753264; Tue, 03 Oct 2023 20:55:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696391753; cv=pass; d=google.com; s=arc-20160816; b=NzB55qzmZbYGDUxhA7ha2zDe+NFISBA+MLuZ1tOPniYw1iGNUkzKSBv8EGaCGW6umh RM4ZqJA7YfeXFX5SYtwL1q5CRGZ/kFfU/XwIH26rTYNJ/zu+tmDlGECuqEjKCoi43OVB RZzmT1XZNuQ5paA/XpJhftsjEDTsfV7Yuqi94rHyJcOxFKzSeRadkSztJZ72N6Klfw81 B4QAUOwyXdNzhijonkYECbLuQRbU68ME1ExrvCRT2IE7KmhCk0et42IZaqExgoedtxpf +q9T3pbuc+UEnZqpr/pksMVqAMQwJs9a4Vli0fkwzzbXxa0IHGFoGbt/mW+aPRZGHca3 PM7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:date:message-id:references :content-transfer-encoding:mime-version:subject:in-reply-to:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=9gfeX7TKJDmXMU/QbflDA3btbrYM7qEVXKFK019nMQU=; fh=BFUAfP3LrNKiUVnBam/vJbyj6bd7pJEFtISg/wI+450=; b=LFpEgPAWI40Il/tNomY7MRP2ntPGWx+O23XXwryC0sIK+uTZO+AVC3QAPDuKt0JaEC riUdtFBnxFZCMqXW6QYmKEPypBuprrLTvj3/rLK2mornStdgQVKR5gRWZoPgi7Wbpg6q OztvmCeCu+6piFnI1yjPY991Swwp1d23ANtG9g+K9o4O/lRa9ECU91gXUb5PgW3dPrfY t207VxzsLKgLgHB+oLKgg4bRfQMOwjzcq6ebjbxh5Qjbt4RxLFgGfoGQ6xi9Ded9h76j DR82xbvm2QVLFO+Y5R1J5Ws1Lv4UXiSzaUM+EF3QJbwFxxulE9x79mYr+TWWgDyznqE1 Jo8A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=euZov3PQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id kt13-20020a170906aacd00b0099cd6660994si1400055ejb.116.2023.10.03.20.55.52 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 20:55:53 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=euZov3PQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E586B3857020 for <ouuuleilei@gmail.com>; Wed, 4 Oct 2023 02:56:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2050.outbound.protection.outlook.com [40.107.247.50]) by sourceware.org (Postfix) with ESMTPS id CCB8D3858402; Wed, 4 Oct 2023 02:55:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CCB8D3858402 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=axis.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SopJgrjwKUpt+bYUnaMzp0DANgOaRzmBYOzDyCGy3Q/mmepHJoENolWwbIAkdPd0DmF1Ap7OnpuyX1TUPg4aamplwHJ66gBQ8KDD0EbQKAJFfVn0jbxoAGqiH2dh/qkkIfFX/wdZheNu4AcKtQobim4+LQfhGgX4HnpSLC/9DTr/HCZsM3EwOIITGFw+lfSiw3dwFyDo6Gg08gJ9X9AEZfEgvy+VvDPDFqj2L5mK1cdjSwZLfV4o8HeVon+6DVyTfz1YbKhkkQhTAwWtCWOPxBTjwNMXP/nj0PzNzKIKqnP4eiQ/XoQE/5VPZwtcq5waXQMcnjKvb3cNuTap1F5uFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9gfeX7TKJDmXMU/QbflDA3btbrYM7qEVXKFK019nMQU=; b=iWSVH2kppNL5Anz4WkraLqsafsURwpS2sqMDtUgBdUrnf43tF4b5AxdklsFf+63KmLnkuMrXdvEJaKnyfoJbIe75KQYHbBkChfIzpBSH1kD652G+iFB31jdTJJ2M49V/iLk3SqVnafy7n7Yc2n9qCp6rPkViKRkt0G9qeGGOgE2ghXNcToG1HMMZ1pVwkXwkHzvrkNEus/xPLlbMSc006Q39IYHtsU7VGUXSlAcqZO1l3iZa8ys1XSKjnpTHQlYmACQCofDLaJKASaTaoLclj65a0jUuFseQq2Jyc03smITWZnvcFB0cq9C/TcsUVrPEPCMV4xdWTMN29FTra3Lb5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 195.60.68.100) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=axis.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9gfeX7TKJDmXMU/QbflDA3btbrYM7qEVXKFK019nMQU=; b=euZov3PQbakjbqoIKAXqkeC6v0c5wXp68pC5vNizi/IBCgN4dn3PENv3Hr3ED2cUlrCMhGMaNxUFZAMjcXaFCPQ4atRBvZyyay+5yE0h0J6rNuzrOyKDCEBqlgIhkiy5ARd+mMZDSzQZhIxK0C5xPIVXqSUXYyli2LOLaYgw+fU= Received: from AS9PR07CA0041.eurprd07.prod.outlook.com (2603:10a6:20b:46b::28) by PAWPR02MB9688.eurprd02.prod.outlook.com (2603:10a6:102:2e3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.28; Wed, 4 Oct 2023 02:55:40 +0000 Received: from AMS0EPF000001A5.eurprd05.prod.outlook.com (2603:10a6:20b:46b:cafe::f3) by AS9PR07CA0041.outlook.office365.com (2603:10a6:20b:46b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.24 via Frontend Transport; Wed, 4 Oct 2023 02:55:40 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=axis.com; Received-SPF: Fail (protection.outlook.com: domain of axis.com does not designate 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001A5.mail.protection.outlook.com (10.167.16.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.14 via Frontend Transport; Wed, 4 Oct 2023 02:55:39 +0000 Received: from SE-MAILARCH01W.axis.com (10.20.40.15) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 4 Oct 2023 04:55:38 +0200 Received: from se-mail01w.axis.com (10.20.40.7) by SE-MAILARCH01W.axis.com (10.20.40.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 4 Oct 2023 04:55:38 +0200 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 4 Oct 2023 04:55:38 +0200 Received: from pchp3.se.axis.com (pchp3.se.axis.com [10.88.21.53]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 4DBCBE98; Wed, 4 Oct 2023 04:55:38 +0200 (CEST) Received: by pchp3.se.axis.com (Postfix, from userid 171) id 489F220439; Wed, 4 Oct 2023 04:55:38 +0200 (CEST) From: Hans-Peter Nilsson <hp@axis.com> To: Christophe Lyon <christophe.lyon@linaro.org> CC: <gcc-patches@gcc.gnu.org>, <libstdc++@gcc.gnu.org> In-Reply-To: <CAPS5khYXtGYLr-pqAQRy_UAsOJATted1Gs0xY4ytTWppFPVJaQ@mail.gmail.com> (message from Christophe Lyon on Tue, 3 Oct 2023 15:20:39 +0200) Subject: [PATCH 1/2] testsuite: Add dg-require-atomic-exchange non-atomic code MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT References: <20230926143439.B589920431@pchp3.se.axis.com> <CAPS5khYXtGYLr-pqAQRy_UAsOJATted1Gs0xY4ytTWppFPVJaQ@mail.gmail.com> Message-ID: <20231004025538.489F220439@pchp3.se.axis.com> Date: Wed, 4 Oct 2023 04:55:38 +0200 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A5:EE_|PAWPR02MB9688:EE_ X-MS-Office365-Filtering-Correlation-Id: 48fc4648-50df-411a-59cb-08dbc4856477 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uXkJ6LINBs9hRTL0mT4E1Cicit9jePhEr30WjernqjEMds1I8RSXHKwP/+vXvojN+TR3H1PjMjNNALzpIVJeeG4c7XEVt0BJxb1To9HCRKsuxUDJmx5lLDcItMsx1wYrQwzLwkePC8KlRk0HPYywE7beuHwCuV54yKRquy4O/5GFfQZjemC5afpuzfB1u/MhbrNfA/2QrgcN1fhTEGDWW5RK7mU/k+uTEb7wqqdB1/i79xwC4CLHsmfKVAJ5sWWjpol/gA/G3o5YFYKPow0L5FJu9j2H0qRSVgBotU0N0O9tiqYg58QgA1342KcrhmGK5zRUEU8Y/WzE+2+I1dwS6Hy4TP1N/8IT7VTGVuVtzfm9vDR3wSFu8yaGJVi5MAp3pG0Z5DYZuvQLgXDuTYuiZ9E+bYN2QFlG/8QAzB8uDnN1xdqiHapLsyHvIKYqtcxO1+M0MefIz8btUrArThjJDylkF0j6y9HPsV5zHKmp7y5Yyj3GaH+/8LoqDASn+4frywZ5HRAbzwFB834JUAvX+Uv/zjn2F7KhfdcHOvsPGjsGwN9/3zJf4fCL+AjDEbrAaOwphCYM1A8TCfPJfS8Dfx7yw+N7QqNYl+sB+W5R0M4APVMX25G7oVusH5He2JJIN4bHff2IBQ0tLVNs7Me2eDr2ZF+sRxlcN7q+xjFyZLWoidIQGsXd54XRB+o69YeneFwSRBfwLjJCwwqITk2VDn0HzOhOwXwcfASBRnx7Rn6YVqNZH9UE6m+BOIqkOl874iSb8MkMLY25au81LVpxFg== X-Forefront-Antispam-Report: CIP:195.60.68.100; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.axis.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(346002)(376002)(136003)(39860400002)(230922051799003)(451199024)(64100799003)(186009)(82310400011)(1800799009)(36840700001)(40470700004)(46966006)(83380400001)(40460700003)(6266002)(336012)(26005)(426003)(1076003)(82740400003)(356005)(81166007)(36860700001)(40480700001)(47076005)(478600001)(41300700001)(4326008)(8676002)(5660300002)(2906002)(33656002)(316002)(54906003)(8936002)(42186006)(6916009)(70206006)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 02:55:39.7669 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48fc4648-50df-411a-59cb-08dbc4856477 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af; Ip=[195.60.68.100]; Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A5.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR02MB9688 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778795679486198038 X-GMAIL-MSGID: 1778795679486198038 |
Series |
[1/2] testsuite: Add dg-require-atomic-exchange non-atomic code
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Hans-Peter Nilsson
Oct. 4, 2023, 2:55 a.m. UTC
> From: Christophe Lyon <christophe.lyon@linaro.org> > Date: Tue, 3 Oct 2023 15:20:39 +0200 > Maybe we need a new variant of dg-require-thread-fence ? Yes: many of the dg-require-thread-fence users need something stronger. Tested arm-eabi together with the next patch (2/2) with RUNTESTFLAGS=--target_board=arm-sim/-mthumb/-march=armv6s-m/-mtune=cortex-m0/-mfloat-abi=soft/-mfpu=auto\ conformance.exp=29_atomics/\* (Incidentally, in the patch context is seen dg-require-atomic-builtins which is a misnomer: it should rather be named "dg-require-lock-atomic-builtins-free".) Ok to commit? -- >8 -- Some targets (armv6) support inline atomic load and store, i.e. dg-require-thread-fence matches, but not atomic like atomic exchange. This directive will replace uses of dg-require-thread-fence where an atomic exchange operation is actually used. * testsuite/lib/dg-options.exp (dg-require-atomic-exchange): New proc. * testsuite/lib/libstdc++.exp (check_v3_target_atomic_exchange): Ditto. --- libstdc++-v3/testsuite/lib/dg-options.exp | 9 ++++++ libstdc++-v3/testsuite/lib/libstdc++.exp | 35 +++++++++++++++++++++++ 2 files changed, 44 insertions(+)
Comments
On Wed, 4 Oct 2023 at 03:56, Hans-Peter Nilsson <hp@axis.com> wrote: > > > From: Christophe Lyon <christophe.lyon@linaro.org> > > Date: Tue, 3 Oct 2023 15:20:39 +0200 > > > Maybe we need a new variant of dg-require-thread-fence ? > > Yes: many of the dg-require-thread-fence users need > something stronger. Tested arm-eabi together with the next > patch (2/2) with > RUNTESTFLAGS=--target_board=arm-sim/-mthumb/-march=armv6s-m/-mtune=cortex-m0/-mfloat-abi=soft/-mfpu=auto\ > conformance.exp=29_atomics/\* > > (Incidentally, in the patch context is seen > dg-require-atomic-builtins which is a misnomer: it should > rather be named "dg-require-lock-atomic-builtins-free".) dg-require-lock-free-atomic-builtins or dg-require-atomic-builtins-lock-free, surely? > > Ok to commit? > > -- >8 -- > Some targets (armv6) support inline atomic load and store, > i.e. dg-require-thread-fence matches, but not atomic like > atomic exchange. This directive will replace uses of > dg-require-thread-fence where an atomic exchange operation > is actually used. > > * testsuite/lib/dg-options.exp (dg-require-atomic-exchange): New proc. > * testsuite/lib/libstdc++.exp (check_v3_target_atomic_exchange): Ditto. OK > --- > libstdc++-v3/testsuite/lib/dg-options.exp | 9 ++++++ > libstdc++-v3/testsuite/lib/libstdc++.exp | 35 +++++++++++++++++++++++ > 2 files changed, 44 insertions(+) > > diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp > index 84ad0c65330b..b13c2f244c63 100644 > --- a/libstdc++-v3/testsuite/lib/dg-options.exp > +++ b/libstdc++-v3/testsuite/lib/dg-options.exp > @@ -133,6 +133,15 @@ proc dg-require-thread-fence { args } { > return > } > > +proc dg-require-atomic-exchange { args } { > + if { ![ check_v3_target_atomic_exchange ] } { > + upvar dg-do-what dg-do-what > + set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] > + return > + } > + return > +} > + > proc dg-require-atomic-builtins { args } { > if { ![ check_v3_target_atomic_builtins ] } { > upvar dg-do-what dg-do-what > diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp > index 608056e5068e..481f81711074 100644 > --- a/libstdc++-v3/testsuite/lib/libstdc++.exp > +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp > @@ -1221,6 +1221,41 @@ proc check_v3_target_thread_fence { } { > }] > } > > +proc check_v3_target_atomic_exchange { } { > + return [check_v3_target_prop_cached et_atomic_exchange { > + global cxxflags > + global DEFAULT_CXXFLAGS > + > + # Set up and link a C++11 test program that depends > + # on atomic exchange be available for "int". > + set src atomic_exchange[pid].cc > + > + set f [open $src "w"] > + puts $f " > + int i, j, k; > + int main() { > + __atomic_exchange (&i, &j, &k, __ATOMIC_SEQ_CST); > + return 0; > + }" > + close $f > + > + set cxxflags_saved $cxxflags > + set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11" > + > + set lines [v3_target_compile $src /dev/null executable ""] > + set cxxflags $cxxflags_saved > + file delete $src > + > + if [string match "" $lines] { > + # No error message, linking succeeded. > + return 1 > + } else { > + verbose "check_v3_target_atomic_exchange: compilation failed" 2 > + return 0 > + } > + }] > +} > + > # Return 1 if atomics_bool and atomic_int are always lock-free, 0 otherwise. > proc check_v3_target_atomic_builtins { } { > return [check_v3_target_prop_cached et_atomic_builtins { > -- > 2.30.2 > > > > > > Thanks, > > > > Christophe > > > > > > Ok to commit? > > > > > > -- >8 -- > > > Make __atomic_test_and_set consistent with other __atomic_ and __sync_ > > > builtins: call a matching library function instead of emitting > > > non-atomic code when the target has no direct insn support. > > > > > > There's special-case code handling targetm.atomic_test_and_set_trueval > > > != 1 trying a modified maybe_emit_sync_lock_test_and_set. Previously, > > > if that worked but its matching emit_store_flag_force returned NULL, > > > we'd segfault later on. Now that the caller handles NULL, gcc_assert > > > here instead. > > > > > > While the referenced PR:s are ARM-specific, the issue is general. > > > > > > PR target/107567 > > > PR target/109166 > > > * builtins.cc (expand_builtin) <case BUILT_IN_ATOMIC_TEST_AND_SET>: > > > Handle failure from expand_builtin_atomic_test_and_set. > > > * optabs.cc (expand_atomic_test_and_set): When all attempts fail to > > > generate atomic code through target support, return NULL > > > instead of emitting non-atomic code. Also, for code handling > > > targetm.atomic_test_and_set_trueval != 1, gcc_assert result > > > from calling emit_store_flag_force instead of returning NULL. > > > --- > > > gcc/builtins.cc | 5 ++++- > > > gcc/optabs.cc | 22 +++++++--------------- > > > 2 files changed, 11 insertions(+), 16 deletions(-) > > > > > > diff --git a/gcc/builtins.cc b/gcc/builtins.cc > > > index 6e4274bb2a4e..40dfd36a3197 100644 > > > --- a/gcc/builtins.cc > > > +++ b/gcc/builtins.cc > > > @@ -8387,7 +8387,10 @@ expand_builtin (tree exp, rtx target, rtx > > > subtarget, machine_mode mode, > > > break; > > > > > > case BUILT_IN_ATOMIC_TEST_AND_SET: > > > - return expand_builtin_atomic_test_and_set (exp, target); > > > + target = expand_builtin_atomic_test_and_set (exp, target); > > > + if (target) > > > + return target; > > > + break; > > > > > > case BUILT_IN_ATOMIC_CLEAR: > > > return expand_builtin_atomic_clear (exp); > > > diff --git a/gcc/optabs.cc b/gcc/optabs.cc > > > index 8b96f23aec05..e1898da22808 100644 > > > --- a/gcc/optabs.cc > > > +++ b/gcc/optabs.cc > > > @@ -7080,25 +7080,17 @@ expand_atomic_test_and_set (rtx target, rtx mem, > > > enum memmodel model) > > > /* Recall that the legacy lock_test_and_set optab was allowed to do > > > magic > > > things with the value 1. Thus we try again without trueval. */ > > > if (!ret && targetm.atomic_test_and_set_trueval != 1) > > > - ret = maybe_emit_sync_lock_test_and_set (subtarget, mem, const1_rtx, > > > model); > > > - > > > - /* Failing all else, assume a single threaded environment and simply > > > - perform the operation. */ > > > - if (!ret) > > > { > > > - /* If the result is ignored skip the move to target. */ > > > - if (subtarget != const0_rtx) > > > - emit_move_insn (subtarget, mem); > > > + ret = maybe_emit_sync_lock_test_and_set (subtarget, mem, > > > const1_rtx, model); > > > > > > - emit_move_insn (mem, trueval); > > > - ret = subtarget; > > > + if (ret) > > > + { > > > + /* Rectify the not-one trueval. */ > > > + ret = emit_store_flag_force (target, NE, ret, const0_rtx, mode, > > > 0, 1); > > > + gcc_assert (ret); > > > + } > > > } > > > > > > - /* Recall that have to return a boolean value; rectify if trueval > > > - is not exactly one. */ > > > - if (targetm.atomic_test_and_set_trueval != 1) > > > - ret = emit_store_flag_force (target, NE, ret, const0_rtx, mode, 0, 1); > > > - > > > return ret; > > > } > > > > > > -- > > > 2.30.2 > > > > > > > > >
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 84ad0c65330b..b13c2f244c63 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -133,6 +133,15 @@ proc dg-require-thread-fence { args } { return } +proc dg-require-atomic-exchange { args } { + if { ![ check_v3_target_atomic_exchange ] } { + upvar dg-do-what dg-do-what + set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] + return + } + return +} + proc dg-require-atomic-builtins { args } { if { ![ check_v3_target_atomic_builtins ] } { upvar dg-do-what dg-do-what diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 608056e5068e..481f81711074 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -1221,6 +1221,41 @@ proc check_v3_target_thread_fence { } { }] } +proc check_v3_target_atomic_exchange { } { + return [check_v3_target_prop_cached et_atomic_exchange { + global cxxflags + global DEFAULT_CXXFLAGS + + # Set up and link a C++11 test program that depends + # on atomic exchange be available for "int". + set src atomic_exchange[pid].cc + + set f [open $src "w"] + puts $f " + int i, j, k; + int main() { + __atomic_exchange (&i, &j, &k, __ATOMIC_SEQ_CST); + return 0; + }" + close $f + + set cxxflags_saved $cxxflags + set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11" + + set lines [v3_target_compile $src /dev/null executable ""] + set cxxflags $cxxflags_saved + file delete $src + + if [string match "" $lines] { + # No error message, linking succeeded. + return 1 + } else { + verbose "check_v3_target_atomic_exchange: compilation failed" 2 + return 0 + } + }] +} + # Return 1 if atomics_bool and atomic_int are always lock-free, 0 otherwise. proc check_v3_target_atomic_builtins { } { return [check_v3_target_prop_cached et_atomic_builtins {