This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix handling of DECL_EXTERNAL in partitioning


On Tue, May 11, 2010 at 4:14 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> eon and xalanbmk breaks with -fwhopr because we incorrectly decide to bring
> hidden DECL_EXTERNAL functions. ?This patch also fixes some of confused checks
> in lto_1_to_1_map I noticed while looking into the problem and unifies common
> code in reachable_from_other_partition_p (there was other confused check
> concerning inline clones in lto_output_node).
>
> We are still wrong WRT attribute ((used)) and asm statements. ?I will try to
> look into that next, that one should be even possible to write simple testcase
> for :)
>
> Bootstrapped/regtested x86_64-linux, OK?

Ok.

Thanks,
Richard.

> ? ? ? ?* lto-cgraph.c (reachable_from_other_partition_p): Export; do not assume
> ? ? ? ?that if function is needed it is reachable.
> ? ? ? ?(lto_output_node): See if it the function is reachable or referenced.
> ? ? ? ?(output_cgraph): Update call of lto_output_node.
> ? ? ? ?* lto-streamer.h (reachable_from_other_partition_p): Declare.
>
> ? ? ? ?* lto.c (lto_1_to_1_map): Remove some no longer needed checks.
> ? ? ? ?(lto_promote_cross_file_statics): Never promote DECL_EXTERNAL;
> ? ? ? ?use reachable_from_other_partition_p and
> ? ? ? ?referenced_from_other_partition_p test.
>
> Index: lto-cgraph.c
> ===================================================================
> --- lto-cgraph.c ? ? ? ?(revision 159269)
> +++ lto-cgraph.c ? ? ? ?(working copy)
> @@ -312,12 +327,10 @@ referenced_from_other_partition_p (struc
>
> ?/* Return true when node is reachable from other partition. ?*/
>
> -static bool
> +bool
> ?reachable_from_other_partition_p (struct cgraph_node *node, cgraph_node_set set)
> ?{
> ? struct cgraph_edge *e;
> - ?if (node->needed)
> - ? ?return true;
> ? if (!node->analyzed)
> ? ? return false;
> ? if (node->global.inlined_to)
> @@ -339,6 +352,7 @@ reachable_from_other_partition_p (struct
> ?static void
> ?lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
> ? ? ? ? ? ? ? ? lto_cgraph_encoder_t encoder, cgraph_node_set set,
> + ? ? ? ? ? ? ? ?varpool_node_set vset,
> ? ? ? ? ? ? ? ? bitmap written_decls)
> ?{
> ? unsigned int tag;
> @@ -400,7 +414,9 @@ lto_output_node (struct lto_simple_outpu
> ? bp_pack_value (bp, node->address_taken, 1);
> ? bp_pack_value (bp, node->abstract_and_needed, 1);
> ? bp_pack_value (bp, tag == LTO_cgraph_analyzed_node
> - ? ? ? ? ? ? ? ?&& reachable_from_other_partition_p (node, set), 1);
> + ? ? ? ? ? ? ? ?&& !DECL_EXTERNAL (node->decl)
> + ? ? ? ? ? ? ? ?&& (reachable_from_other_partition_p (node, set)
> + ? ? ? ? ? ? ? ? ? ?|| referenced_from_other_partition_p (&node->ref_list, set, vset)), 1);
> ? bp_pack_value (bp, node->lowered, 1);
> ? bp_pack_value (bp, in_other_partition, 1);
> ? bp_pack_value (bp, node->alias, 1);
> @@ -767,7 +783,7 @@ output_cgraph (cgraph_node_set set, varp
> ? for (i = 0; i < n_nodes; i++)
> ? ? {
> ? ? ? node = lto_cgraph_encoder_deref (encoder, i);
> - ? ? ?lto_output_node (ob, node, encoder, set, written_decls);
> + ? ? ?lto_output_node (ob, node, encoder, set, vset, written_decls);
> ? ? }
>
> ? lto_bitmap_free (written_decls);
> Index: lto/lto.c
> ===================================================================
> --- lto/lto.c ? (revision 159269)
> +++ lto/lto.c ? (working copy)
> @@ -556,13 +556,11 @@ lto_1_to_1_map (void)
> ? ? ? if (node->global.inlined_to || node->clone_of)
> ? ? ? ?continue;
> ? ? ? /* Nodes without a body do not need partitioning. ?*/
> - ? ? ?if (!node->analyzed || node->same_body_alias)
> + ? ? ?if (!node->analyzed)
> ? ? ? ?continue;
> - ? ? ?/* We only need to partition the nodes that we read from the
> - ? ? ? ?gimple bytecode files. ?*/
> +
> ? ? ? file_data = node->local.lto_file_data;
> - ? ? ?if (file_data == NULL)
> - ? ? ? continue;
> + ? ? ?gcc_assert (!node->same_body_alias && file_data);
>
> ? ? ? slot = pointer_map_contains (pmap, file_data);
> ? ? ? if (slot)
> @@ -735,22 +733,13 @@ lto_promote_cross_file_statics (void)
> ? ? ? for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
> ? ? ? ?{
> ? ? ? ? ?struct cgraph_node *node = csi_node (csi);
> - ? ? ? ? bool globalize = node->local.vtable_method;
> - ? ? ? ? struct cgraph_edge *e;
> ? ? ? ? ?if (node->local.externally_visible)
> ? ? ? ? ? ?continue;
> - ? ? ? ? if (!globalize
> - ? ? ? ? ? ? && referenced_from_other_partition_p (&node->ref_list, set, vset))
> - ? ? ? ? ? globalize = true;
> - ? ? ? ? for (e = node->callers; e && !globalize; e = e->next_caller)
> - ? ? ? ? ? {
> - ? ? ? ? ? ? struct cgraph_node *caller = e->caller;
> - ? ? ? ? ? ? if (caller->global.inlined_to)
> - ? ? ? ? ? ? ? caller = caller->global.inlined_to;
> - ? ? ? ? ? ? if (!cgraph_node_in_set_p (caller, set))
> - ? ? ? ? ? ? ? globalize = true;
> - ? ? ? ? ? }
> - ? ? ? ? if (globalize)
> + ? ? ? ? if (node->clone_of || node->global.inlined_to)
> + ? ? ? ? ? continue;
> + ? ? ? ? if (!DECL_EXTERNAL (node->decl)
> + ? ? ? ? ? ? && (referenced_from_other_partition_p (&node->ref_list, set, vset)
> + ? ? ? ? ? ? ? ? || reachable_from_other_partition_p (node, set)))
> ? ? ? ? ? ? {
> ? ? ? ? ? ? ? ?gcc_assert (flag_wpa);
> ? ? ? ? ? ? ? ?TREE_PUBLIC (node->decl) = 1;
> Index: lto-streamer.h
> ===================================================================
> --- lto-streamer.h ? ? ?(revision 159269)
> +++ lto-streamer.h ? ? ?(working copy)
> @@ -863,6 +863,8 @@ void input_cgraph (void);
> ?bool referenced_from_other_partition_p (struct ipa_ref_list *,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?cgraph_node_set,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?varpool_node_set vset);
> +bool reachable_from_other_partition_p (struct cgraph_node *,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?cgraph_node_set);
>
>
> ?/* In lto-symtab.c. ?*/
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]