From: Trevor Saunders <tbsaunde+...@tbsaunde.org>

gcc/ChangeLog:

2017-05-09  Trevor Saunders  <tbsaunde+...@tbsaunde.org>

        * ddg.c (find_nodes_on_paths): Use auto_sbitmap.
        (longest_simple_path): Likewise.
        * shrink-wrap.c (spread_components): Likewise.
        (disqualify_problematic_components): Likewise.
        (emit_common_heads_for_components): Likewise.
        (emit_common_tails_for_components): Likewise.
        (insert_prologue_epilogue_for_components): Likewise.
---
 gcc/ddg.c         | 26 ++++++++------------------
 gcc/shrink-wrap.c | 38 +++++++++++---------------------------
 2 files changed, 19 insertions(+), 45 deletions(-)

diff --git a/gcc/ddg.c b/gcc/ddg.c
index 9ea98d6f40f..8aaed80dec4 100644
--- a/gcc/ddg.c
+++ b/gcc/ddg.c
@@ -1081,16 +1081,15 @@ free_ddg_all_sccs (ddg_all_sccs_ptr all_sccs)
 int
 find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to)
 {
-  int answer;
   int change;
   unsigned int u = 0;
   int num_nodes = g->num_nodes;
   sbitmap_iterator sbi;
 
-  sbitmap workset = sbitmap_alloc (num_nodes);
-  sbitmap reachable_from = sbitmap_alloc (num_nodes);
-  sbitmap reach_to = sbitmap_alloc (num_nodes);
-  sbitmap tmp = sbitmap_alloc (num_nodes);
+  auto_sbitmap workset (num_nodes);
+  auto_sbitmap reachable_from (num_nodes);
+  auto_sbitmap reach_to (num_nodes);
+  auto_sbitmap tmp (num_nodes);
 
   bitmap_copy (reachable_from, from);
   bitmap_copy (tmp, from);
@@ -1150,12 +1149,7 @@ find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap 
from, sbitmap to)
        }
     }
 
-  answer = bitmap_and (result, reachable_from, reach_to);
-  sbitmap_free (workset);
-  sbitmap_free (reachable_from);
-  sbitmap_free (reach_to);
-  sbitmap_free (tmp);
-  return answer;
+  return bitmap_and (result, reachable_from, reach_to);
 }
 
 
@@ -1195,10 +1189,9 @@ longest_simple_path (struct ddg * g, int src, int dest, 
sbitmap nodes)
   int i;
   unsigned int u = 0;
   int change = 1;
-  int result;
   int num_nodes = g->num_nodes;
-  sbitmap workset = sbitmap_alloc (num_nodes);
-  sbitmap tmp = sbitmap_alloc (num_nodes);
+  auto_sbitmap workset (num_nodes);
+  auto_sbitmap tmp (num_nodes);
 
 
   /* Data will hold the distance of the longest path found so far from
@@ -1224,10 +1217,7 @@ longest_simple_path (struct ddg * g, int src, int dest, 
sbitmap nodes)
          change |= update_dist_to_successors (u_node, nodes, tmp);
        }
     }
-  result = g->nodes[dest].aux.count;
-  sbitmap_free (workset);
-  sbitmap_free (tmp);
-  return result;
+  return g->nodes[dest].aux.count;
 }
 
 #endif /* INSN_SCHEDULING */
diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c
index 492376d949b..1ac4ea3b054 100644
--- a/gcc/shrink-wrap.c
+++ b/gcc/shrink-wrap.c
@@ -1264,7 +1264,7 @@ spread_components (sbitmap components)
   todo.create (n_basic_blocks_for_fn (cfun));
   auto_bitmap seen;
 
