Commit f14540b6 by Steve Ellcey Committed by Steve Ellcey

cfghooks.c (copy_bbs): Add update_dominance argument.

2013-05-16  Steve Ellcey  <sellcey@imgtec.com>

	* cfghooks.c (copy_bbs): Add update_dominance argument.
	* cfghooks.h (copy_bbs): Update prototype.
	* tree-cfg.c (gimple_duplicate_sese_region):
	Add update_dominance argument.
	* tree-flow.h (gimple_duplicate_sese_region): Update prototype.
	* tree-ssa-loop-ch.c (copy_loop_headers): Update
	gimple_duplicate_sese_region call.
	* tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
	Update copy_bbs call.
	* cfgloopmanip.c (duplicate_loop_to_header_edge): Ditto.
	* trans-mem.c (ipa_uninstrument_transaction): Ditto.

From-SVN: r198980
parent 45f9820f
2013-05-16 Steve Ellcey <sellcey@imgtec.com>
* cfghooks.c (copy_bbs): Add update_dominance argument.
* cfghooks.h (copy_bbs): Update prototype.
* tree-cfg.c (gimple_duplicate_sese_region):
Add update_dominance argument.
* tree-flow.h (gimple_duplicate_sese_region): Update prototype.
* tree-ssa-loop-ch.c (copy_loop_headers): Update
gimple_duplicate_sese_region call.
* tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
Update copy_bbs call.
* cfgloopmanip.c (duplicate_loop_to_header_edge): Ditto.
* trans-mem.c (ipa_uninstrument_transaction): Ditto.
2013-05-16 Jakub Jelinek <jakub@redhat.com> 2013-05-16 Jakub Jelinek <jakub@redhat.com>
* tree-vectorizer.h (NUM_PATTERNS): Increment. * tree-vectorizer.h (NUM_PATTERNS): Increment.
......
...@@ -1282,12 +1282,17 @@ end: ...@@ -1282,12 +1282,17 @@ end:
/* Duplicates N basic blocks stored in array BBS. Newly created basic blocks /* Duplicates N basic blocks stored in array BBS. Newly created basic blocks
are placed into array NEW_BBS in the same order. Edges from basic blocks are placed into array NEW_BBS in the same order. Edges from basic blocks
in BBS are also duplicated and copies of those of them in BBS are also duplicated and copies of those that lead into BBS are
that lead into BBS are redirected to appropriate newly created block. The redirected to appropriate newly created block. The function assigns bbs
function assigns bbs into loops (copy of basic block bb is assigned to into loops (copy of basic block bb is assigned to bb->loop_father->copy
bb->loop_father->copy loop, so this must be set up correctly in advance) loop, so this must be set up correctly in advance)
and updates dominators locally (LOOPS structure that contains the information
about dominators is passed to enable this). If UPDATE_DOMINANCE is true then this function updates dominators locally
(LOOPS structure that contains the information about dominators is passed
to enable this), otherwise it does not update the dominator information
and it assumed that the caller will do this, perhaps by destroying and
recreating it instead of trying to do an incremental update like this
function does when update_dominance is true.
BASE is the superloop to that basic block belongs; if its header or latch BASE is the superloop to that basic block belongs; if its header or latch
is copied, we do not set the new blocks as header or latch. is copied, we do not set the new blocks as header or latch.
...@@ -1301,7 +1306,7 @@ end: ...@@ -1301,7 +1306,7 @@ end:
void void
copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs, copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs,
edge *edges, unsigned num_edges, edge *new_edges, edge *edges, unsigned num_edges, edge *new_edges,
struct loop *base, basic_block after) struct loop *base, basic_block after, bool update_dominance)
{ {
unsigned i, j; unsigned i, j;
basic_block bb, new_bb, dom_bb; basic_block bb, new_bb, dom_bb;
...@@ -1327,16 +1332,19 @@ copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs, ...@@ -1327,16 +1332,19 @@ copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs,
} }
/* Set dominators. */ /* Set dominators. */
for (i = 0; i < n; i++) if (update_dominance)
{ {
bb = bbs[i]; for (i = 0; i < n; i++)
new_bb = new_bbs[i];
dom_bb = get_immediate_dominator (CDI_DOMINATORS, bb);
if (dom_bb->flags & BB_DUPLICATED)
{ {
dom_bb = get_bb_copy (dom_bb); bb = bbs[i];
set_immediate_dominator (CDI_DOMINATORS, new_bb, dom_bb); new_bb = new_bbs[i];
dom_bb = get_immediate_dominator (CDI_DOMINATORS, bb);
if (dom_bb->flags & BB_DUPLICATED)
{
dom_bb = get_bb_copy (dom_bb);
set_immediate_dominator (CDI_DOMINATORS, new_bb, dom_bb);
}
} }
} }
......
...@@ -201,7 +201,7 @@ extern void lv_add_condition_to_bb (basic_block, basic_block, basic_block, ...@@ -201,7 +201,7 @@ extern void lv_add_condition_to_bb (basic_block, basic_block, basic_block,
extern bool can_copy_bbs_p (basic_block *, unsigned); extern bool can_copy_bbs_p (basic_block *, unsigned);
extern void copy_bbs (basic_block *, unsigned, basic_block *, extern void copy_bbs (basic_block *, unsigned, basic_block *,
edge *, unsigned, edge *, struct loop *, edge *, unsigned, edge *, struct loop *,
basic_block); basic_block, bool);
void account_profile_record (struct profile_record *, int); void account_profile_record (struct profile_record *, int);
......
...@@ -1300,7 +1300,7 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, ...@@ -1300,7 +1300,7 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
/* Copy bbs. */ /* Copy bbs. */
copy_bbs (bbs, n, new_bbs, spec_edges, 2, new_spec_edges, loop, copy_bbs (bbs, n, new_bbs, spec_edges, 2, new_spec_edges, loop,
place_after); place_after, true);
place_after = new_spec_edges[SE_LATCH]->src; place_after = new_spec_edges[SE_LATCH]->src;
if (flags & DLTHE_RECORD_COPY_NUMBER) if (flags & DLTHE_RECORD_COPY_NUMBER)
......
...@@ -3978,7 +3978,8 @@ ipa_uninstrument_transaction (struct tm_region *region, ...@@ -3978,7 +3978,8 @@ ipa_uninstrument_transaction (struct tm_region *region,
int n = queue.length (); int n = queue.length ();
basic_block *new_bbs = XNEWVEC (basic_block, n); basic_block *new_bbs = XNEWVEC (basic_block, n);
copy_bbs (queue.address (), n, new_bbs, NULL, 0, NULL, NULL, transaction_bb); copy_bbs (queue.address (), n, new_bbs, NULL, 0, NULL, NULL, transaction_bb,
true);
edge e = make_edge (transaction_bb, new_bbs[0], EDGE_TM_UNINSTRUMENTED); edge e = make_edge (transaction_bb, new_bbs[0], EDGE_TM_UNINSTRUMENTED);
add_phi_args_after_copy (new_bbs, n, e); add_phi_args_after_copy (new_bbs, n, e);
......
...@@ -5686,16 +5686,19 @@ add_phi_args_after_copy (basic_block *region_copy, unsigned n_region, ...@@ -5686,16 +5686,19 @@ add_phi_args_after_copy (basic_block *region_copy, unsigned n_region,
inside region is live over the other exit edges of the region. All entry inside region is live over the other exit edges of the region. All entry
edges to the region must go to ENTRY->dest. The edge ENTRY is redirected edges to the region must go to ENTRY->dest. The edge ENTRY is redirected
to the duplicate of the region. Dominance and loop information is to the duplicate of the region. Dominance and loop information is
updated, but not the SSA web. The new basic blocks are stored to updated if UPDATE_DOMINANCE is true, but not the SSA web. If
REGION_COPY in the same order as they had in REGION, provided that UPDATE_DOMINANCE is false then we assume that the caller will update the
REGION_COPY is not NULL. dominance information after calling this function. The new basic
blocks are stored to REGION_COPY in the same order as they had in REGION,
provided that REGION_COPY is not NULL.
The function returns false if it is unable to copy the region, The function returns false if it is unable to copy the region,
true otherwise. */ true otherwise. */
bool bool
gimple_duplicate_sese_region (edge entry, edge exit, gimple_duplicate_sese_region (edge entry, edge exit,
basic_block *region, unsigned n_region, basic_block *region, unsigned n_region,
basic_block *region_copy) basic_block *region_copy,
bool update_dominance)
{ {
unsigned i; unsigned i;
bool free_region_copy = false, copying_header = false; bool free_region_copy = false, copying_header = false;
...@@ -5749,12 +5752,15 @@ gimple_duplicate_sese_region (edge entry, edge exit, ...@@ -5749,12 +5752,15 @@ gimple_duplicate_sese_region (edge entry, edge exit,
free_region_copy = true; free_region_copy = true;
} }
/* Record blocks outside the region that are dominated by something
inside. */
doms.create (0);
initialize_original_copy_tables (); initialize_original_copy_tables ();
doms = get_dominated_by_region (CDI_DOMINATORS, region, n_region); /* Record blocks outside the region that are dominated by something
inside. */
if (update_dominance)
{
doms.create (0);
doms = get_dominated_by_region (CDI_DOMINATORS, region, n_region);
}
if (entry->dest->count) if (entry->dest->count)
{ {
...@@ -5778,7 +5784,7 @@ gimple_duplicate_sese_region (edge entry, edge exit, ...@@ -5778,7 +5784,7 @@ gimple_duplicate_sese_region (edge entry, edge exit,
} }
copy_bbs (region, n_region, region_copy, &exit, 1, &exit_copy, loop, copy_bbs (region, n_region, region_copy, &exit, 1, &exit_copy, loop,
split_edge_bb_loc (entry)); split_edge_bb_loc (entry), update_dominance);
if (total_count) if (total_count)
{ {
scale_bbs_frequencies_gcov_type (region, n_region, scale_bbs_frequencies_gcov_type (region, n_region,
...@@ -5809,10 +5815,13 @@ gimple_duplicate_sese_region (edge entry, edge exit, ...@@ -5809,10 +5815,13 @@ gimple_duplicate_sese_region (edge entry, edge exit,
for entry block and its copy. Anything that is outside of the for entry block and its copy. Anything that is outside of the
region, but was dominated by something inside needs recounting as region, but was dominated by something inside needs recounting as
well. */ well. */
set_immediate_dominator (CDI_DOMINATORS, entry->dest, entry->src); if (update_dominance)
doms.safe_push (get_bb_original (entry->dest)); {
iterate_fix_dominators (CDI_DOMINATORS, doms, false); set_immediate_dominator (CDI_DOMINATORS, entry->dest, entry->src);
doms.release (); doms.safe_push (get_bb_original (entry->dest));
iterate_fix_dominators (CDI_DOMINATORS, doms, false);
doms.release ();
}
/* Add the other PHI node arguments. */ /* Add the other PHI node arguments. */
add_phi_args_after_copy (region_copy, n_region, NULL); add_phi_args_after_copy (region_copy, n_region, NULL);
...@@ -5944,7 +5953,7 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU ...@@ -5944,7 +5953,7 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU
} }
copy_bbs (region, n_region, region_copy, exits, 2, nexits, orig_loop, copy_bbs (region, n_region, region_copy, exits, 2, nexits, orig_loop,
split_edge_bb_loc (exit)); split_edge_bb_loc (exit), true);
if (total_count) if (total_count)
{ {
scale_bbs_frequencies_gcov_type (region, n_region, scale_bbs_frequencies_gcov_type (region, n_region,
......
...@@ -395,7 +395,7 @@ extern void verify_gimple_in_cfg (struct function *); ...@@ -395,7 +395,7 @@ extern void verify_gimple_in_cfg (struct function *);
extern tree gimple_block_label (basic_block); extern tree gimple_block_label (basic_block);
extern void extract_true_false_edges_from_block (basic_block, edge *, edge *); extern void extract_true_false_edges_from_block (basic_block, edge *, edge *);
extern bool gimple_duplicate_sese_region (edge, edge, basic_block *, unsigned, extern bool gimple_duplicate_sese_region (edge, edge, basic_block *, unsigned,
basic_block *); basic_block *, bool);
extern bool gimple_duplicate_sese_tail (edge, edge, basic_block *, unsigned, extern bool gimple_duplicate_sese_tail (edge, edge, basic_block *, unsigned,
basic_block *); basic_block *);
extern void gather_blocks_in_sese_region (basic_block entry, basic_block exit, extern void gather_blocks_in_sese_region (basic_block entry, basic_block exit,
......
...@@ -197,7 +197,8 @@ copy_loop_headers (void) ...@@ -197,7 +197,8 @@ copy_loop_headers (void)
entry = loop_preheader_edge (loop); entry = loop_preheader_edge (loop);
propagate_threaded_block_debug_into (exit->dest, entry->dest); propagate_threaded_block_debug_into (exit->dest, entry->dest);
if (!gimple_duplicate_sese_region (entry, exit, bbs, n_bbs, copied_bbs)) if (!gimple_duplicate_sese_region (entry, exit, bbs, n_bbs, copied_bbs,
true))
{ {
fprintf (dump_file, "Duplication failed.\n"); fprintf (dump_file, "Duplication failed.\n");
continue; continue;
......
...@@ -735,7 +735,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop, edge e) ...@@ -735,7 +735,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop, edge e)
copy_bbs (bbs, loop->num_nodes + 1, new_bbs, copy_bbs (bbs, loop->num_nodes + 1, new_bbs,
&exit, 1, &new_exit, NULL, &exit, 1, &new_exit, NULL,
e->src); e->src, true);
basic_block new_preheader = new_bbs[loop->num_nodes]; basic_block new_preheader = new_bbs[loop->num_nodes];
add_phi_args_after_copy (new_bbs, loop->num_nodes + 1, NULL); add_phi_args_after_copy (new_bbs, loop->num_nodes + 1, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment