summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-manip.c
diff options
context:
space:
mode:
authorsteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2012-08-13 21:02:19 +0000
committersteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2012-08-13 21:02:19 +0000
commited7e22069d2345aced81f8cc3f1dbfb258ba05e4 (patch)
tree1c95fd4683bc594cb2132acdc6e4392391693368 /gcc/tree-ssa-loop-manip.c
parent88f1a24d7a98930aeda6861dda25d815d898b21f (diff)
downloadgcc-ed7e22069d2345aced81f8cc3f1dbfb258ba05e4.tar.gz
* tree-ssa-pre.c (do_regular_insertion): Add FIXME markers at points
of potentially huge memset overhead. (do_partial_partial_insertion): Likewise. * cfgexpand.c (gimple_expand_cfg): Use XCNEWVEC instead of xcalloc. * tree-vrp.c (find_assert_locations): Use XNEWVEC instead of XCNEWVEC for arrays to be filled by pre_and_rev_post_order_compute. Allocate the right number of slots, not that number plus NUM_FIXED_BLOCKS. * tree-ssa-reassoc.c (init_reassoc): Likewise. * cfganal.c (dfs_enumerate_from): Use XNEWVEC instead of XCNEWVEC for array used as stack. * tree-ssa-sccvn.c (init_scc_vn): Use XNEWVEC instead of XCNEWVEC for arrays to be filled by pre_and_rev_post_order_compute. * cfgloopmanip.c (find_path): Use XNEWVEC instead of XCNEWVEC for array to be filled by dfs_enumerate_from. (remove_path): Likewise. (duplicate_loop_to_header_edge): Use XNEWVEC instead of XCNEWVEC for array of loops that is filled on the next lines. * cfgloop.c (get_loop_body): Use XNEWVEC instead of XCNEWVEC for array of basic blocks to be returned. (get_loop_body_in_dom_order): Likewise. (get_loop_body_in_bfs_order): Likewise. * tree-ssa-loop-manip.c (loop_renamer_obstack): New static obstack for all bitmaps used for rewriting into loop-closed SSA form. (add_exit_phis_var): Allocate the def bitmap on it. Clear the livein bitmap at the end to release a lot of memory. (add_exit_phis): Allocate the exits bitmap on the new obstack. (get_loops_exits): Allocate the exits bitmap on the new obstack. (find_uses_to_rename_use): Allocate a use_blocks bitmap if ver is seen for the first time. (find_uses_to_rename): Add "???" for why the whole function must be re-scanned if changed_bbs is empty. (rewrite_into_loop_closed_ssa): Allocate bitmaps on the new obstack. Use XNEWVEC to allocate the use_blocks array. Initialize the new obstack, and free it at the end. Remove loop over all SSA names. (check_loop_closed_ssa_stmt): Look only at SSA_OP_USE operands. * tree-cfg.c (move_sese_region_to_fn): Use XNEWVEC instead of xcalloc to allocate edge_pred and edge_flag arrays. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190359 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-loop-manip.c')
-rw-r--r--gcc/tree-ssa-loop-manip.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 5aa8c7d3c3f..98846138e7c 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -34,6 +34,10 @@ along with GCC; see the file COPYING3. If not see
#include "tree-inline.h"
#include "langhooks.h"
+/* All bitmaps for rewriting into loop-closed SSA go on this obstack,
+ so that we can free them all at once. */
+static bitmap_obstack loop_renamer_obstack;
+
/* Creates an induction variable with value BASE + STEP * iteration in LOOP.
It is expected that neither BASE nor STEP are shared with other expressions
(unless the sharing rules allow this). Use VAR as a base var_decl for it
@@ -168,7 +172,7 @@ add_exit_phis_var (tree var, bitmap livein, bitmap exits)
gcc_checking_assert (is_gimple_reg (var));
bitmap_clear_bit (livein, def_bb->index);
- def = BITMAP_ALLOC (NULL);
+ def = BITMAP_ALLOC (&loop_renamer_obstack);
bitmap_set_bit (def, def_bb->index);
compute_global_livein (livein, def);
BITMAP_FREE (def);
@@ -177,6 +181,10 @@ add_exit_phis_var (tree var, bitmap livein, bitmap exits)
{
add_exit_phis_edge (BASIC_BLOCK (index), var);
}
+
+ /* Free the livein bitmap. We'll not be needing it anymore, and
+ it may have grown quite large. No reason to hold on to it. */
+ bitmap_clear (livein);
}
/* Add exit phis for the names marked in NAMES_TO_RENAME.
@@ -200,7 +208,7 @@ add_exit_phis (bitmap names_to_rename, bitmap *use_blocks, bitmap loop_exits)
static bitmap
get_loops_exits (void)
{
- bitmap exits = BITMAP_ALLOC (NULL);
+ bitmap exits = BITMAP_ALLOC (&loop_renamer_obstack);
basic_block bb;
edge e;
edge_iterator ei;
@@ -253,11 +261,11 @@ find_uses_to_rename_use (basic_block bb, tree use, bitmap *use_blocks,
if (flow_bb_inside_loop_p (def_loop, bb))
return;
- if (!use_blocks[ver])
- use_blocks[ver] = BITMAP_ALLOC (NULL);
+ /* If we're seeing VER for the first time, we still have to allocate
+ a bitmap for its uses. */
+ if (bitmap_set_bit (need_phis, ver))
+ use_blocks[ver] = BITMAP_ALLOC (&loop_renamer_obstack);
bitmap_set_bit (use_blocks[ver], bb->index);
-
- bitmap_set_bit (need_phis, ver);
}
/* For uses in STMT, mark names that are used outside of the loop they are
@@ -312,6 +320,7 @@ find_uses_to_rename (bitmap changed_bbs, bitmap *use_blocks, bitmap need_phis)
unsigned index;
bitmap_iterator bi;
+ /* ??? If CHANGED_BBS is empty we rewrite the whole function -- why? */
if (changed_bbs && !bitmap_empty_p (changed_bbs))
{
EXECUTE_IF_SET_IN_BITMAP (changed_bbs, 0, index, bi)
@@ -365,22 +374,25 @@ rewrite_into_loop_closed_ssa (bitmap changed_bbs, unsigned update_flag)
{
bitmap loop_exits;
bitmap *use_blocks;
- unsigned i, old_num_ssa_names;
bitmap names_to_rename;
loops_state_set (LOOP_CLOSED_SSA);
if (number_of_loops () <= 1)
return;
+ bitmap_obstack_initialize (&loop_renamer_obstack);
+
loop_exits = get_loops_exits ();
- names_to_rename = BITMAP_ALLOC (NULL);
+ names_to_rename = BITMAP_ALLOC (&loop_renamer_obstack);
/* If the pass has caused the SSA form to be out-of-date, update it
now. */
update_ssa (update_flag);
- old_num_ssa_names = num_ssa_names;
- use_blocks = XCNEWVEC (bitmap, old_num_ssa_names);
+ /* Uses of names to rename. We don't have to initialize this array,
+ because we know that we will only have entries for the SSA names
+ in NAMES_TO_RENAME. */
+ use_blocks = XCNEWVEC (bitmap, num_ssa_names);
/* Find the uses outside loops. */
find_uses_to_rename (changed_bbs, use_blocks, names_to_rename);
@@ -389,11 +401,8 @@ rewrite_into_loop_closed_ssa (bitmap changed_bbs, unsigned update_flag)
rewrite. */
add_exit_phis (names_to_rename, use_blocks, loop_exits);
- for (i = 0; i < old_num_ssa_names; i++)
- BITMAP_FREE (use_blocks[i]);
+ bitmap_obstack_release (&loop_renamer_obstack);
free (use_blocks);
- BITMAP_FREE (loop_exits);
- BITMAP_FREE (names_to_rename);
/* Fix up all the names found to be used outside their original
loops. */
@@ -428,7 +437,7 @@ check_loop_closed_ssa_stmt (basic_block bb, gimple stmt)
if (is_gimple_debug (stmt))
return;
- FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_ALL_USES)
+ FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_USE)
check_loop_closed_ssa_use (bb, var);
}