aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2019-01-26 23:19:17 +0100
committerMartin Jambor <jamborm@gcc.gnu.org>2019-01-26 23:19:17 +0100
commit95a2ed0325864069bb0368d75bcf85a8b22c4127 (patch)
tree04c852d893bcc50234c3b2bead6edb14dabc70bd /gcc/tree-inline.c
parente4e13e261060dde55de4f7135fe09a816a51f929 (diff)
downloadgcc-95a2ed0325864069bb0368d75bcf85a8b22c4127.zip
gcc-95a2ed0325864069bb0368d75bcf85a8b22c4127.tar.gz
gcc-95a2ed0325864069bb0368d75bcf85a8b22c4127.tar.bz2
[PR ipa/88933] Careful CFG cleanup in IPA-CP function transformation
2019-01-26 Martin Jambor <mjambor@suse.cz> PR ipa/88933 * tree-inline.c: Include tree-cfgcleanup.h. (delete_unreachable_blocks_update_callgraph): Move... * tree-cfgcleanup.c (delete_unreachable_blocks_update_callgraph): ...here, make externally visible, make second argument bool, adjust all callers. * tree-cfgcleanup.c: Include cgraph.h. * tree-cfgcleanup.h (delete_unreachable_blocks_update_callgraph): Declare. * ipa-prop.c: Include tree-cfgcleanup.h. (ipcp_transform_function): Call delete_unreachable_blocks_update_callgraph instead of cleaning uo CFG. testsuite/ * gfortran.dg/gomp/pr88933.f90: New test. From-SVN: r268305
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r--gcc/tree-inline.c80
1 files changed, 4 insertions, 76 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index eb5073c..5c0c4c5 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -60,6 +60,7 @@ along with GCC; see the file COPYING3. If not see
#include "stringpool.h"
#include "attribs.h"
#include "sreal.h"
+#include "tree-cfgcleanup.h"
/* I'm not real happy about this, but we need to handle gimple and
non-gimple trees. */
@@ -132,7 +133,6 @@ static tree copy_decl_to_var (tree, copy_body_data *);
static tree copy_result_decl_to_var (tree, copy_body_data *);
static tree copy_decl_maybe_to_var (tree, copy_body_data *);
static gimple_seq remap_gimple_stmt (gimple *, copy_body_data *);
-static bool delete_unreachable_blocks_update_callgraph (copy_body_data *id);
static void insert_init_stmt (copy_body_data *, basic_block, gimple *);
/* Insert a tree->tree mapping for ID. Despite the name suggests
@@ -5124,7 +5124,8 @@ optimize_inline_calls (tree fn)
/* Renumber the lexical scoping (non-code) blocks consecutively. */
number_blocks (fn);
- delete_unreachable_blocks_update_callgraph (&id);
+ delete_unreachable_blocks_update_callgraph (id.dst_node, false);
+
if (flag_checking)
id.dst_node->verify ();
@@ -5708,79 +5709,6 @@ tree_versionable_function_p (tree fndecl)
&& copy_forbidden (DECL_STRUCT_FUNCTION (fndecl)) == NULL);
}
-/* Delete all unreachable basic blocks and update callgraph.
- Doing so is somewhat nontrivial because we need to update all clones and
- remove inline function that become unreachable. */
-
-static bool
-delete_unreachable_blocks_update_callgraph (copy_body_data *id)
-{
- bool changed = false;
- basic_block b, next_bb;
-
- find_unreachable_blocks ();
-
- /* Delete all unreachable basic blocks. */
-
- for (b = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb; b
- != EXIT_BLOCK_PTR_FOR_FN (cfun); b = next_bb)
- {
- next_bb = b->next_bb;
-
- if (!(b->flags & BB_REACHABLE))
- {
- gimple_stmt_iterator bsi;
-
- for (bsi = gsi_start_bb (b); !gsi_end_p (bsi); gsi_next (&bsi))
- {
- struct cgraph_edge *e;
- struct cgraph_node *node;
-
- id->dst_node->remove_stmt_references (gsi_stmt (bsi));
-
- if (gimple_code (gsi_stmt (bsi)) == GIMPLE_CALL
- &&(e = id->dst_node->get_edge (gsi_stmt (bsi))) != NULL)
- {
- if (!e->inline_failed)
- e->callee->remove_symbol_and_inline_clones (id->dst_node);
- else
- e->remove ();
- }
- if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES
- && id->dst_node->clones)
- for (node = id->dst_node->clones; node != id->dst_node;)
- {
- node->remove_stmt_references (gsi_stmt (bsi));
- if (gimple_code (gsi_stmt (bsi)) == GIMPLE_CALL
- && (e = node->get_edge (gsi_stmt (bsi))) != NULL)
- {
- if (!e->inline_failed)
- e->callee->remove_symbol_and_inline_clones (id->dst_node);
- else
- e->remove ();
- }
-
- if (node->clones)
- node = node->clones;
- else if (node->next_sibling_clone)
- node = node->next_sibling_clone;
- else
- {
- while (node != id->dst_node && !node->next_sibling_clone)
- node = node->clone_of;
- if (node != id->dst_node)
- node = node->next_sibling_clone;
- }
- }
- }
- delete_basic_block (b);
- changed = true;
- }
- }
-
- return changed;
-}
-
/* Update clone info after duplication. */
static void
@@ -6094,7 +6022,7 @@ tree_function_versioning (tree old_decl, tree new_decl,
update_max_bb_count ();
fold_marked_statements (0, id.statements_to_fold);
delete id.statements_to_fold;
- delete_unreachable_blocks_update_callgraph (&id);
+ delete_unreachable_blocks_update_callgraph (id.dst_node, update_clones);
if (id.dst_node->definition)
cgraph_edge::rebuild_references ();
if (loops_state_satisfies_p (LOOPS_NEED_FIXUP))