From patchwork Thu Oct 13 01:09:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 119337 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 15033B6F75 for ; Thu, 13 Oct 2011 12:10:25 +1100 (EST) Received: (qmail 30480 invoked by alias); 13 Oct 2011 01:10:21 -0000 Received: (qmail 30460 invoked by uid 22791); 13 Oct 2011 01:10:19 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Oct 2011 01:10:03 +0000 Received: from hpaq5.eem.corp.google.com (hpaq5.eem.corp.google.com [172.25.149.5]) by smtp-out.google.com with ESMTP id p9D1A0VV023815; Wed, 12 Oct 2011 18:10:00 -0700 Received: from tobiano.tor.corp.google.com (tobiano.tor.corp.google.com [172.29.41.6]) by hpaq5.eem.corp.google.com with ESMTP id p9D19xi0027135; Wed, 12 Oct 2011 18:09:59 -0700 Received: by tobiano.tor.corp.google.com (Postfix, from userid 54752) id 885BFAE1DD; Wed, 12 Oct 2011 21:09:58 -0400 (EDT) To: reply@codereview.appspotmail.com, rguenther@suse.de, gcc-patches@gcc.gnu.org Subject: [lto] Factor out code for streaming struct function. (issue5253051) Message-Id: <20111013010958.885BFAE1DD@tobiano.tor.corp.google.com> Date: Wed, 12 Oct 2011 21:09:58 -0400 (EDT) From: dnovillo@google.com (Diego Novillo) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The pph branch also needs to stream struct function objects, but it doesn't need to stream things like SSA names and the other data processed by output_function/input_function. This patch factors out the common code into separate functions. I've made them static for now, since no other external code calls it yet. This will minimize differences between pph and trunk. Tested on x86_64 with LTO profiled bootstrap. Barring any objections, I'll commit this to trunk in the next couple of days. Diego. 2011-10-12 Lawrence Crowl Diego Novillo * lto-streamer-in.c (input_struct_function_base): Factor out of ... (input_function): ... here. * lto-streamer-out.c (output_struct_function_base): Factor out of ... (output_function): ... here. --- This patch is available for review at http://codereview.appspot.com/5253051 diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index f18b944..1847738 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -764,27 +764,40 @@ fixup_call_stmt_edges (struct cgraph_node *orig, gimple *stmts) } } -/* Read the body of function FN_DECL from DATA_IN using input block IB. */ + +/* Input the base body of struct function FN from DATA_IN + using input block IB. */ static void -input_function (tree fn_decl, struct data_in *data_in, - struct lto_input_block *ib) +input_struct_function_base (struct function *fn, struct data_in *data_in, + struct lto_input_block *ib) { - struct function *fn; - enum LTO_tags tag; - gimple *stmts; - basic_block bb; struct bitpack_d bp; - struct cgraph_node *node; - tree args, narg, oarg; int len; - fn = DECL_STRUCT_FUNCTION (fn_decl); - tag = streamer_read_record_start (ib); - clear_line_info (data_in); + /* Read the static chain and non-local goto save area. */ + fn->static_chain_decl = stream_read_tree (ib, data_in); + fn->nonlocal_goto_save_area = stream_read_tree (ib, data_in); - gimple_register_cfg_hooks (); - lto_tag_check (tag, LTO_function); + /* Read all the local symbols. */ + len = streamer_read_hwi (ib); + if (len > 0) + { + int i; + VEC_safe_grow (tree, gc, fn->local_decls, len); + for (i = 0; i < len; i++) + { + tree t = stream_read_tree (ib, data_in); + VEC_replace (tree, fn->local_decls, i, t); + } + } + + /* Input the function start and end loci. */ + fn->function_start_locus = lto_input_location (ib, data_in); + fn->function_end_locus = lto_input_location (ib, data_in); + + /* Input the current IL state of the function. */ + fn->curr_properties = streamer_read_uhwi (ib); /* Read all the attributes for FN. */ bp = streamer_read_bitpack (ib); @@ -802,30 +815,30 @@ input_function (tree fn_decl, struct data_in *data_in, fn->calls_setjmp = bp_unpack_value (&bp, 1); fn->va_list_fpr_size = bp_unpack_value (&bp, 8); fn->va_list_gpr_size = bp_unpack_value (&bp, 8); +} - /* Input the function start and end loci. */ - fn->function_start_locus = lto_input_location (ib, data_in); - fn->function_end_locus = lto_input_location (ib, data_in); - /* Input the current IL state of the function. */ - fn->curr_properties = streamer_read_uhwi (ib); +/* Read the body of function FN_DECL from DATA_IN using input block IB. */ - /* Read the static chain and non-local goto save area. */ - fn->static_chain_decl = stream_read_tree (ib, data_in); - fn->nonlocal_goto_save_area = stream_read_tree (ib, data_in); +static void +input_function (tree fn_decl, struct data_in *data_in, + struct lto_input_block *ib) +{ + struct function *fn; + enum LTO_tags tag; + gimple *stmts; + basic_block bb; + struct cgraph_node *node; + tree args, narg, oarg; - /* Read all the local symbols. */ - len = streamer_read_hwi (ib); - if (len > 0) - { - int i; - VEC_safe_grow (tree, gc, fn->local_decls, len); - for (i = 0; i < len; i++) - { - tree t = stream_read_tree (ib, data_in); - VEC_replace (tree, fn->local_decls, i, t); - } - } + fn = DECL_STRUCT_FUNCTION (fn_decl); + tag = streamer_read_record_start (ib); + clear_line_info (data_in); + + gimple_register_cfg_hooks (); + lto_tag_check (tag, LTO_function); + + input_struct_function_base (fn, data_in, ib); /* Read all function arguments. We need to re-map them here to the arguments of the merged function declaration. */ diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 4d88f62..1ae4a4b 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -719,36 +719,30 @@ produce_asm (struct output_block *ob, tree fn) } -/* Output the body of function NODE->DECL. */ +/* Output the base body of struct function FN using output block OB. */ -static void -output_function (struct cgraph_node *node) +void +output_struct_function_base (struct output_block *ob, struct function *fn) { struct bitpack_d bp; - tree function; - struct function *fn; - basic_block bb; - struct output_block *ob; unsigned i; tree t; - function = node->decl; - fn = DECL_STRUCT_FUNCTION (function); - ob = create_output_block (LTO_section_function_body); - - clear_line_info (ob); - ob->cgraph_node = node; - - gcc_assert (current_function_decl == NULL_TREE && cfun == NULL); + /* Output the static chain and non-local goto save area. */ + stream_write_tree (ob, fn->static_chain_decl, true); + stream_write_tree (ob, fn->nonlocal_goto_save_area, true); - /* Set current_function_decl and cfun. */ - current_function_decl = function; - push_cfun (fn); + /* Output all the local variables in the function. */ + streamer_write_hwi (ob, VEC_length (tree, fn->local_decls)); + FOR_EACH_VEC_ELT (tree, fn->local_decls, i, t) + stream_write_tree (ob, t, true); - /* Make string 0 be a NULL string. */ - streamer_write_char_stream (ob->string_stream, 0); + /* Output the function start and end loci. */ + lto_output_location (ob, fn->function_start_locus); + lto_output_location (ob, fn->function_end_locus); - streamer_write_record_start (ob, LTO_function); + /* Output current IL state of the function. */ + streamer_write_uhwi (ob, fn->curr_properties); /* Write all the attributes for FN. */ bp = bitpack_create (ob->main_stream); @@ -767,22 +761,38 @@ output_function (struct cgraph_node *node) bp_pack_value (&bp, fn->va_list_fpr_size, 8); bp_pack_value (&bp, fn->va_list_gpr_size, 8); streamer_write_bitpack (&bp); +} - /* Output the function start and end loci. */ - lto_output_location (ob, fn->function_start_locus); - lto_output_location (ob, fn->function_end_locus); - /* Output current IL state of the function. */ - streamer_write_uhwi (ob, fn->curr_properties); +/* Output the body of function NODE->DECL. */ - /* Output the static chain and non-local goto save area. */ - stream_write_tree (ob, fn->static_chain_decl, true); - stream_write_tree (ob, fn->nonlocal_goto_save_area, true); +static void +output_function (struct cgraph_node *node) +{ + tree function; + struct function *fn; + basic_block bb; + struct output_block *ob; - /* Output all the local variables in the function. */ - streamer_write_hwi (ob, VEC_length (tree, fn->local_decls)); - FOR_EACH_VEC_ELT (tree, fn->local_decls, i, t) - stream_write_tree (ob, t, true); + function = node->decl; + fn = DECL_STRUCT_FUNCTION (function); + ob = create_output_block (LTO_section_function_body); + + clear_line_info (ob); + ob->cgraph_node = node; + + gcc_assert (current_function_decl == NULL_TREE && cfun == NULL); + + /* Set current_function_decl and cfun. */ + current_function_decl = function; + push_cfun (fn); + + /* Make string 0 be a NULL string. */ + streamer_write_char_stream (ob->string_stream, 0); + + streamer_write_record_start (ob, LTO_function); + + output_struct_function_base (ob, fn); /* Output the head of the arguments list. */ stream_write_tree (ob, DECL_ARGUMENTS (function), true);