On 11/20/18 11:58 AM, Martin Liška wrote: > On 10/3/18 11:23 AM, Martin Liška wrote: >> On 9/25/18 8:48 AM, Martin Liška wrote: >>> Hi. >>> >>> One more tested patch. >>> >>> Martin >>> >> >> One more tested patch. >> >> Martin >> > > Hi. > > One another tested patch that I'm going to install. > > Martin >
Hi. Another 2 patches that I've just tested and will install. Martin
>From 65c43b0a4fb210485ad01d5f55573bfc0f17441d Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Mon, 11 Feb 2019 08:13:03 +0000 Subject: [PATCH 1/2] Backport r268762 gcc/ChangeLog: 2019-02-11 Martin Liska <mli...@suse.cz> PR ipa/89009 * ipa-cp.c (build_toporder_info): Remove usage of a param. * ipa-inline.c (inline_small_functions): Likewise. * ipa-pure-const.c (propagate_pure_const): Likewise. (propagate_nothrow): Likewise. * ipa-reference.c (propagate): Likewise. * ipa-utils.c (struct searchc_env): Remove unused field. (searchc): Always search across AVAIL_INTERPOSABLE. (ipa_reduced_postorder): Always allow AVAIL_INTERPOSABLE as the only called IPA pure const can properly not propagate across interposable boundary. * ipa-utils.h (ipa_reduced_postorder): Remove param. gcc/testsuite/ChangeLog: 2019-02-11 Martin Liska <mli...@suse.cz> PR ipa/89009 * g++.dg/ipa/pr89009.C: New test. --- gcc/ipa-cp.c | 2 +- gcc/ipa-inline.c | 2 +- gcc/ipa-pure-const.c | 4 ++-- gcc/ipa-reference.c | 2 +- gcc/ipa-utils.c | 9 +++------ gcc/ipa-utils.h | 2 +- gcc/testsuite/g++.dg/ipa/pr89009.C | 12 ++++++++++++ 7 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ipa/pr89009.C diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index e868b9c2623..5bd4df0ecb7 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -820,7 +820,7 @@ build_toporder_info (struct ipa_topo_info *topo) topo->stack = XCNEWVEC (struct cgraph_node *, symtab->cgraph_count); gcc_checking_assert (topo->stack_top == 0); - topo->nnodes = ipa_reduced_postorder (topo->order, true, true, NULL); + topo->nnodes = ipa_reduced_postorder (topo->order, true, NULL); } /* Free information about strongly connected components and the arrays in diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 996b04cb81d..bde7ecfd0d5 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -1759,7 +1759,7 @@ inline_small_functions (void) metrics. */ max_count = profile_count::uninitialized (); - ipa_reduced_postorder (order, true, true, NULL); + ipa_reduced_postorder (order, true, NULL); free (order); FOR_EACH_DEFINED_FUNCTION (node) diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index a80b6845633..d36d1ba9b73 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -1443,7 +1443,7 @@ propagate_pure_const (void) bool remove_p = false; bool has_cdtor; - order_pos = ipa_reduced_postorder (order, true, false, + order_pos = ipa_reduced_postorder (order, true, ignore_edge_for_pure_const); if (dump_file) { @@ -1773,7 +1773,7 @@ propagate_nothrow (void) int i; struct ipa_dfs_info * w_info; - order_pos = ipa_reduced_postorder (order, true, false, + order_pos = ipa_reduced_postorder (order, true, ignore_edge_for_nothrow); if (dump_file) { diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c index 6490c03f8d0..b9db61697d1 100644 --- a/gcc/ipa-reference.c +++ b/gcc/ipa-reference.c @@ -728,7 +728,7 @@ propagate (void) the global information. All the nodes within a cycle will have the same info so we collapse cycles first. Then we can do the propagation in one pass from the leaves to the roots. */ - order_pos = ipa_reduced_postorder (order, true, true, ignore_edge_p); + order_pos = ipa_reduced_postorder (order, true, ignore_edge_p); if (dump_file) ipa_print_order (dump_file, "reduced", order, order_pos); diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c index a271bb822cb..106d3079391 100644 --- a/gcc/ipa-utils.c +++ b/gcc/ipa-utils.c @@ -63,7 +63,6 @@ struct searchc_env { int order_pos; splay_tree nodes_marked_new; bool reduce; - bool allow_overwritable; int count; }; @@ -105,7 +104,7 @@ searchc (struct searchc_env* env, struct cgraph_node *v, if (w->aux && (avail > AVAIL_INTERPOSABLE - || (env->allow_overwritable && avail == AVAIL_INTERPOSABLE))) + || avail == AVAIL_INTERPOSABLE)) { w_info = (struct ipa_dfs_info *) w->aux; if (w_info->new_node) @@ -162,7 +161,7 @@ searchc (struct searchc_env* env, struct cgraph_node *v, int ipa_reduced_postorder (struct cgraph_node **order, - bool reduce, bool allow_overwritable, + bool reduce, bool (*ignore_edge) (struct cgraph_edge *)) { struct cgraph_node *node; @@ -175,15 +174,13 @@ ipa_reduced_postorder (struct cgraph_node **order, env.nodes_marked_new = splay_tree_new (splay_tree_compare_ints, 0, 0); env.count = 1; env.reduce = reduce; - env.allow_overwritable = allow_overwritable; FOR_EACH_DEFINED_FUNCTION (node) { enum availability avail = node->get_availability (); if (avail > AVAIL_INTERPOSABLE - || (allow_overwritable - && (avail == AVAIL_INTERPOSABLE))) + || avail == AVAIL_INTERPOSABLE) { /* Reuse the info if it is already there. */ struct ipa_dfs_info *info = (struct ipa_dfs_info *) node->aux; diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h index 1609ac14d7f..e247d63fd7e 100644 --- a/gcc/ipa-utils.h +++ b/gcc/ipa-utils.h @@ -36,7 +36,7 @@ struct ipa_dfs_info { /* In ipa-utils.c */ void ipa_print_order (FILE*, const char *, struct cgraph_node**, int); -int ipa_reduced_postorder (struct cgraph_node **, bool, bool, +int ipa_reduced_postorder (struct cgraph_node **, bool, bool (*ignore_edge) (struct cgraph_edge *)); void ipa_free_postorder_info (void); vec<cgraph_node *> ipa_get_nodes_in_cycle (struct cgraph_node *); diff --git a/gcc/testsuite/g++.dg/ipa/pr89009.C b/gcc/testsuite/g++.dg/ipa/pr89009.C new file mode 100644 index 00000000000..6b4fc65a641 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr89009.C @@ -0,0 +1,12 @@ +/* PR ipa/89009 */ +/* { dg-do run } */ +/* { dg-options "-fvisibility=hidden -fpic -O2 -fno-inline" } */ + +#pragma GCC visibility push(default) +void foo1() { __builtin_printf ("foo\n"); } +#pragma GCC visibility pop +void foo2() { __builtin_printf ("foo\n"); } + +int main() { foo2(); return 0; } + +/* { dg-output "foo" } */ -- 2.20.1
>From 947e8b02e187f56873b9cce665603fbc5815b6c8 Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 13 Feb 2019 06:57:38 +0000 Subject: [PATCH 2/2] Backport r268835 gcc/ChangeLog: 2019-02-13 Martin Liska <mli...@suse.cz> PR lto/88858 * cfgrtl.c (remove_barriers_from_footer): New function. (try_redirect_by_replacing_jump): Use it. (cfg_layout_redirect_edge_and_branch): Likewise. --- gcc/cfgrtl.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index 7af4191da77..f6e4fecd647 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -984,6 +984,31 @@ block_label (basic_block block) return as_a <rtx_code_label *> (BB_HEAD (block)); } +/* Remove all barriers from BB_FOOTER of a BB. */ + +static void +remove_barriers_from_footer (basic_block bb) +{ + rtx_insn *insn = BB_FOOTER (bb); + + /* Remove barriers but keep jumptables. */ + while (insn) + { + if (BARRIER_P (insn)) + { + if (PREV_INSN (insn)) + SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); + else + BB_FOOTER (bb) = NEXT_INSN (insn); + if (NEXT_INSN (insn)) + SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); + } + if (LABEL_P (insn)) + return; + insn = NEXT_INSN (insn); + } +} + /* Attempt to perform edge redirection by replacing possibly complex jump instruction by unconditional jump or removing jump completely. This can apply only if all edges now point to the same block. The parameters and @@ -1047,26 +1072,8 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) /* Selectively unlink whole insn chain. */ if (in_cfglayout) { - rtx_insn *insn = BB_FOOTER (src); - delete_insn_chain (kill_from, BB_END (src), false); - - /* Remove barriers but keep jumptables. */ - while (insn) - { - if (BARRIER_P (insn)) - { - if (PREV_INSN (insn)) - SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); - else - BB_FOOTER (src) = NEXT_INSN (insn); - if (NEXT_INSN (insn)) - SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); - } - if (LABEL_P (insn)) - break; - insn = NEXT_INSN (insn); - } + remove_barriers_from_footer (src); } else delete_insn_chain (kill_from, PREV_INSN (BB_HEAD (target)), @@ -4379,6 +4386,7 @@ cfg_layout_redirect_edge_and_branch (edge e, basic_block dest) "Removing crossing jump while redirecting edge form %i to %i\n", e->src->index, dest->index); delete_insn (BB_END (src)); + remove_barriers_from_footer (src); e->flags |= EDGE_FALLTHRU; } -- 2.20.1