From patchwork Tue Oct 26 17:05:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 69267 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 5616EB70CD for ; Wed, 27 Oct 2010 04:05:58 +1100 (EST) Received: (qmail 8307 invoked by alias); 26 Oct 2010 17:05:50 -0000 Received: (qmail 8295 invoked by uid 22791); 26 Oct 2010 17:05:47 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Oct 2010 17:05:41 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 8613A9AC78F; Tue, 26 Oct 2010 19:05:39 +0200 (CEST) Date: Tue, 26 Oct 2010 19:05:39 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix minor WHOPR partitioning issue Message-ID: <20101026170539.GE20390@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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 Hi, while looking into other problem I noticed that even with single partition we consider some functions/var to be used by other partition. This is caused by bug in partitioning code that inserts functions with same comdat group twice. Another related problem is with partition_varpool_node_p possibly leading to comdat functions with attribute used to be declared unused. The patch also improves dumping, so we get body availability and other info. Bootstrapped/regtested x86_64-linux, will commit it as obvious. * lto/lto.c (add_cgraph_node_to_partition, add_varpool_node_to_partition): Add debug info. (lto_1_to_1_map, lto_balanced_map): Do not re-add already partitioned nodes. (do_whole_program_analysis): Set function flags before dumping. Index: lto/lto.c =================================================================== --- lto/lto.c (revision 165972) +++ lto/lto.c (working copy) @@ -760,7 +760,12 @@ add_cgraph_node_to_partition (ltrans_par part->insns += node->local.inline_summary.self_size; if (node->aux) - node->in_other_partition = 1; + { + node->in_other_partition = 1; + if (cgraph_dump_file) + fprintf (cgraph_dump_file, "Node %s/%i now used in multiple partitions\n", + cgraph_node_name (node), node->uid); + } node->aux = (void *)((size_t)node->aux + 1); cgraph_node_set_add (part->cgraph_set, node); @@ -785,7 +790,12 @@ add_varpool_node_to_partition (ltrans_pa varpool_node_set_add (part->varpool_set, vnode); if (vnode->aux) - vnode->in_other_partition = 1; + { + vnode->in_other_partition = 1; + if (cgraph_dump_file) + fprintf (cgraph_dump_file, "Varpool node %s now used in multiple partitions\n", + varpool_node_name (vnode)); + } vnode->aux = (void *)((size_t)vnode->aux + 1); add_references_to_partition (part, &vnode->ref_list); @@ -856,6 +866,7 @@ partition_varpool_node_p (struct varpool /* Constant pool and comdat are always only in partitions they are needed. */ if (DECL_IN_CONSTANT_POOL (vnode->decl) || (DECL_COMDAT (vnode->decl) + && !vnode->force_output && !varpool_used_from_object_file_p (vnode))) return false; return true; @@ -911,7 +922,8 @@ lto_1_to_1_map (void) npartitions++; } - add_cgraph_node_to_partition (partition, node); + if (!node->aux) + add_cgraph_node_to_partition (partition, node); } for (vnode = varpool_nodes; vnode; vnode = vnode->next) @@ -930,7 +942,8 @@ lto_1_to_1_map (void) npartitions++; } - add_varpool_node_to_partition (partition, vnode); + if (!vnode->aux) + add_varpool_node_to_partition (partition, vnode); } for (node = cgraph_nodes; node; node = node->next) node->aux = NULL; @@ -1005,6 +1018,8 @@ lto_balanced_map (void) INT_MAX, best_internal = 0; int npartitions; + for (vnode = varpool_nodes; vnode; vnode = vnode->next) + gcc_assert (!vnode->aux); /* Until we have better ordering facility, use toplogical order. Include only nodes we will partition and compute estimate of program size. Note that since nodes that are not partitioned might be put into @@ -1034,7 +1049,8 @@ lto_balanced_map (void) for (i = 0; i < n_nodes; i++) { - add_cgraph_node_to_partition (partition, order[i]); + if (!order[i]->aux) + add_cgraph_node_to_partition (partition, order[i]); total_size -= order[i]->global.size; /* Once we added a new node to the partition, we also want to add @@ -1198,8 +1214,8 @@ lto_balanced_map (void) best_total_size = total_size; } if (cgraph_dump_file) - fprintf (cgraph_dump_file, "Step %i: added %s, size %i, cost %i/%i best %i/%i, step %i\n", i, - cgraph_node_name (order[i]), partition->insns, cost, internal, + fprintf (cgraph_dump_file, "Step %i: added %s/%i, size %i, cost %i/%i best %i/%i, step %i\n", i, + cgraph_node_name (order[i]), order[i]->uid, partition->insns, cost, internal, best_cost, best_internal, best_i); /* Partition is too large, unwind into step when best cost was reached and start new partition. */ @@ -2314,13 +2330,13 @@ do_whole_program_analysis (void) dump_memory_report (false); } + cgraph_function_flags_ready = true; + if (cgraph_dump_file) { dump_cgraph (cgraph_dump_file); dump_varpool (cgraph_dump_file); } - - cgraph_function_flags_ready = true; bitmap_obstack_initialize (NULL); ipa_register_cgraph_hooks (); cgraph_state = CGRAPH_STATE_IPA_SSA;