From patchwork Thu Aug 1 18:43:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1967989 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X22aCkdb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WZdCV6zSPz1ybX for ; Fri, 2 Aug 2024 04:43:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 313733858430 for ; Thu, 1 Aug 2024 18:43:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id B77C73858D20 for ; Thu, 1 Aug 2024 18:43:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B77C73858D20 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B77C73858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722537809; cv=none; b=WVu9VoSTTusp3fhiLfd9nWiuOtJcZEkWB9K0VtqQlONvjjuiJB3ytHoE7aZxjZTVzFOtaInBvKy6Z0IRC8mltBqgBu9p1kRQdaa3S439+vFmrAcgiydZkN1opMUtIG+ZXgu6oG6vKjfmnn/SZa/pYF2qKWSXpKutBeCdafUn8ho= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722537809; c=relaxed/simple; bh=jsnK38/iLyeNeMJtUPsnhZ1+nUvXOOnvaPgq7cKaN4E=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=h2vgSnnUspyHRQpRGWSMQQppJMv3Qb/bh1hCjjMzF7vbjQ6ylGWsHm72hVnmTX1cMHgqjWEiNVwvbi5Iv++3V293hf5AXocvY3rHfisMlLI57yq3mUKV7HwZgZJOmB1JRdnkPmd4TRD+3CBrspdDdXrHVUZiug6Vl36PIUCbaQo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722537807; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=mxgfktQ445DJ/Npp1BeoRe3cPaxRrPxxmyebNu1sZqs=; b=X22aCkdb9ZD6DP2xgg6caIKOlRX/hIlHhpz6qYkjytVjWHu349IHdJzBdZE2m7LqNq0Tdk /+J2R5B2PqDkmbWa2/AIxTsDvd8HuIcwUrMP/irEu+EitbNi66dUJEcDlJVMWoYR/sW1FL Doy1LwVEDk6Oj7XcD52lnqGSRN9vCno= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-42-1CPa2pCgOXqpT9Vy81S6kw-1; Thu, 01 Aug 2024 14:43:26 -0400 X-MC-Unique: 1CPa2pCgOXqpT9Vy81S6kw-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 12A551955D5B for ; Thu, 1 Aug 2024 18:43:25 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.25]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 42FE819560AA; Thu, 1 Aug 2024 18:43:24 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 471IhLwd1756365 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 1 Aug 2024 20:43:21 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 471IhLX31756364; Thu, 1 Aug 2024 20:43:21 +0200 Date: Thu, 1 Aug 2024 20:43:21 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Add unsequenced C++ testcase Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! This is the testcase I wrote originally and which on top of the https://gcc.gnu.org/pipermail/gcc-patches/2024-August/659154.html patch didn't behave the way I wanted (no warning and no optimizations of [[unsequenced]] function templates which don't have pointer/reference arguments. Posting this separately, because it depends on the above mentioned patch as well as the PR116175 https://gcc.gnu.org/pipermail/gcc-patches/2024-August/659157.html patch. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-08-01 Jakub Jelinek * g++.dg/ext/attr-unsequenced-1.C: New test. Jakub --- gcc/testsuite/g++.dg/ext/attr-unsequenced-1.C.jj 2024-08-01 16:57:52.309618653 +0200 +++ gcc/testsuite/g++.dg/ext/attr-unsequenced-1.C 2024-08-01 16:53:36.711859089 +0200 @@ -0,0 +1,53 @@ +// { dg-do compile { target c++11 } } +// { dg-options "-O2 -fdump-tree-optimized" } */ +// { dg-final { scan-tree-dump-times " bar \\\(1, 2, 3\\\);" 1 "optimized" } } +// { dg-final { scan-tree-dump-times " bar \\\(4, 5, 6\\\);" 1 "optimized" } } + +template +[[gnu::noipa]] U +foo (T x, T y, T z) [[gnu::unsequenced]] +{ + *x = 1; + *y = 2; + *z = 3; +} + +template +[[gnu::noipa]] T +bar (T x, T y, T z) [[gnu::unsequenced]] +{ + return x + y + z; +} + +int +baz () [[gnu::unsequenced]] +{ + int x, y, z; + foo (&x, &y, &z); + return x; +} + +int +qux () [[gnu::unsequenced]] +{ + int a = bar (1, 2, 3); + int b = bar (1, 2, 3); + int c = bar (1, 2, 3); + int d = bar (4, 5, 6); + int e = bar (4, 5, 6); + int f = bar (4, 5, 6); + return a + b + c + d + e + f; +} + +template +[[gnu::noipa]] U +corge (T x, T y, T z) [[gnu::unsequenced]] // { dg-warning "'unsequenced' attribute on function type without pointer arguments returning 'void'" } +{ + x += y + z; +} + +void +freddy () +{ + corge (1, 2, 3); +}