diff options
author | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-07-07 21:43:41 -0300 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-07-07 21:43:41 -0300 |
commit | 79e10e02f1f0dfe39061660c945d48995df3f3f3 (patch) | |
tree | 92b07059939bd95c8ad0dd945520ad09af939d46 /gcc | |
parent | 0db25c6846b063dbd3c140793b7aa246f02a1400 (diff) | |
download | gcc-79e10e02f1f0dfe39061660c945d48995df3f3f3.zip gcc-79e10e02f1f0dfe39061660c945d48995df3f3f3.tar.gz gcc-79e10e02f1f0dfe39061660c945d48995df3f3f3.tar.bz2 |
Fix ipa-cp and ipa-profile failed assertions.
This commit fixes issues with ipa-cp and ipa-profile that was disabled
before by expanding the LTRANS boundary, as implemented in
lto_apply_partition_mask.
gcc/ChangeLog:
2020-07-07 Giuliano Belinassi <giuliano.belinassi@usp.br>
* ipa-cp.c (initialize_node_lattices): Uncoment `gcc_unreachable'.
* ipa-profile.c (ipa_propagate_frequency): Uncoment assert.
* lto-cgraph.c (handle_node_in_boundary): New function.
* (lto_apply_partition_mask): Remove call to remove_unreachable_nodes,
and expand LTRANS boundary based on partitioned nodes.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ipa-cp.c | 4 | ||||
-rw-r--r-- | gcc/ipa-profile.c | 2 | ||||
-rw-r--r-- | gcc/lto-cgraph.c | 121 |
4 files changed, 76 insertions, 60 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 98d66bd..1909efb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2020-07-07 Giuliano Belinassi <giuliano.belinassi@usp.br> + * ipa-cp.c (initialize_node_lattices): Uncoment `gcc_unreachable'. + * ipa-profile.c (ipa_propagate_frequency): Uncoment assert. + * lto-cgraph.c (handle_node_in_boundary): New function. + * (lto_apply_partition_mask): Remove call to remove_unreachable_nodes, + and expand LTRANS boundary based on partitioned nodes. + +2020-07-07 Giuliano Belinassi <giuliano.belinassi@usp.br> + * cgraphunit.c (ipa_passes): Quick switch between promote statics and balance. * ipa-sra.c (gate): Disable it for split_outputs. @@ -16,7 +24,6 @@ * tree.c (filter_name): New function. (get_file_function_name): Filter buf so that it do not confuse ld. - 2020-07-02 Giuliano Belinassi <giuliano.belinassi@usp.br> * cgraphunit.c (ipa_passes): Update ipa_passes. diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 9915bf6..c64e910 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1195,7 +1195,7 @@ initialize_node_lattices (struct cgraph_node *node) int caller_count = 0; node->call_for_symbol_thunks_and_aliases (count_callers, &caller_count, true); - //gcc_checking_assert (caller_count > 0); + gcc_checking_assert (caller_count > 0); if (caller_count == 1) node->call_for_symbol_thunks_and_aliases (set_single_call_flag, NULL, true); @@ -1733,7 +1733,7 @@ ipcp_verify_propagated_values (void) print_all_lattices (dump_file, true, false); } - //gcc_unreachable (); + gcc_unreachable (); } } } diff --git a/gcc/ipa-profile.c b/gcc/ipa-profile.c index 22a2689..9fbfa90 100644 --- a/gcc/ipa-profile.c +++ b/gcc/ipa-profile.c @@ -653,7 +653,7 @@ ipa_propagate_frequency (struct cgraph_node *node) || (opt_for_fn (node->decl, flag_devirtualize) && DECL_VIRTUAL_P (node->decl))) return false; - //gcc_assert (node->analyzed); + gcc_assert (node->analyzed); if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Processing frequency %s\n", node->dump_name ()); diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index 8469d5b..0029588 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -2061,6 +2061,48 @@ input_cgraph_opt_summary (vec<symtab_node *> nodes) } } +/* Handle node that are in the LTRANS boundary, releasing its body and + other informations. */ + +static void +handle_node_in_boundary (symtab_node *node) +{ + cgraph_node *cnode = dyn_cast <cgraph_node *> (node); + varpool_node *vnode = dyn_cast <varpool_node *> (node); + if (cnode) + { + cnode->maybe_release_dominators (); + + if (cnode->clone_of) + cnode->remove_from_clone_tree (); + + if (cnode->has_gimple_body_p ()) + { + cnode->remove_callees (); + cnode->remove_all_references (); + cnode->release_body (); + cnode->body_removed = true; + cnode->analyzed = false; + cnode->definition = false; + cnode->cpp_implicit_alias = false; + cnode->alias = false; + cnode->transparent_alias = false; + cnode->thunk.thunk_p = false; + cnode->weakref = false; + /* After early inlining we drop always_inline attributes on + bodies of functions that are still referenced (have their + address taken). */ + DECL_ATTRIBUTES (cnode->decl) + = remove_attribute ("always_inline", + DECL_ATTRIBUTES (node->decl)); + + cnode->in_other_partition = true; + } + } + else if (vnode && !DECL_EXTERNAL (vnode->decl)) + vnode->in_other_partition = true; +} + /* Replace the partition in the symbol table, removing every node which is not in partition. */ @@ -2070,7 +2112,6 @@ lto_apply_partition_mask (ltrans_partition partition) vec<lto_encoder_entry> &nodes = partition->encoder->nodes; symtab_node *node; auto_vec<symtab_node *, 16> mark_to_remove; - auto_vec<symtab_node *, 16> force_output_enabled; unsigned int i; FOR_EACH_SYMBOL (node) @@ -2082,57 +2123,36 @@ lto_apply_partition_mask (ltrans_partition partition) node->aux2 = 1; if (!nodes[i].in_partition) - { - cgraph_node *cnode = dyn_cast <cgraph_node *> (node); - varpool_node *vnode = dyn_cast <varpool_node *> (node); - if (cnode) - { - cnode->maybe_release_dominators (); - - if (cnode->clone_of) - cnode->remove_from_clone_tree (); - - if (cnode->has_gimple_body_p ()) - { - cnode->remove_callees (); - cnode->remove_all_references (); - cnode->release_body (); - cnode->body_removed = true; - cnode->analyzed = false; - cnode->definition = false; - cnode->cpp_implicit_alias = false; - cnode->alias = false; - cnode->transparent_alias = false; - cnode->thunk.thunk_p = false; - cnode->weakref = false; - /* After early inlining we drop always_inline attributes on - bodies of functions that are still referenced (have their - address taken). */ - DECL_ATTRIBUTES (cnode->decl) - = remove_attribute ("always_inline", - DECL_ATTRIBUTES (node->decl)); - - cnode->in_other_partition = true; - } - } - else if (vnode && !DECL_EXTERNAL (vnode->decl)) - vnode->in_other_partition = true; - } + handle_node_in_boundary (node); } for (i = 0; i < nodes.length (); i++) { symtab_node *node = nodes[i].node; + bool in_partition = nodes[i].in_partition; - /* Temporarly set force output to avoid incorrect removal of node. */ - if (node->force_output) - force_output_enabled.safe_push (node); - else - node->force_output = true; + /* Expand boundary a little more to avoid issues with ipa-cp. */ + if (in_partition) + { + if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node)) + if (cnode->local) + for (cgraph_edge *e = cnode->callers; e; e = e->next_caller) + { + if (e->caller->get_partitioning_class () == SYMBOL_PARTITION) + { + if (e->caller->aux2 == 0 && e->caller->has_gimple_body_p ()) + { + bool in_other_partition = node->in_other_partition; + handle_node_in_boundary (node); + node->in_other_partition = in_other_partition; + } + } + e->caller->aux2 = 1; + } - /* Handle Schrondiger nodes that are and are not in the partition. */ - if (nodes[i].in_partition) - node->in_other_partition = false; + /* Handle Schrondiger nodes that are and are not in the partition. */ + node->in_other_partition = false; + } } FOR_EACH_SYMBOL (node) @@ -2149,15 +2169,4 @@ lto_apply_partition_mask (ltrans_partition partition) node->remove (); } - - symtab->remove_unreachable_nodes (NULL); - - FOR_EACH_SYMBOL (node) - node->force_output = false; - - for (i = 0; i < force_output_enabled.length (); ++i) - { - symtab_node *node = force_output_enabled[i]; - node->force_output = true; - } } |