From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9898 invoked by alias); 9 Jan 2015 11:45:24 -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 9764 invoked by uid 89); 9 Jan 2015 11:45:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 09 Jan 2015 11:45:20 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t09BjCXf018688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 9 Jan 2015 06:45:12 -0500 Received: from tucnak.zalov.cz (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t09Bj9qW025709 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Fri, 9 Jan 2015 06:45:11 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.9/8.14.9) with ESMTP id t09Bj7ZS021897; Fri, 9 Jan 2015 12:45:07 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.9/8.14.9/Submit) id t09Bj3fo021896; Fri, 9 Jan 2015 12:45:03 +0100 Date: Fri, 09 Jan 2015 11:50:00 -0000 From: Jakub Jelinek To: Thomas Schwinge Cc: Bernd Schmidt , Bernd Schmidt , Richard Biener , Jan Hubicka , gcc-patches@gcc.gnu.org, neil@daikokuya.co.uk.zalov.cz, joseph@codesourcery.com, Julian Brown , Cesar Philippidis , iverbin@gmail.com, kirill.yukhin@gmail.com, andrey.turetskiy@gmail.com Subject: Re: LTO streaming of TARGET_OPTIMIZE_NODE Message-ID: <20150109114503.GW1405@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20141113040652.GB1984@kam.mff.cuni.cz> <546DDE1C.6060203@t-online.de> <20150108141149.GC1405@tucnak.redhat.com> <871tn4w6tt.fsf@schwinge.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871tn4w6tt.fsf@schwinge.name> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg00499.txt.bz2 On Fri, Jan 09, 2015 at 12:07:26PM +0100, Thomas Schwinge wrote: > On Thu, 8 Jan 2015 15:11:49 +0100, Jakub Jelinek wrote: > > On Thu, Nov 20, 2014 at 01:27:08PM +0100, Bernd Schmidt wrote: > > > On 11/13/2014 05:06 AM, Jan Hubicka wrote: > > > >this patch adds infrastructure for proper streaming and merging of > > > >TREE_TARGET_OPTION. > > > > > > This breaks the offloading path via LTO since it introduces an > > > incompatibility in LTO format between host and offload machine. > > > > > > A very quick patch to fix it is below - the OpenACC testcase I was using > > > seems to be working again with this. Thoughts, suggestions? > > > > I actually think > > Thanks for picking up this issue! Richard said on IRC he doesn't like the string comparisons, so here is untested modification of the patch. If it looks good, I'll test it today: 2015-01-09 Bernd Schmidt Jakub Jelinek PR middle-end/64412 * lto-streamer.h (lto_stream_offload_p): New declaration. * lto-streamer.c (lto_stream_offload_p): New variable. * cgraphunit.c (ipa_passes): Set lto_stream_offload_p at the same time as section_name_prefix. * lto-streamer-out.c (hash_tree): Don't hash TREE_TARGET_OPTION if lto_stream_offload_p. * tree-streamer-out.c (streamer_pack_tree_bitfields): Don't stream TREE_TARGET_OPTION if lto_stream_offload_p. (write_ts_function_decl_tree_pointers): Don't stream DECL_FUNCTION_SPECIFIC_TARGET if lto_stream_offload_p. * tree-streamer-in.c (unpack_value_fields): Don't stream TREE_TARGET_OPTION in if ACCEL_COMPILER. (lto_input_ts_function_decl_tree_pointers): Don't stream DECL_FUNCTION_SPECIFIC_TARGET in if ACCEL_COMPILER. * lto-opts.c (lto_write_options): Use lto_stream_offload_p instead of section_name_prefix string comparisons. lto/ * lto.c (read_cgraph_and_symbols): Set lto_stream_offload_p if ACCEL_COMPILER. --- gcc/lto-streamer.h.jj 2015-01-05 13:07:13.000000000 +0100 +++ gcc/lto-streamer.h 2015-01-09 12:18:26.199842482 +0100 @@ -744,6 +744,10 @@ extern void lto_append_block (struct lto /* In lto-streamer.c. */ + +/* Set when streaming LTO for offloading compiler. */ +extern bool lto_stream_offload_p; + extern const char *lto_tag_name (enum LTO_tags); extern bitmap lto_bitmap_alloc (void); extern void lto_bitmap_free (bitmap); --- gcc/lto-streamer.c.jj 2015-01-05 13:07:13.000000000 +0100 +++ gcc/lto-streamer.c 2015-01-09 12:16:04.909269917 +0100 @@ -61,6 +61,8 @@ static bitmap_obstack lto_obstack; static bool lto_obstack_initialized; const char *section_name_prefix = LTO_SECTION_NAME_PREFIX; +/* Set when streaming LTO for offloading compiler. */ +bool lto_stream_offload_p; /* Return a string representing LTO tag TAG. */ --- gcc/cgraphunit.c.jj 2015-01-09 12:01:33.000000000 +0100 +++ gcc/cgraphunit.c 2015-01-09 12:22:27.742692667 +0100 @@ -2108,11 +2108,14 @@ ipa_passes (void) if (g->have_offload) { section_name_prefix = OFFLOAD_SECTION_NAME_PREFIX; + lto_stream_offload_p = true; ipa_write_summaries (true); + lto_stream_offload_p = false; } if (flag_lto) { section_name_prefix = LTO_SECTION_NAME_PREFIX; + lto_stream_offload_p = false; ipa_write_summaries (false); } } --- gcc/lto-streamer-out.c.jj 2015-01-08 18:10:23.633598629 +0100 +++ gcc/lto-streamer-out.c 2015-01-09 12:14:41.017711211 +0100 @@ -944,7 +944,9 @@ hash_tree (struct streamer_tree_cache_d hstate.add (TRANSLATION_UNIT_LANGUAGE (t), strlen (TRANSLATION_UNIT_LANGUAGE (t))); - if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)) + if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION) + /* We don't stream these when passing things to a different target. */ + && !lto_stream_offload_p) hstate.add_wide_int (cl_target_option_hash (TREE_TARGET_OPTION (t))); if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION)) --- gcc/tree-streamer-out.c.jj 2015-01-08 18:10:23.631598663 +0100 +++ gcc/tree-streamer-out.c 2015-01-09 12:14:41.018711194 +0100 @@ -472,7 +472,9 @@ streamer_pack_tree_bitfields (struct out if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR)) bp_pack_var_len_unsigned (bp, CONSTRUCTOR_NELTS (expr)); - if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)) + if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION) + /* Don't stream these when passing things to a different target. */ + && !lto_stream_offload_p) cl_target_option_stream_out (ob, bp, TREE_TARGET_OPTION (expr)); if (code == OMP_CLAUSE) @@ -687,7 +689,9 @@ write_ts_function_decl_tree_pointers (st stream_write_tree (ob, DECL_VINDEX (expr), ref_p); /* DECL_STRUCT_FUNCTION is handled by lto_output_function. */ stream_write_tree (ob, DECL_FUNCTION_PERSONALITY (expr), ref_p); - stream_write_tree (ob, DECL_FUNCTION_SPECIFIC_TARGET (expr), ref_p); + /* Don't stream these when passing things to a different target. */ + if (!lto_stream_offload_p) + stream_write_tree (ob, DECL_FUNCTION_SPECIFIC_TARGET (expr), ref_p); stream_write_tree (ob, DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr), ref_p); } --- gcc/tree-streamer-in.c.jj 2015-01-08 18:10:23.561599843 +0100 +++ gcc/tree-streamer-in.c 2015-01-09 12:14:41.017711211 +0100 @@ -520,8 +520,10 @@ unpack_value_fields (struct data_in *dat vec_safe_grow (CONSTRUCTOR_ELTS (expr), length); } +#ifndef ACCEL_COMPILER if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)) cl_target_option_stream_in (data_in, bp, TREE_TARGET_OPTION (expr)); +#endif if (code == OMP_CLAUSE) unpack_ts_omp_clause_value_fields (data_in, bp, expr); @@ -785,7 +787,9 @@ lto_input_ts_function_decl_tree_pointers DECL_VINDEX (expr) = stream_read_tree (ib, data_in); /* DECL_STRUCT_FUNCTION is loaded on demand by cgraph_get_body. */ DECL_FUNCTION_PERSONALITY (expr) = stream_read_tree (ib, data_in); +#ifndef ACCEL_COMPILER DECL_FUNCTION_SPECIFIC_TARGET (expr) = stream_read_tree (ib, data_in); +#endif DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr) = stream_read_tree (ib, data_in); /* If the file contains a function with an EH personality set, --- gcc/lto-opts.c.jj 2015-01-05 13:07:12.000000000 +0100 +++ gcc/lto-opts.c 2015-01-09 12:21:04.203127914 +0100 @@ -160,7 +160,7 @@ lto_write_options (void) "-fno-strict-overflow"); /* Append options from target hook and store them to offload_lto section. */ - if (strcmp (section_name_prefix, OFFLOAD_SECTION_NAME_PREFIX) == 0) + if (lto_stream_offload_p) { char *offload_opts = targetm.offload_options (); char *offload_ptr = offload_opts; @@ -201,7 +201,7 @@ lto_write_options (void) /* Do not store target-specific options in offload_lto section. */ if ((cl_options[option->opt_index].flags & CL_TARGET) - && strcmp (section_name_prefix, OFFLOAD_SECTION_NAME_PREFIX) == 0) + && lto_stream_offload_p) continue; /* Drop options created from the gcc driver that will be rejected @@ -214,8 +214,7 @@ lto_write_options (void) We do not need those. The only exception is -foffload option, if we write it in offload_lto section. Also drop all diagnostic options. */ if ((cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING)) - && (strcmp (section_name_prefix, OFFLOAD_SECTION_NAME_PREFIX) != 0 - || option->opt_index != OPT_foffload_)) + && (!lto_stream_offload_p || option->opt_index != OPT_foffload_)) continue; for (j = 0; j < option->canonical_option_num_elements; ++j) --- gcc/lto/lto.c.jj 2015-01-05 13:07:19.000000000 +0100 +++ gcc/lto/lto.c 2015-01-09 12:21:50.479332868 +0100 @@ -2900,7 +2900,8 @@ read_cgraph_and_symbols (unsigned nfiles timevar_push (TV_IPA_LTO_DECL_IN); #ifdef ACCEL_COMPILER - section_name_prefix = OFFLOAD_SECTION_NAME_PREFIX; + section_name_prefix = OFFLOAD_SECTION_NAME_PREFIX; + lto_stream_offload_p = true; #endif real_file_decl_data Jakub