This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [bitmap memory]: Allocation part 2
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: law at redhat dot com
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Roger Sayle <roger at eyesopen dot com>,Daniel Berlin <dberlin at dberlin dot org>
- Date: Tue, 23 Nov 2004 14:13:07 +0000
- Subject: Re: [bitmap memory]: Allocation part 2
- Organization: Codesourcery LLC
- References: <41A21524.4050102@codesourcery.com> <1101162070.27318.220.camel@localhost.localdomain>
Jeffrey A Law wrote:
That patch is, err, long. Is there any way you can break it into
distinct functional hunks to make review easier?
Here is the fragment that removes XMALLOC_REG_SET and XFREE_REG_SET.
You'll notice it does not include any of the ra*.c files -- they
use bitmaps directly, even though they are mucking about with sets
of registers :)
booted & tested on i686-pc-linux-gnu, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2004-11-23 Nathan Sidwell <nathan@codesourcery.com>
* basic-block.h (OBSTACK_ALLOC_REG_SET): Rename to ...
(ALLOC_REG_SET): ... here.
(FREE_REG_SET): Adjust.
(XMALLOC_REG_SET, XFREE_REG_SET): Remove.
* bb-reorder.c (fix_crossing_conditional_branches): Adjust.
* cfglayout.c (cfg_layout_duplicate_bb): Adjust.
* cfgrtl.c (rtl_split_block, rtl_split_edge,
safe_insert_insn_on_edge, cfg_layout_split_edge): Adjust.
* flow.c (update_life_info, calculate_global_regs_live,
allocate_bb_life_data, init_propagate_block_info): Adjust.
* global.c (build_insn_chain): Adjust.
* ifcvt.c (dead_or_predicable): Adjust.
* loop-iv.c (simplify_using_initial_values): Adjust.
* recog.c (peephole2_optimize): Adjust.
* sched-deps.c (init_deps_global): Adjust.
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.229
diff -c -3 -p -r1.229 basic-block.h
*** basic-block.h 22 Nov 2004 12:23:42 -0000 1.229
--- basic-block.h 23 Nov 2004 10:54:54 -0000
*************** typedef bitmap_head regset_head;
*** 37,42 ****
--- 37,48 ----
/* A pointer to a regset_head. */
typedef bitmap regset;
+ /* Allocate a register set with oballoc. */
+ #define ALLOC_REG_SET(OBSTACK) BITMAP_OBSTACK_ALLOC (OBSTACK)
+
+ /* Do any cleanup needed on a regset when it is no longer used. */
+ #define FREE_REG_SET(REGSET) BITMAP_OBSTACK_FREE (REGSET)
+
/* Initialize a new regset. */
#define INIT_REG_SET(HEAD) bitmap_initialize (HEAD, ®_obstack)
*************** typedef bitmap_iterator reg_set_iterator
*** 101,118 ****
#define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \
EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI) \
- /* Allocate a register set with oballoc. */
- #define OBSTACK_ALLOC_REG_SET(OBSTACK) BITMAP_OBSTACK_ALLOC (OBSTACK)
-
- /* Do any cleanup needed on a regset when it is no longer used. */
- #define FREE_REG_SET(REGSET) BITMAP_OBSTACK_FREE(REGSET)
-
- /* Allocate a register set with xmalloc. */
- #define XMALLOC_REG_SET() BITMAP_XMALLOC ()
-
- /* Free a register set. */
- #define XFREE_REG_SET(REGSET) BITMAP_XFREE (REGSET)
-
/* Type we use to hold basic block counters. Should be at least
64bit. Although a counter cannot be negative, we use a signed
type, because erroneous negative counts can be generated when the
--- 107,112 ----
Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.85
diff -c -3 -p -r1.85 bb-reorder.c
*** bb-reorder.c 22 Nov 2004 12:23:42 -0000 1.85
--- bb-reorder.c 23 Nov 2004 10:54:59 -0000
*************** fix_crossing_conditional_branches (void)
*** 1690,1699 ****
/* Update register liveness information. */
! new_bb->global_live_at_start =
! OBSTACK_ALLOC_REG_SET (®_obstack);
! new_bb->global_live_at_end =
! OBSTACK_ALLOC_REG_SET (®_obstack);
COPY_REG_SET (new_bb->global_live_at_end,
prev_bb->global_live_at_end);
COPY_REG_SET (new_bb->global_live_at_start,
--- 1690,1697 ----
/* Update register liveness information. */
! new_bb->global_live_at_start = ALLOC_REG_SET (®_obstack);
! new_bb->global_live_at_end = ALLOC_REG_SET (®_obstack);
COPY_REG_SET (new_bb->global_live_at_end,
prev_bb->global_live_at_end);
COPY_REG_SET (new_bb->global_live_at_start,
Index: cfglayout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.77
diff -c -3 -p -r1.77 cfglayout.c
*** cfglayout.c 22 Nov 2004 12:23:44 -0000 1.77
--- cfglayout.c 23 Nov 2004 10:56:59 -0000
*************** cfg_layout_duplicate_bb (basic_block bb)
*** 1116,1123 ****
if (bb->global_live_at_start)
{
! new_bb->global_live_at_start = OBSTACK_ALLOC_REG_SET (®_obstack);
! new_bb->global_live_at_end = OBSTACK_ALLOC_REG_SET (®_obstack);
COPY_REG_SET (new_bb->global_live_at_start, bb->global_live_at_start);
COPY_REG_SET (new_bb->global_live_at_end, bb->global_live_at_end);
}
--- 1116,1123 ----
if (bb->global_live_at_start)
{
! new_bb->global_live_at_start = ALLOC_REG_SET (®_obstack);
! new_bb->global_live_at_end = ALLOC_REG_SET (®_obstack);
COPY_REG_SET (new_bb->global_live_at_start, bb->global_live_at_start);
COPY_REG_SET (new_bb->global_live_at_end, bb->global_live_at_end);
}
Index: cfgrtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgrtl.c,v
retrieving revision 1.147
diff -c -3 -p -r1.147 cfgrtl.c
*** cfgrtl.c 22 Nov 2004 12:23:45 -0000 1.147
--- cfgrtl.c 23 Nov 2004 10:57:12 -0000
*************** rtl_split_block (basic_block bb, void *i
*** 489,496 ****
if (bb->global_live_at_start)
{
! new_bb->global_live_at_start = OBSTACK_ALLOC_REG_SET (®_obstack);
! new_bb->global_live_at_end = OBSTACK_ALLOC_REG_SET (®_obstack);
COPY_REG_SET (new_bb->global_live_at_end, bb->global_live_at_end);
/* We now have to calculate which registers are live at the end
--- 489,496 ----
if (bb->global_live_at_start)
{
! new_bb->global_live_at_start = ALLOC_REG_SET (®_obstack);
! new_bb->global_live_at_end = ALLOC_REG_SET (®_obstack);
COPY_REG_SET (new_bb->global_live_at_end, bb->global_live_at_end);
/* We now have to calculate which registers are live at the end
*************** force_nonfallthru_and_redirect (edge e,
*** 1094,1103 ****
if (target->global_live_at_start)
{
! jump_block->global_live_at_start
! = OBSTACK_ALLOC_REG_SET (®_obstack);
! jump_block->global_live_at_end
! = OBSTACK_ALLOC_REG_SET (®_obstack);
COPY_REG_SET (jump_block->global_live_at_start,
target->global_live_at_start);
COPY_REG_SET (jump_block->global_live_at_end,
--- 1094,1101 ----
if (target->global_live_at_start)
{
! jump_block->global_live_at_start = ALLOC_REG_SET (®_obstack);
! jump_block->global_live_at_end = ALLOC_REG_SET (®_obstack);
COPY_REG_SET (jump_block->global_live_at_start,
target->global_live_at_start);
COPY_REG_SET (jump_block->global_live_at_end,
*************** rtl_split_edge (edge edge_in)
*** 1383,1390 ****
/* ??? This info is likely going to be out of date very soon. */
if (edge_in->dest->global_live_at_start)
{
! bb->global_live_at_start = OBSTACK_ALLOC_REG_SET (®_obstack);
! bb->global_live_at_end = OBSTACK_ALLOC_REG_SET (®_obstack);
COPY_REG_SET (bb->global_live_at_start,
edge_in->dest->global_live_at_start);
COPY_REG_SET (bb->global_live_at_end,
--- 1381,1388 ----
/* ??? This info is likely going to be out of date very soon. */
if (edge_in->dest->global_live_at_start)
{
! bb->global_live_at_start = ALLOC_REG_SET (®_obstack);
! bb->global_live_at_end = ALLOC_REG_SET (®_obstack);
COPY_REG_SET (bb->global_live_at_start,
edge_in->dest->global_live_at_start);
COPY_REG_SET (bb->global_live_at_end,
*************** safe_insert_insn_on_edge (rtx insn, edge
*** 1472,1478 ****
noccmode = false;
#endif
! killed = OBSTACK_ALLOC_REG_SET (®_obstack);
for (x = insn; x; x = NEXT_INSN (x))
if (INSN_P (x))
--- 1470,1476 ----
noccmode = false;
#endif
! killed = ALLOC_REG_SET (®_obstack);
for (x = insn; x; x = NEXT_INSN (x))
if (INSN_P (x))
*************** cfg_layout_split_edge (edge e)
*** 2855,2862 ****
create it to avoid getting an ICE later. */
if (e->dest->global_live_at_start)
{
! new_bb->global_live_at_start = OBSTACK_ALLOC_REG_SET (®_obstack);
! new_bb->global_live_at_end = OBSTACK_ALLOC_REG_SET (®_obstack);
COPY_REG_SET (new_bb->global_live_at_start,
e->dest->global_live_at_start);
COPY_REG_SET (new_bb->global_live_at_end,
--- 2853,2860 ----
create it to avoid getting an ICE later. */
if (e->dest->global_live_at_start)
{
! new_bb->global_live_at_start = ALLOC_REG_SET (®_obstack);
! new_bb->global_live_at_end = ALLOC_REG_SET (®_obstack);
COPY_REG_SET (new_bb->global_live_at_start,
e->dest->global_live_at_start);
COPY_REG_SET (new_bb->global_live_at_end,
Index: flow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flow.c,v
retrieving revision 1.610
diff -c -3 -p -r1.610 flow.c
*** flow.c 22 Nov 2004 12:23:48 -0000 1.610
--- flow.c 23 Nov 2004 11:00:22 -0000
*************** update_life_info (sbitmap blocks, enum u
*** 575,581 ****
int stabilized_prop_flags = prop_flags;
basic_block bb;
! tmp = OBSTACK_ALLOC_REG_SET (®_obstack);
ndead = 0;
if ((prop_flags & PROP_REG_INFO) && !reg_deaths)
--- 575,581 ----
int stabilized_prop_flags = prop_flags;
basic_block bb;
! tmp = ALLOC_REG_SET (®_obstack);
ndead = 0;
if ((prop_flags & PROP_REG_INFO) && !reg_deaths)
*************** calculate_global_regs_live (sbitmap bloc
*** 1033,1041 ****
gcc_assert (!bb->aux);
#endif
! tmp = OBSTACK_ALLOC_REG_SET (®_obstack);
! new_live_at_end = OBSTACK_ALLOC_REG_SET (®_obstack);
! invalidated_by_call = OBSTACK_ALLOC_REG_SET (®_obstack);
/* Inconveniently, this is only readily available in hard reg set form. */
for (i = 0; i < FIRST_PSEUDO_REGISTER; ++i)
--- 1033,1041 ----
gcc_assert (!bb->aux);
#endif
! tmp = ALLOC_REG_SET (®_obstack);
! new_live_at_end = ALLOC_REG_SET (®_obstack);
! invalidated_by_call = ALLOC_REG_SET (®_obstack);
/* Inconveniently, this is only readily available in hard reg set form. */
for (i = 0; i < FIRST_PSEUDO_REGISTER; ++i)
*************** calculate_global_regs_live (sbitmap bloc
*** 1189,1196 ****
if (local_sets[bb->index - (INVALID_BLOCK + 1)] == NULL)
{
! local_sets[bb->index - (INVALID_BLOCK + 1)] = XMALLOC_REG_SET ();
! cond_local_sets[bb->index - (INVALID_BLOCK + 1)] = XMALLOC_REG_SET ();
rescan = 1;
}
else
--- 1189,1198 ----
if (local_sets[bb->index - (INVALID_BLOCK + 1)] == NULL)
{
! local_sets[bb->index - (INVALID_BLOCK + 1)]
! = ALLOC_REG_SET (®_obstack);
! cond_local_sets[bb->index - (INVALID_BLOCK + 1)]
! = ALLOC_REG_SET (®_obstack);
rescan = 1;
}
else
*************** calculate_global_regs_live (sbitmap bloc
*** 1294,1309 ****
EXECUTE_IF_SET_IN_SBITMAP (blocks_out, 0, i,
{
basic_block bb = BASIC_BLOCK (i);
! XFREE_REG_SET (local_sets[bb->index - (INVALID_BLOCK + 1)]);
! XFREE_REG_SET (cond_local_sets[bb->index - (INVALID_BLOCK + 1)]);
});
}
else
{
FOR_EACH_BB (bb)
{
! XFREE_REG_SET (local_sets[bb->index - (INVALID_BLOCK + 1)]);
! XFREE_REG_SET (cond_local_sets[bb->index - (INVALID_BLOCK + 1)]);
}
}
--- 1296,1311 ----
EXECUTE_IF_SET_IN_SBITMAP (blocks_out, 0, i,
{
basic_block bb = BASIC_BLOCK (i);
! FREE_REG_SET (local_sets[bb->index - (INVALID_BLOCK + 1)]);
! FREE_REG_SET (cond_local_sets[bb->index - (INVALID_BLOCK + 1)]);
});
}
else
{
FOR_EACH_BB (bb)
{
! FREE_REG_SET (local_sets[bb->index - (INVALID_BLOCK + 1)]);
! FREE_REG_SET (cond_local_sets[bb->index - (INVALID_BLOCK + 1)]);
}
}
*************** allocate_bb_life_data (void)
*** 1436,1446 ****
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
{
! bb->global_live_at_start = OBSTACK_ALLOC_REG_SET (®_obstack);
! bb->global_live_at_end = OBSTACK_ALLOC_REG_SET (®_obstack);
}
! regs_live_at_setjmp = OBSTACK_ALLOC_REG_SET (®_obstack);
}
void
--- 1438,1448 ----
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
{
! bb->global_live_at_start = ALLOC_REG_SET (®_obstack);
! bb->global_live_at_end = ALLOC_REG_SET (®_obstack);
}
! regs_live_at_setjmp = ALLOC_REG_SET (®_obstack);
}
void
*************** init_propagate_block_info (basic_block b
*** 1843,1849 ****
if (JUMP_P (BB_END (bb))
&& any_condjump_p (BB_END (bb)))
{
! regset diff = OBSTACK_ALLOC_REG_SET (®_obstack);
basic_block bb_true, bb_false;
unsigned i;
--- 1845,1851 ----
if (JUMP_P (BB_END (bb))
&& any_condjump_p (BB_END (bb)))
{
! regset diff = ALLOC_REG_SET (®_obstack);
basic_block bb_true, bb_false;
unsigned i;
Index: global.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/global.c,v
retrieving revision 1.117
diff -c -3 -p -r1.117 global.c
*** global.c 22 Nov 2004 12:23:50 -0000 1.117
--- global.c 23 Nov 2004 11:02:56 -0000
*************** build_insn_chain (rtx first)
*** 1805,1811 ****
struct insn_chain *prev = 0;
basic_block b = ENTRY_BLOCK_PTR->next_bb;
! live_relevant_regs = OBSTACK_ALLOC_REG_SET (®_obstack);
for (; first; first = NEXT_INSN (first))
{
--- 1805,1811 ----
struct insn_chain *prev = 0;
basic_block b = ENTRY_BLOCK_PTR->next_bb;
! live_relevant_regs = ALLOC_REG_SET (®_obstack);
for (; first; first = NEXT_INSN (first))
{
Index: ifcvt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ifcvt.c,v
retrieving revision 1.172
diff -c -3 -p -r1.172 ifcvt.c
*** ifcvt.c 22 Nov 2004 12:23:52 -0000 1.172
--- ifcvt.c 23 Nov 2004 11:03:09 -0000
*************** dead_or_predicable (basic_block test_bb,
*** 3165,3174 ****
TEST_SET = set of registers set between EARLIEST and the
end of the block. */
! tmp = OBSTACK_ALLOC_REG_SET (®_obstack);
! merge_set = OBSTACK_ALLOC_REG_SET (®_obstack);
! test_live = OBSTACK_ALLOC_REG_SET (®_obstack);
! test_set = OBSTACK_ALLOC_REG_SET (®_obstack);
/* ??? bb->local_set is only valid during calculate_global_regs_live,
so we must recompute usage for MERGE_BB. Not so bad, I suppose,
--- 3165,3174 ----
TEST_SET = set of registers set between EARLIEST and the
end of the block. */
! tmp = ALLOC_REG_SET (®_obstack);
! merge_set = ALLOC_REG_SET (®_obstack);
! test_live = ALLOC_REG_SET (®_obstack);
! test_set = ALLOC_REG_SET (®_obstack);
/* ??? bb->local_set is only valid during calculate_global_regs_live,
so we must recompute usage for MERGE_BB. Not so bad, I suppose,
Index: loop-iv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-iv.c,v
retrieving revision 2.23
diff -c -3 -p -r2.23 loop-iv.c
*** loop-iv.c 22 Nov 2004 12:23:53 -0000 2.23
--- loop-iv.c 23 Nov 2004 11:03:40 -0000
*************** simplify_using_initial_values (struct lo
*** 1778,1784 ****
if (e->src == ENTRY_BLOCK_PTR)
return;
! altered = OBSTACK_ALLOC_REG_SET (®_obstack);
while (1)
{
--- 1778,1784 ----
if (e->src == ENTRY_BLOCK_PTR)
return;
! altered = ALLOC_REG_SET (®_obstack);
while (1)
{
Index: recog.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/recog.c,v
retrieving revision 1.213
diff -c -3 -p -r1.213 recog.c
*** recog.c 22 Nov 2004 12:23:54 -0000 1.213
--- recog.c 23 Nov 2004 11:05:49 -0000
*************** peephole2_optimize (FILE *dump_file ATTR
*** 2988,2995 ****
/* Initialize the regsets we're going to use. */
for (i = 0; i < MAX_INSNS_PER_PEEP2 + 1; ++i)
! peep2_insn_data[i].live_before = OBSTACK_ALLOC_REG_SET (®_obstack);
! live = OBSTACK_ALLOC_REG_SET (®_obstack);
#ifdef HAVE_conditional_execution
blocks = sbitmap_alloc (last_basic_block);
--- 2988,2995 ----
/* Initialize the regsets we're going to use. */
for (i = 0; i < MAX_INSNS_PER_PEEP2 + 1; ++i)
! peep2_insn_data[i].live_before = ALLOC_REG_SET (®_obstack);
! live = ALLOC_REG_SET (®_obstack);
#ifdef HAVE_conditional_execution
blocks = sbitmap_alloc (last_basic_block);
Index: sched-deps.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sched-deps.c,v
retrieving revision 1.86
diff -c -3 -p -r1.86 sched-deps.c
*** sched-deps.c 22 Nov 2004 12:23:57 -0000 1.86
--- sched-deps.c 23 Nov 2004 11:07:12 -0000
*************** free_dependency_caches (void)
*** 1591,1599 ****
void
init_deps_global (void)
{
! reg_pending_sets = OBSTACK_ALLOC_REG_SET (®_obstack);
! reg_pending_clobbers = OBSTACK_ALLOC_REG_SET (®_obstack);
! reg_pending_uses = OBSTACK_ALLOC_REG_SET (®_obstack);
reg_pending_barrier = NOT_A_BARRIER;
}
--- 1591,1599 ----
void
init_deps_global (void)
{
! reg_pending_sets = ALLOC_REG_SET (®_obstack);
! reg_pending_clobbers = ALLOC_REG_SET (®_obstack);
! reg_pending_uses = ALLOC_REG_SET (®_obstack);
reg_pending_barrier = NOT_A_BARRIER;
}