-  sbitmap old = sbitmap_alloc (SBITMAP_SIZE (components));
+  auto_sbitmap old (SBITMAP_SIZE (components));
 
   /* Find for every block the components that are *not* needed on some path
      from the entry to that block.  Do this with a flood fill from the entry
@@ -1390,8 +1390,6 @@ spread_components (sbitmap components)
          fprintf (dump_file, "\n");
        }
     }
-
-  sbitmap_free (old);
 }
 
 /* If we cannot handle placing some component's prologues or epilogues where
@@ -1400,8 +1398,8 @@ spread_components (sbitmap components)
 static void
 disqualify_problematic_components (sbitmap components)
 {
-  sbitmap pro = sbitmap_alloc (SBITMAP_SIZE (components));
-  sbitmap epi = sbitmap_alloc (SBITMAP_SIZE (components));
+  auto_sbitmap pro (SBITMAP_SIZE (components));
+  auto_sbitmap epi (SBITMAP_SIZE (components));
 
   basic_block bb;
   FOR_EACH_BB_FN (bb, cfun)
@@ -1466,9 +1464,6 @@ disqualify_problematic_components (sbitmap components)
            }
        }
     }
-
-  sbitmap_free (pro);
-  sbitmap_free (epi);
 }
 
 /* Place code for prologues and epilogues for COMPONENTS where we can put
@@ -1476,9 +1471,9 @@ disqualify_problematic_components (sbitmap components)
 static void
 emit_common_heads_for_components (sbitmap components)
 {
-  sbitmap pro = sbitmap_alloc (SBITMAP_SIZE (components));
-  sbitmap epi = sbitmap_alloc (SBITMAP_SIZE (components));
-  sbitmap tmp = sbitmap_alloc (SBITMAP_SIZE (components));
+  auto_sbitmap pro (SBITMAP_SIZE (components));
+  auto_sbitmap epi (SBITMAP_SIZE (components));
+  auto_sbitmap tmp (SBITMAP_SIZE (components));
 
   basic_block bb;
   FOR_ALL_BB_FN (bb, cfun)
@@ -1554,10 +1549,6 @@ emit_common_heads_for_components (sbitmap components)
          bitmap_ior (SW (bb)->head_components, SW (bb)->head_components, epi);
        }
     }
-
-  sbitmap_free (pro);
-  sbitmap_free (epi);
-  sbitmap_free (tmp);
 }
 
 /* Place code for prologues and epilogues for COMPONENTS where we can put
@@ -1565,9 +1556,9 @@ emit_common_heads_for_components (sbitmap components)
 static void
 emit_common_tails_for_components (sbitmap components)
 {
-  sbitmap pro = sbitmap_alloc (SBITMAP_SIZE (components));
-  sbitmap epi = sbitmap_alloc (SBITMAP_SIZE (components));
-  sbitmap tmp = sbitmap_alloc (SBITMAP_SIZE (components));
+  auto_sbitmap pro (SBITMAP_SIZE (components));
+  auto_sbitmap epi (SBITMAP_SIZE (components));
+  auto_sbitmap tmp (SBITMAP_SIZE (components));
 
   basic_block bb;
   FOR_ALL_BB_FN (bb, cfun)
@@ -1664,10 +1655,6 @@ emit_common_tails_for_components (sbitmap components)
          bitmap_ior (SW (bb)->tail_components, SW (bb)->tail_components, pro);
        }
     }
-
-  sbitmap_free (pro);
-  sbitmap_free (epi);
-  sbitmap_free (tmp);
 }
 
 /* Place prologues and epilogues for COMPONENTS on edges, if we haven't already
@@ -1675,8 +1662,8 @@ emit_common_tails_for_components (sbitmap components)
 static void
 insert_prologue_epilogue_for_components (sbitmap components)
 {
-  sbitmap pro = sbitmap_alloc (SBITMAP_SIZE (components));
-  sbitmap epi = sbitmap_alloc (SBITMAP_SIZE (components));
+  auto_sbitmap pro (SBITMAP_SIZE (components));
+  auto_sbitmap epi (SBITMAP_SIZE (components));
 
   basic_block bb;
   FOR_EACH_BB_FN (bb, cfun)
@@ -1754,9 +1741,6 @@ insert_prologue_epilogue_for_components (sbitmap 
components)
        }
     }
 
-  sbitmap_free (pro);
-  sbitmap_free (epi);
-
   commit_edge_insertions ();
 }
 
-- 
2.11.0

Reply via email to