From patchwork Thu Dec 16 11:07:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 49010 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 0A7B4385843D for ; Thu, 16 Dec 2021 11:13:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 30B123858430 for ; Thu, 16 Dec 2021 11:07:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 30B123858430 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EC3F11F3A7; Thu, 16 Dec 2021 11:07:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1639652851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aN71h/7CSa7+ZFJUEPJOtlcrN3jSLOUC5pXTFYYzBfg=; b=DRksZiT/pcXs1jbIs9j4E3TkY8Y6iwXccJ78k+Oew+z/8PlYosL1OwumPDSrw7q3JUhMA1 jdBExjiHNJrpalJ5/NRtujs47MWs7aMSYSgmZ0hYL6xMQsUG12wwjT1N3GBntY3IYAbFpz dav42G8fSRV2Z5gaMjLR1TbyclSBPW8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1639652851; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aN71h/7CSa7+ZFJUEPJOtlcrN3jSLOUC5pXTFYYzBfg=; b=2LT2Xg7F+sxQ1OyZHcpw73qTqpvaAluciCGgD8cbFJx1PdVXASYXKVVUyMqva5o982CjvY 8BGFwCdmIDg25QAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D797013B4B; Thu, 16 Dec 2021 11:07:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id LKBrM/Mdu2H6MAAAMHmgww (envelope-from ); Thu, 16 Dec 2021 11:07:31 +0000 Message-ID: <9cedfef0-dd5f-7dbd-e7fb-cb64e427dd30@suse.cz> Date: Thu, 16 Dec 2021 12:07:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] pragma: respect pragma in lambda functions To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 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 Sender: "Gcc-patches" In g:01ad8c54fdca we started supporting target pragma changes that are primarily caused by optimization option. The same can happen in the opposite way and we need to check for changes both in optimization_current_node and target_option_current_node. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin PR c++/103696 gcc/ChangeLog: * attribs.c (decl_attributes): Check if target_option_current_node is changed. gcc/testsuite/ChangeLog: * g++.target/i386/pr103696.C: New test. --- gcc/attribs.c | 3 ++- gcc/testsuite/g++.target/i386/pr103696.C | 25 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.target/i386/pr103696.C diff --git a/gcc/attribs.c b/gcc/attribs.c index 01a9ed66485..29703e75fba 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -605,7 +605,8 @@ decl_attributes (tree *node, tree attributes, int flags, } if (TREE_CODE (*node) == FUNCTION_DECL - && optimization_current_node != optimization_default_node + && (optimization_current_node != optimization_default_node + || target_option_current_node != target_option_default_node) && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)) { DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) = optimization_current_node; diff --git a/gcc/testsuite/g++.target/i386/pr103696.C b/gcc/testsuite/g++.target/i386/pr103696.C new file mode 100644 index 00000000000..de7d5c68be9 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr103696.C @@ -0,0 +1,25 @@ +// PR c++/103696 +// { dg-options "-O2 -std=c++14 -fdump-tree-optimized" } + +int global_var; + +void fn() { +} + +#pragma GCC optimize("finite-math-only") +#pragma GCC target("sse3") + +void fn2() { +} + +void fn3() { +} + +int solve() { + auto nested = []() { + return global_var; + }; + return nested(); +} + +/* { dg-final { scan-tree-dump-not "lambda" "optimized" } } */