From patchwork Thu Jul 25 23:54:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1964968 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=AmWN9eSB; dkim-atps=neutral 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 4WVSSV3g4xz1yY9 for ; Fri, 26 Jul 2024 09:55:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BBA08385842C for ; Thu, 25 Jul 2024 23:55:36 +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.129.124]) by sourceware.org (Postfix) with ESMTP id 2AFBD385700F for ; Thu, 25 Jul 2024 23:55:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AFBD385700F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2AFBD385700F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721951713; cv=none; b=nzzyWWFiQE8gktVCBJyGtbTJKgqVKR6awL+pHdiaaJ0SBkihO4P+HroVIPH0Urgu2gjgrrWoPkeuLvz+EqwgeC28Ao18E9Ulj/ECwfB8gTr9qH0IYhfK9mb99SOArcPtwmYUHFvjuitySzG1NcMxpQXvERVTaqCTW1oMvkxhguI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721951713; c=relaxed/simple; bh=tpSoK8TAjRMM3xHuOvfmxP9/Rhh1UAa2OBdIYw0BBfc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Q57A0iqFZpZUWBhkG0AoWJCuNCMSBkQHlaWQrCyRgciEvLe2xtdvmP1Gl2SHUlh54cc7d1XrhmJNpHTqzORDD4LZFMf5U514zdqQtoOofND4JoIIVGZNkSZU/7Z2tbwlAuHtFMr/vdxpB4rgWJw/Y33kYOp2pq5JJBLh6Ld1iUA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721951709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=u02YujwDV1h21tzcSUFqIOcxJZ2wY1415solekiymN8=; b=AmWN9eSBA9UrVcm78WbsNYYOQX1Bv7vAsfiQgUKigap5qph7ntnEe/SEDeUFdB5as8FAs8 CJ3slTML1O9yybMQXOl2nFmH2H4Bv2F+hsDbWhN+gOAVHjeSm3qK9GhtEJBj3VvCuryGkj sfuhNKw5KeA3gYFqwXJcQb7rVFebpIM= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-157-o4HH6nidOhWQG2RBvycIBA-1; Thu, 25 Jul 2024 19:55:08 -0400 X-MC-Unique: o4HH6nidOhWQG2RBvycIBA-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7a1d8c45a90so11911285a.2 for ; Thu, 25 Jul 2024 16:55:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721951708; x=1722556508; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u02YujwDV1h21tzcSUFqIOcxJZ2wY1415solekiymN8=; b=MZIDsb/Yk0u6/pV2202roT5HfG3ccZ/n0QJfo7NGPq+xRjSkbceHxLFaN1KvzUOlKd 7ytq2OH6I5FbDlwJ6vqw2UiAUvwAucYsWLciwWhYRdv2SUCflIYxA1NesXk3MSNSdMLW R9WfHHMHeah/N8gtFvBIqHbrcGQulhMMJ4vqLchg7Gj0NvitWJKpTj+fvAflv6LoZjj4 WvPY7Sc+nR8Vaxher64nCkfH151aTdCuIZONWCeomVJyZkA87PajFOv67hNTs3cyNLHU IF9n7ymmiHokpZBZo9dsCCfwqjcMWlcoCTD49xsIbH+63RRjbOPrvCmoHzZMpz/bC+UR QLWQ== X-Gm-Message-State: AOJu0YzApWajIb5MM0+QBGiAarhwYGX/z6SIRwML/Cu6blZ3v4iJh8OK QGOe/b5CQ+dIHVmlI7THsUk8hnI7iUAcN6sfup3JTWjl3wYTSJLoEk+DwZ0ppgUKi3zED33kAnK k7aldg5mldVCZbjO66Smi6G7kLSoDWuoG+Z4eOzdwenb5YD2MbHXne+epxTdUa+KP5FGI1PAgNm wd9zUOcIgSco62iYscXAx31rojT0mf7KERug8= X-Received: by 2002:a05:620a:424b:b0:79f:879:63ad with SMTP id af79cd13be357-7a1d7f0f9afmr365339985a.46.1721951707771; Thu, 25 Jul 2024 16:55:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2dSHnwn8wd+GfyyeDm0QqjZdr7fFf0t1MVWTTFY4HTx8D7d/xufB9bnfFkYupBnNPAU03Bg== X-Received: by 2002:a05:620a:424b:b0:79f:879:63ad with SMTP id af79cd13be357-7a1d7f0f9afmr365337785a.46.1721951707249; Thu, 25 Jul 2024 16:55:07 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1d7435d8bsm126430585a.74.2024.07.25.16.55.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 16:55:06 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: #pragma target and deferred instantiation [PR115403] Date: Thu, 25 Jul 2024 19:54:23 -0400 Message-ID: <20240725235505.3394071-1-jason@redhat.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, 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: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu, applying to trunk. Also built highway to check. -- 8< -- My patch for 109753 applies the current #pragma target/optimize to a function when we compile it, which was a problem for a template instantiation deferred until EOF, where different #pragmas are active. So let's only do this for artificial functions. PR c++/115403 PR c++/109753 gcc/cp/ChangeLog: * decl.cc (start_preparsed_function): Only call decl_attributes for artificial functions. gcc/testsuite/ChangeLog: * g++.dg/ext/pragma-target1.C: New test. --- gcc/cp/decl.cc | 7 +++++-- gcc/testsuite/g++.dg/ext/pragma-target1.C | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/pragma-target1.C base-commit: 29341f21ce1eb7cdb8cd468e4ceb0d07cf2775e0 diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 6b686d75a49..279af21eed0 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -17882,8 +17882,11 @@ start_preparsed_function (tree decl1, tree attrs, int flags) doing_friend = true; } - /* Adjust for #pragma target/optimize. */ - decl_attributes (&decl1, NULL_TREE, 0); + /* Adjust for #pragma target/optimize if this is an artificial function that + (probably) didn't go through grokfndecl. We particularly don't want this + for deferred instantiations, which should match their template. */ + if (DECL_ARTIFICIAL (decl1)) + decl_attributes (&decl1, NULL_TREE, 0); if (DECL_DECLARED_INLINE_P (decl1) && lookup_attribute ("noinline", attrs)) diff --git a/gcc/testsuite/g++.dg/ext/pragma-target1.C b/gcc/testsuite/g++.dg/ext/pragma-target1.C new file mode 100644 index 00000000000..0ce2438da2f --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pragma-target1.C @@ -0,0 +1,6 @@ +// PR c++/115403 +// { dg-do compile { target x86_64-*-* } } + +template __attribute__((always_inline)) inline void AssertEqual() {} +void TestAllF16FromF32() { AssertEqual(); } +#pragma GCC target "sse4.1"