From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63411 invoked by alias); 20 Jul 2017 09:22:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 63394 invoked by uid 89); 20 Jul 2017 09:22:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Jul 2017 09:22:03 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1dY7eh-0003Wc-Qe from Tom_deVries@mentor.com ; Thu, 20 Jul 2017 02:21:59 -0700 Received: from [127.0.0.1] (137.202.0.87) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Thu, 20 Jul 2017 10:21:49 +0100 To: Richard Biener CC: GCC Patches , Thomas Schwinge From: Tom de Vries Subject: [PATCH, PR81430] Use finalize_options in lto1 Message-ID: <767255ef-911c-d89c-3569-785c30354166@mentor.com> Date: Thu, 20 Jul 2017 09:22:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------8DDC7DA8966869D2E061DD69" X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-SW-Source: 2017-07/txt/msg01210.txt.bz2 --------------8DDC7DA8966869D2E061DD69 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2099 Hi, this patch fixes PR81430, an ICE in the libgomp testsuite for both openmp and openacc test-cases for x86_64 with nvptx accelerator. The scenario how we hit the ICE is as follows: - a testcase is compiled with -O2 - ix86_option_optimization_table enables OPT_freorder_blocks_and_partition at -O2 - cc1 writes out the flag as part of DECL_FUNCTION_SPECIFIC_OPTIMIZATION - lto1 reads in the flag as part of DECL_FUNCTION_SPECIFIC_OPTIMIZATION - lto1 uses the flag, and runs pass_partition_blocks - pass_partition_blocks ICEs, because it generates code that is not supported by the nvptx target. Note that for standalone compilation for single-thread ptx execution, we don't attempt to run pass_partition_blocks. This is because for nvptx, TARGET_HAVE_NAMED_SECTIONS is set to false, and this bit in finish_options switches off pass_partition_blocks: ... /* If the target requested unwind info, then turn off the partitioning optimization with a different message. Likewise, if the target does not support named sections. */ if (opts->x_flag_reorder_blocks_and_partition && (!targetm_common.have_named_sections || (opts->x_flag_unwind_tables && targetm_common.unwind_tables_default && (ui_except == UI_SJLJ || ui_except >= UI_TARGET)))) { if (opts_set->x_flag_reorder_blocks_and_partition) inform (loc, "-freorder-blocks-and-partition does not work " "on this architecture"); opts->x_flag_reorder_blocks_and_partition = 0; opts->x_flag_reorder_blocks = 1; } ... The patch fixes this by calling finish_options in lto1 after cl_optimization_restore. Points for review: 1. I'm uncertain though about the placement of the call. Perhaps it should be in cl_optimization_restore, before targetm.override_options_after_change? 2. I think that this is offloading specific, so perhaps this should be guarded with lto_stream_offload_p or #ifdef ACCEL_COMPILER or some such. Bootstrapped and reg-tested on x86_64. OK for trunk? Thanks, - Tom --------------8DDC7DA8966869D2E061DD69 Content-Type: text/x-patch; name="0001-Use-finalize_options-in-lto1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-Use-finalize_options-in-lto1.patch" Content-length: 1009 Use finalize_options in lto1 2017-07-20 Tom de Vries PR lto/81430 * function.c (invoke_set_current_function_hook): Call finish_options in lto1 after cl_optimization_restore. --- gcc/function.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/function.c b/gcc/function.c index f625489..ccb312b 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -77,6 +77,7 @@ along with GCC; see the file COPYING3. If not see #include "rtl-chkp.h" #include "tree-dfa.h" #include "tree-ssa.h" +#include "opts.h" /* So we can assign to cfun in this file. */ #undef cfun @@ -4793,6 +4794,11 @@ invoke_set_current_function_hook (tree fndecl) { optimization_current_node = opts; cl_optimization_restore (&global_options, TREE_OPTIMIZATION (opts)); + if (in_lto_p) + finish_options (&global_options, &global_options_set, + (fndecl + ? DECL_SOURCE_LOCATION (fndecl) + : UNKNOWN_LOCATION)); } targetm.set_current_function (fndecl); --------------8DDC7DA8966869D2E061DD69--