]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cfghooks.c (copy_bbs): Add update_dominance argument.
authorSteve Ellcey <sellcey@imgtec.com>
Thu, 16 May 2013 17:09:40 +0000 (17:09 +0000)
committerSteve Ellcey <sje@gcc.gnu.org>
Thu, 16 May 2013 17:09:40 +0000 (17:09 +0000)
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

gcc/ChangeLog
gcc/cfghooks.c
gcc/cfghooks.h
gcc/cfgloopmanip.c
gcc/trans-mem.c
gcc/tree-cfg.c
gcc/tree-flow.h
gcc/tree-ssa-loop-ch.c
gcc/tree-vect-loop-manip.c

index 1c70cb1c6c7a27337a79daedaa538d25a6ee95f2..615c233532869fec69387d96b9001835d3e220c8 100644 (file)
@@ -1,3 +1,17 @@
+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>
 
        * tree-vectorizer.h (NUM_PATTERNS): Increment.
index 22b962b52b1fec196b2f1ad72224dd26808d4cbd..8331fa0e9561374a24895ad1e1d8341bc8bc2bdd 100644 (file)
@@ -1282,12 +1282,17 @@ end:
 
 /* 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
-   in BBS are also duplicated and copies of those of them
-   that lead into BBS are redirected to appropriate newly created block.  The
-   function assigns bbs into loops (copy of basic block bb is assigned to
-   bb->loop_father->copy 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).
+   in BBS are also duplicated and copies of those that lead into BBS are
+   redirected to appropriate newly created block.  The function assigns bbs
+   into loops (copy of basic block bb is assigned to bb->loop_father->copy
+   loop, so this must be set up correctly in advance)
+
+   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
    is copied, we do not set the new blocks as header or latch.
@@ -1301,7 +1306,7 @@ end:
 void
 copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs,
          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;
   basic_block bb, new_bb, dom_bb;
@@ -1327,16 +1332,19 @@ copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs,
     }
 
   /* Set dominators.  */
-  for (i = 0; i < n; i++)
+  if (update_dominance)
     {
-      bb = bbs[i];
-      new_bb = new_bbs[i];
-
-      dom_bb = get_immediate_dominator (CDI_DOMINATORS, bb);
-      if (dom_bb->flags & BB_DUPLICATED)
+      for (i = 0; i < n; i++)
        {
-         dom_bb = get_bb_copy (dom_bb);
-         set_immediate_dominator (CDI_DOMINATORS, new_bb, dom_bb);
+         bb = bbs[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);
+             set_immediate_dominator (CDI_DOMINATORS, new_bb, dom_bb);
+           }
        }
     }
 
index bff0a0c04b6425b117a1395d32cc2c4e1472204d..ec595a5123b668265369dd544cd1413c4090905a 100644 (file)
@@ -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 void copy_bbs (basic_block *, unsigned, basic_block *,
                      edge *, unsigned, edge *, struct loop *,
-                     basic_block);
+                     basic_block, bool);
 
 void account_profile_record (struct profile_record *, int);
 
index 9581677da9f147fbde9ee0431230258edc9a89d0..bc877559052ea5f91e019828c0c1e912e4ca026e 100644 (file)
@@ -1300,7 +1300,7 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
 
       /* Copy bbs.  */
       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;
 
       if (flags & DLTHE_RECORD_COPY_NUMBER)
index 5cb828659109a8b4f694eca4acf5eb6d3189c7a4..c66278c01107fc2d5918a39750d8203355622888 100644 (file)
@@ -3978,7 +3978,8 @@ ipa_uninstrument_transaction (struct tm_region *region,
   int n = queue.length ();
   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);
   add_phi_args_after_copy (new_bbs, n, e);
 
index a08a737a0c0a95602ddfd1ccbaccb32334240bf8..721c4f77d4ad23f9e53480756e9dece0a972c503 100644 (file)
@@ -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
    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
-   updated, but not the SSA web.  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.
+   updated if UPDATE_DOMINANCE is true, but not the SSA web.  If
+   UPDATE_DOMINANCE is false then we assume that the caller will update the
+   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,
    true otherwise.  */
 
 bool
 gimple_duplicate_sese_region (edge entry, edge exit,
                            basic_block *region, unsigned n_region,
-                           basic_block *region_copy)
+                           basic_block *region_copy,
+                           bool update_dominance)
 {
   unsigned i;
   bool free_region_copy = false, copying_header = false;
@@ -5749,12 +5752,15 @@ gimple_duplicate_sese_region (edge entry, edge exit,
       free_region_copy = true;
     }
 
-  /* Record blocks outside the region that are dominated by something
-     inside.  */
-  doms.create (0);
   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)
     {
@@ -5778,7 +5784,7 @@ gimple_duplicate_sese_region (edge entry, edge exit,
     }
 
   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)
     {
       scale_bbs_frequencies_gcov_type (region, n_region,
@@ -5809,10 +5815,13 @@ gimple_duplicate_sese_region (edge entry, edge exit,
      for entry block and its copy.  Anything that is outside of the
      region, but was dominated by something inside needs recounting as
      well.  */
-  set_immediate_dominator (CDI_DOMINATORS, entry->dest, entry->src);
-  doms.safe_push (get_bb_original (entry->dest));
-  iterate_fix_dominators (CDI_DOMINATORS, doms, false);
-  doms.release ();
+  if (update_dominance)
+    {
+      set_immediate_dominator (CDI_DOMINATORS, entry->dest, entry->src);
+      doms.safe_push (get_bb_original (entry->dest));
+      iterate_fix_dominators (CDI_DOMINATORS, doms, false);
+      doms.release ();
+    }
 
   /* Add the other PHI node arguments.  */
   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
     }
 
   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)
     {
       scale_bbs_frequencies_gcov_type (region, n_region,
index 01fe3633182346357b57fb2453213df248f50610..24fcfbfe92089692ca301b1db9faeb6e2750ca24 100644 (file)
@@ -395,7 +395,7 @@ extern void verify_gimple_in_cfg (struct function *);
 extern tree gimple_block_label (basic_block);
 extern void extract_true_false_edges_from_block (basic_block, edge *, edge *);
 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,
                                      basic_block *);
 extern void gather_blocks_in_sese_region (basic_block entry, basic_block exit,
index a1d02997eda1a03c3b15883aab6487a26dfb18fe..ff17c7e78fbf1599038d3769155f7d5124622773 100644 (file)
@@ -197,7 +197,8 @@ copy_loop_headers (void)
       entry = loop_preheader_edge (loop);
 
       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");
          continue;
index a0d676971261d0219e25fc6651219f93ee91944f..12f70ee002a6da090b28c9bd3a2aed26835ee544 100644 (file)
@@ -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,
            &exit, 1, &new_exit, NULL,
-           e->src);
+           e->src, true);
   basic_block new_preheader = new_bbs[loop->num_nodes];
 
   add_phi_args_after_copy (new_bbs, loop->num_nodes + 1, NULL);