This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
More alloca patches
- To: gcc-patches at gcc dot gnu dot org
- Subject: More alloca patches
- From: "Mark P. Mitchell" <mark at codesourcery dot com>
- Date: Mon, 1 Nov 1999 16:20:23 -0700 (MST)
- Reply-to: mark at codesourcery dot com
Here are some more patches replacing alloca with xmalloc. Tested on
mips-sgi-irix6.5.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
Mon Nov 1 15:41:01 1999 Mark P. Mitchell <mark@codesourcery.com>
* bitmap.h (BITMAP_XMALLOC): New macro.
* flow.c (CLEAN_ALLOCA): Remove.
(delete_unreachable_blocks): Use xmalloc/xcalloc instead of alloca.
(life_analysis): Likewise.
(update_life_info): Don't use CLEAN_ALLOCA.
(life_analysis_1): Use xmalloc/xcalloc instead of alloca.
(calculate_global_regs_live): Likewise.
(print_rtl_with_bb): Likewise.
(verify_flow_info): Likewise.
* global.c (global_alloc): Likewise.
(global_conflicts): Likewise.
* integrate.c (save_for_inline_nocopy): Likewise.
(expand_inline_function): Likewise.
* jump.c (jump_optimize_1): Likewise.
(duplicate_loop_exit_test): Likewise.
(thread_jumps): Likewise.
* loop.c (loop_optimize): Likewise.
(combine_givs): Likewise.
(recombine_givs): Likewise.
* reorg.c (dbr_schedule): Likewise.
* unroll.c (unroll_loop): Likewise.
Index: bitmap.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/bitmap.h,v
retrieving revision 1.14
diff -c -p -r1.14 bitmap.h
*** bitmap.h 1999/10/27 01:25:12 1.14
--- bitmap.h 1999/11/01 22:50:14
*************** extern void debug_bitmap PROTO((bitmap))
*** 114,119 ****
--- 114,123 ----
#define BITMAP_ALLOCA() \
bitmap_initialize ((bitmap) alloca (sizeof (bitmap_head)))
+ /* Allocate a bitmap with xmalloc. */
+ #define BITMAP_XMALLOC() \
+ bitmap_initialize ((bitmap) xmalloc (sizeof (bitmap_head)))
+
/* Do any cleanup needed on a bitmap when it is no longer used. */
#define BITMAP_FREE(BITMAP) \
do { \
Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.180
diff -c -p -r1.180 flow.c
*** flow.c 1999/11/01 08:53:40 1.180
--- flow.c 1999/11/01 22:50:17
*************** Boston, MA 02111-1307, USA. */
*** 157,169 ****
#define HAVE_prologue 0
#endif
- #ifdef USE_C_ALLOCA
- #define CLEAN_ALLOCA alloca (0)
- #else
- #define CLEAN_ALLOCA
- #endif
-
-
/* The contents of the current function definition are allocated
in this obstack, and all are freed at the end of the function.
For top-level functions, this is temporary_obstack.
--- 157,162 ----
*************** delete_unreachable_blocks ()
*** 1668,1674 ****
int i, n;
n = n_basic_blocks;
! tos = worklist = (basic_block *) alloca (sizeof (basic_block) * n);
/* Use basic_block->aux as a marker. Clear them all. */
--- 1661,1667 ----
int i, n;
n = n_basic_blocks;
! tos = worklist = (basic_block *) xmalloc (sizeof (basic_block) * n);
/* Use basic_block->aux as a marker. Clear them all. */
*************** delete_unreachable_blocks ()
*** 1752,1757 ****
--- 1745,1752 ----
blocks to remove as well. */
if (deleted_handler)
delete_eh_regions ();
+
+ free (worklist);
}
/* Find EH regions for which there is no longer a handler, and delete them. */
*************** life_analysis (f, nregs, file, remove_de
*** 2453,2459 ****
#endif
/* Allocate a bitmap to be filled in by record_volatile_insns. */
! uid_volatile = BITMAP_ALLOCA ();
/* We want alias analysis information for local dead store elimination. */
init_alias_analysis ();
--- 2448,2454 ----
#endif
/* Allocate a bitmap to be filled in by record_volatile_insns. */
! uid_volatile = BITMAP_XMALLOC ();
/* We want alias analysis information for local dead store elimination. */
init_alias_analysis ();
*************** life_analysis (f, nregs, file, remove_de
*** 2472,2477 ****
--- 2467,2473 ----
dump_flow_info (file);
BITMAP_FREE (uid_volatile);
+ free (uid_volatile);
free_basic_block_vars (1);
}
*************** update_life_info (blocks, extent, prop_f
*** 2601,2608 ****
if (extent == UPDATE_LIFE_LOCAL)
verify_local_live_at_start (tmp, bb);
-
- CLEAN_ALLOCA;
});
FREE_REG_SET (tmp);
--- 2597,2602 ----
*************** life_analysis_1 (f, nregs, flags)
*** 2916,2923 ****
allocate_reg_life_data ();
allocate_bb_life_data ();
! reg_next_use = (rtx *) alloca (nregs * sizeof (rtx));
! memset (reg_next_use, 0, nregs * sizeof (rtx));
/* Assume that the stack pointer is unchanging if alloca hasn't been used.
This will be cleared by record_volatile_insns if it encounters an insn
--- 2910,2916 ----
allocate_reg_life_data ();
allocate_bb_life_data ();
! reg_next_use = (rtx *) xcalloc (nregs, sizeof (rtx));
/* Assume that the stack pointer is unchanging if alloca hasn't been used.
This will be cleared by record_volatile_insns if it encounters an insn
*************** life_analysis_1 (f, nregs, flags)
*** 2971,2978 ****
COPY_REG_SET (tmp, bb->global_live_at_end);
propagate_block (tmp, bb->head, bb->end, (regset) NULL, i, flags);
-
- CLEAN_ALLOCA;
}
FREE_REG_SET (tmp);
--- 2964,2969 ----
*************** life_analysis_1 (f, nregs, flags)
*** 3000,3005 ****
--- 2991,2998 ----
if (reload_completed)
memcpy (regs_ever_live, save_regs_ever_live, sizeof (regs_ever_live));
+ /* Clean up. */
+ free (reg_next_use);
reg_next_use = NULL;
}
*************** calculate_global_regs_live (blocks_in, b
*** 3022,3028 ****
/* Create a worklist. Allocate an extra slot for ENTRY_BLOCK, and one
because the `head == tail' style test for an empty queue doesn't
work with a full queue. */
! queue = (basic_block *) alloca ((n_basic_blocks + 2) * sizeof (*queue));
qtail = queue;
qhead = qend = queue + n_basic_blocks + 2;
--- 3015,3021 ----
/* Create a worklist. Allocate an extra slot for ENTRY_BLOCK, and one
because the `head == tail' style test for an empty queue doesn't
work with a full queue. */
! queue = (basic_block *) xmalloc ((n_basic_blocks + 2) * sizeof (*queue));
qtail = queue;
qhead = qend = queue + n_basic_blocks + 2;
*************** calculate_global_regs_live (blocks_in, b
*** 3158,3163 ****
--- 3151,3158 ----
basic_block bb = BASIC_BLOCK (i);
FREE_REG_SET (bb->local_set);
});
+
+ free (queue);
}
/* Subroutines of life analysis. */
*************** print_rtl_with_bb (outf, rtx_first)
*** 5069,5083 ****
enum bb_state { NOT_IN_BB, IN_ONE_BB, IN_MULTIPLE_BB };
int max_uid = get_max_uid ();
basic_block *start = (basic_block *)
! alloca (max_uid * sizeof (basic_block));
basic_block *end = (basic_block *)
! alloca (max_uid * sizeof (basic_block));
enum bb_state *in_bb_p = (enum bb_state *)
! alloca (max_uid * sizeof (enum bb_state));
!
! memset (start, 0, max_uid * sizeof (basic_block));
! memset (end, 0, max_uid * sizeof (basic_block));
! memset (in_bb_p, 0, max_uid * sizeof (enum bb_state));
for (i = n_basic_blocks - 1; i >= 0; i--)
{
--- 5064,5074 ----
enum bb_state { NOT_IN_BB, IN_ONE_BB, IN_MULTIPLE_BB };
int max_uid = get_max_uid ();
basic_block *start = (basic_block *)
! xcalloc (max_uid, sizeof (basic_block));
basic_block *end = (basic_block *)
! xcalloc (max_uid, sizeof (basic_block));
enum bb_state *in_bb_p = (enum bb_state *)
! xcalloc (max_uid, sizeof (enum bb_state));
for (i = n_basic_blocks - 1; i >= 0; i--)
{
*************** print_rtl_with_bb (outf, rtx_first)
*** 5134,5139 ****
--- 5125,5134 ----
if (did_output)
putc ('\n', outf);
}
+
+ free (start);
+ free (end);
+ free (in_bb_p);
}
if (current_function_epilogue_delay_list != 0)
*************** verify_flow_info ()
*** 5878,5885 ****
rtx x;
int i, err = 0;
! bb_info = (basic_block *) alloca (max_uid * sizeof (basic_block));
! memset (bb_info, 0, max_uid * sizeof (basic_block));
/* First pass check head/end pointers and set bb_info array used by
later passes. */
--- 5873,5879 ----
rtx x;
int i, err = 0;
! bb_info = (basic_block *) xcalloc (max_uid, sizeof (basic_block));
/* First pass check head/end pointers and set bb_info array used by
later passes. */
*************** verify_flow_info ()
*** 6074,6079 ****
--- 6068,6076 ----
if (err)
abort ();
+
+ /* Clean up. */
+ free (bb_info);
}
/* Functions to access an edge list with a vector representation.
Index: global.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/global.c,v
retrieving revision 1.38
diff -c -p -r1.38 global.c
*** global.c 1999/10/27 19:27:41 1.38
--- global.c 1999/11/01 22:50:20
*************** global_alloc (file)
*** 372,386 ****
/* Establish mappings from register number to allocation number
and vice versa. In the process, count the allocnos. */
! reg_allocno = (int *) alloca (max_regno * sizeof (int));
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
reg_allocno[i] = -1;
/* Initialize the shared-hard-reg mapping
from the list of pairs that may share. */
! reg_may_share = (int *) alloca (max_regno * sizeof (int));
! bzero ((char *) reg_may_share, max_regno * sizeof (int));
for (x = regs_may_share; x; x = XEXP (XEXP (x, 1), 1))
{
int r1 = REGNO (XEXP (x, 0));
--- 372,385 ----
/* Establish mappings from register number to allocation number
and vice versa. In the process, count the allocnos. */
! reg_allocno = (int *) xmalloc (max_regno * sizeof (int));
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
reg_allocno[i] = -1;
/* Initialize the shared-hard-reg mapping
from the list of pairs that may share. */
! reg_may_share = (int *) xcalloc (max_regno, sizeof (int));
for (x = regs_may_share; x; x = XEXP (XEXP (x, 1), 1))
{
int r1 = REGNO (XEXP (x, 0));
*************** global_alloc (file)
*** 411,425 ****
else
reg_allocno[i] = -1;
! allocno_reg = (int *) alloca (max_allocno * sizeof (int));
! allocno_size = (int *) alloca (max_allocno * sizeof (int));
! allocno_calls_crossed = (int *) alloca (max_allocno * sizeof (int));
! allocno_n_refs = (int *) alloca (max_allocno * sizeof (int));
! allocno_live_length = (int *) alloca (max_allocno * sizeof (int));
! bzero ((char *) allocno_size, max_allocno * sizeof (int));
! bzero ((char *) allocno_calls_crossed, max_allocno * sizeof (int));
! bzero ((char *) allocno_n_refs, max_allocno * sizeof (int));
! bzero ((char *) allocno_live_length, max_allocno * sizeof (int));
for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
if (reg_allocno[i] >= 0)
--- 410,420 ----
else
reg_allocno[i] = -1;
! allocno_reg = (int *) xmalloc (max_allocno * sizeof (int));
! allocno_size = (int *) xcalloc (max_allocno, sizeof (int));
! allocno_calls_crossed = (int *) xcalloc (max_allocno, sizeof (int));
! allocno_n_refs = (int *) xcalloc (max_allocno, sizeof (int));
! allocno_live_length = (int *) xcalloc (max_allocno, sizeof (int));
for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
if (reg_allocno[i] >= 0)
*************** global_alloc (file)
*** 461,486 ****
initialize them. */
hard_reg_conflicts
! = (HARD_REG_SET *) alloca (max_allocno * sizeof (HARD_REG_SET));
! bzero ((char *) hard_reg_conflicts, max_allocno * sizeof (HARD_REG_SET));
!
hard_reg_preferences
! = (HARD_REG_SET *) alloca (max_allocno * sizeof (HARD_REG_SET));
! bzero ((char *) hard_reg_preferences, max_allocno * sizeof (HARD_REG_SET));
!
hard_reg_copy_preferences
! = (HARD_REG_SET *) alloca (max_allocno * sizeof (HARD_REG_SET));
! bzero ((char *) hard_reg_copy_preferences,
! max_allocno * sizeof (HARD_REG_SET));
!
hard_reg_full_preferences
! = (HARD_REG_SET *) alloca (max_allocno * sizeof (HARD_REG_SET));
! bzero ((char *) hard_reg_full_preferences,
! max_allocno * sizeof (HARD_REG_SET));
!
regs_someone_prefers
! = (HARD_REG_SET *) alloca (max_allocno * sizeof (HARD_REG_SET));
! bzero ((char *) regs_someone_prefers, max_allocno * sizeof (HARD_REG_SET));
allocno_row_words = (max_allocno + INT_BITS - 1) / INT_BITS;
--- 456,470 ----
initialize them. */
hard_reg_conflicts
! = (HARD_REG_SET *) xcalloc (max_allocno, sizeof (HARD_REG_SET));
hard_reg_preferences
! = (HARD_REG_SET *) xcalloc (max_allocno, sizeof (HARD_REG_SET));
hard_reg_copy_preferences
! = (HARD_REG_SET *) xcalloc (max_allocno, sizeof (HARD_REG_SET));
hard_reg_full_preferences
! = (HARD_REG_SET *) xcalloc (max_allocno, sizeof (HARD_REG_SET));
regs_someone_prefers
! = (HARD_REG_SET *) xcalloc (max_allocno, sizeof (HARD_REG_SET));
allocno_row_words = (max_allocno + INT_BITS - 1) / INT_BITS;
*************** global_alloc (file)
*** 490,496 ****
conflicts = (INT_TYPE *) xcalloc (max_allocno * allocno_row_words,
sizeof (INT_TYPE));
! allocnos_live = (INT_TYPE *) alloca (allocno_row_words * sizeof (INT_TYPE));
/* If there is work to be done (at least one reg to allocate),
perform global conflict analysis and allocate the regs. */
--- 474,480 ----
conflicts = (INT_TYPE *) xcalloc (max_allocno * allocno_row_words,
sizeof (INT_TYPE));
! allocnos_live = (INT_TYPE *) xmalloc (allocno_row_words * sizeof (INT_TYPE));
/* If there is work to be done (at least one reg to allocate),
perform global conflict analysis and allocate the regs. */
*************** global_alloc (file)
*** 523,529 ****
/* Determine the order to allocate the remaining pseudo registers. */
! allocno_order = (int *) alloca (max_allocno * sizeof (int));
for (i = 0; i < (size_t) max_allocno; i++)
allocno_order[i] = i;
--- 507,513 ----
/* Determine the order to allocate the remaining pseudo registers. */
! allocno_order = (int *) xmalloc (max_allocno * sizeof (int));
for (i = 0; i < (size_t) max_allocno; i++)
allocno_order[i] = i;
*************** global_alloc (file)
*** 568,573 ****
--- 552,559 ----
if (reg_alternate_class (allocno_reg[allocno_order[i]]) != NO_REGS)
find_reg (allocno_order[i], 0, 1, 0, 0);
}
+
+ free (allocno_order);
}
/* Do the reloads now while the allocno data still exist, so that we can
*************** global_alloc (file)
*** 582,588 ****
--- 568,589 ----
retval = reload (get_insns (), 1, file);
}
+ /* Clean up. */
+ free (reg_allocno);
+ free (reg_may_share);
+ free (allocno_reg);
+ free (allocno_size);
+ free (allocno_calls_crossed);
+ free (allocno_n_refs);
+ free (allocno_live_length);
+ free (hard_reg_conflicts);
+ free (hard_reg_preferences);
+ free (hard_reg_copy_preferences);
+ free (hard_reg_full_preferences);
+ free (regs_someone_prefers);
free (conflicts);
+ free (allocnos_live);
+
return retval;
}
*************** global_conflicts ()
*** 626,634 ****
int *block_start_allocnos;
/* Make a vector that mark_reg_{store,clobber} will store in. */
! regs_set = (rtx *) alloca (max_parallel * sizeof (rtx) * 2);
! block_start_allocnos = (int *) alloca (max_allocno * sizeof (int));
for (b = 0; b < n_basic_blocks; b++)
{
--- 627,635 ----
int *block_start_allocnos;
/* Make a vector that mark_reg_{store,clobber} will store in. */
! regs_set = (rtx *) xmalloc (max_parallel * sizeof (rtx) * 2);
! block_start_allocnos = (int *) xmalloc (max_allocno * sizeof (int));
for (b = 0; b < n_basic_blocks; b++)
{
*************** global_conflicts ()
*** 788,793 ****
--- 789,798 ----
insn = NEXT_INSN (insn);
}
}
+
+ /* Clean up. */
+ free (block_start_allocnos);
+ free (regs_set);
}
/* Expand the preference information by looking for cases where one allocno
dies in an insn that sets an allocno. If those two allocnos don't conflict,
Index: integrate.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/integrate.c,v
retrieving revision 1.77
diff -c -p -r1.77 integrate.c
*** integrate.c 1999/11/01 06:04:59 1.77
--- integrate.c 1999/11/01 22:50:21
*************** save_for_inline_nocopy (fndecl)
*** 350,356 ****
for the parms, prior to elimination of virtual registers.
These values are needed for substituting parms properly. */
! parmdecl_map = (tree *) alloca (max_parm_reg * sizeof (tree));
/* Make and emit a return-label if we have not already done so. */
--- 350,356 ----
for the parms, prior to elimination of virtual registers.
These values are needed for substituting parms properly. */
! parmdecl_map = (tree *) xmalloc (max_parm_reg * sizeof (tree));
/* Make and emit a return-label if we have not already done so. */
*************** save_for_inline_nocopy (fndecl)
*** 401,406 ****
--- 401,409 ----
current_function->original_arg_vector = argvec;
current_function->original_decl_initial = DECL_INITIAL (fndecl);
DECL_SAVED_INSNS (fndecl) = current_function;
+
+ /* Clean up. */
+ free (parmdecl_map);
}
/* Note whether a parameter is modified or not. */
*************** expand_inline_function (fndecl, parms, t
*** 566,573 ****
/* Expand the function arguments. Do this first so that any
new registers get created before we allocate the maps. */
! arg_vals = (rtx *) alloca (nargs * sizeof (rtx));
! arg_trees = (tree *) alloca (nargs * sizeof (tree));
for (formal = DECL_ARGUMENTS (fndecl), actual = parms, i = 0;
formal;
--- 569,576 ----
/* Expand the function arguments. Do this first so that any
new registers get created before we allocate the maps. */
! arg_vals = (rtx *) xmalloc (nargs * sizeof (rtx));
! arg_trees = (tree *) xmalloc (nargs * sizeof (tree));
for (formal = DECL_ARGUMENTS (fndecl), actual = parms, i = 0;
formal;
*************** expand_inline_function (fndecl, parms, t
*** 649,659 ****
/* Allocate the structures we use to remap things. */
! map = (struct inline_remap *) alloca (sizeof (struct inline_remap));
map->fndecl = fndecl;
! map->reg_map = (rtx *) alloca (max_regno * sizeof (rtx));
! bzero ((char *) map->reg_map, max_regno * sizeof (rtx));
/* We used to use alloca here, but the size of what it would try to
allocate would occasionally cause it to exceed the stack limit and
--- 652,661 ----
/* Allocate the structures we use to remap things. */
! map = (struct inline_remap *) xmalloc (sizeof (struct inline_remap));
map->fndecl = fndecl;
! map->reg_map = (rtx *) xcalloc (max_regno, sizeof (rtx));
/* We used to use alloca here, but the size of what it would try to
allocate would occasionally cause it to exceed the stack limit and
*************** expand_inline_function (fndecl, parms, t
*** 663,670 ****
map->label_map = real_label_map;
inl_max_uid = (inl_f->emit->x_cur_insn_uid + 1);
! map->insn_map = (rtx *) alloca (inl_max_uid * sizeof (rtx));
! bzero ((char *) map->insn_map, inl_max_uid * sizeof (rtx));
map->min_insnno = 0;
map->max_insnno = inl_max_uid;
--- 665,671 ----
map->label_map = real_label_map;
inl_max_uid = (inl_f->emit->x_cur_insn_uid + 1);
! map->insn_map = (rtx *) xcalloc (inl_max_uid, sizeof (rtx));
map->min_insnno = 0;
map->max_insnno = inl_max_uid;
*************** expand_inline_function (fndecl, parms, t
*** 1356,1363 ****
/* Make sure we free the things we explicitly allocated with xmalloc. */
if (real_label_map)
free (real_label_map);
! if (map)
! VARRAY_FREE (map->const_equiv_varray);
inlining = inlining_previous;
return target;
--- 1357,1369 ----
/* Make sure we free the things we explicitly allocated with xmalloc. */
if (real_label_map)
free (real_label_map);
! VARRAY_FREE (map->const_equiv_varray);
! free (map->reg_map);
! free (map->insn_map);
! free (map);
! free (arg_vals);
! free (arg_trees);
!
inlining = inlining_previous;
return target;
Index: jump.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/jump.c,v
retrieving revision 1.86
diff -c -p -r1.86 jump.c
*** jump.c 1999/11/01 01:11:20 1.86
--- jump.c 1999/11/01 22:50:22
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 205,212 ****
/* Leave some extra room for labels and duplicate exit test insns
we make. */
max_jump_chain = max_uid * 14 / 10;
! jump_chain = (rtx *) alloca (max_jump_chain * sizeof (rtx));
! bzero ((char *) jump_chain, max_jump_chain * sizeof (rtx));
mark_all_labels (f, cross_jump);
--- 205,211 ----
/* Leave some extra room for labels and duplicate exit test insns
we make. */
max_jump_chain = max_uid * 14 / 10;
! jump_chain = (rtx *) xcalloc (max_jump_chain, sizeof (rtx));
mark_all_labels (f, cross_jump);
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 227,233 ****
/* Quit now if we just wanted to rebuild the JUMP_LABEL and REG_LABEL
notes and recompute LABEL_NUSES. */
if (mark_labels_only)
! return;
exception_optimize ();
--- 226,232 ----
/* Quit now if we just wanted to rebuild the JUMP_LABEL and REG_LABEL
notes and recompute LABEL_NUSES. */
if (mark_labels_only)
! goto end;
exception_optimize ();
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 245,254 ****
/* Zero the "deleted" flag of all the "deleted" insns. */
for (insn = f; insn; insn = NEXT_INSN (insn))
INSN_DELETED_P (insn) = 0;
!
! /* Show that the jump chain is not valid. */
! jump_chain = 0;
! return;
}
#ifdef HAVE_return
--- 244,251 ----
/* Zero the "deleted" flag of all the "deleted" insns. */
for (insn = f; insn; insn = NEXT_INSN (insn))
INSN_DELETED_P (insn) = 0;
!
! goto end;
}
#ifdef HAVE_return
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 2301,2307 ****
if (calculate_can_reach_end (last_insn, 0, 1))
can_reach_end = 1;
! /* Show JUMP_CHAIN no longer valid. */
jump_chain = 0;
}
--- 2298,2306 ----
if (calculate_can_reach_end (last_insn, 0, 1))
can_reach_end = 1;
! end:
! /* Clean up. */
! free (jump_chain);
jump_chain = 0;
}
*************** duplicate_loop_exit_test (loop_start)
*** 2872,2881 ****
/* We can do the replacement. Allocate reg_map if this is the
first replacement we found. */
if (reg_map == 0)
! {
! reg_map = (rtx *) alloca (max_reg * sizeof (rtx));
! bzero ((char *) reg_map, max_reg * sizeof (rtx));
! }
REG_LOOP_TEST_P (reg) = 1;
--- 2871,2877 ----
/* We can do the replacement. Allocate reg_map if this is the
first replacement we found. */
if (reg_map == 0)
! reg_map = (rtx *) xcalloc (max_reg, sizeof (rtx));
REG_LOOP_TEST_P (reg) = 1;
*************** duplicate_loop_exit_test (loop_start)
*** 2986,2991 ****
--- 2982,2991 ----
emit_note_before (NOTE_INSN_LOOP_VTOP, exitcode);
delete_insn (next_nonnote_insn (loop_start));
+
+ /* Clean up. */
+ if (reg_map)
+ free (reg_map);
return 1;
}
*************** thread_jumps (f, max_reg, flag_before_lo
*** 5182,5190 ****
int *all_reset;
/* Allocate register tables and quick-reset table. */
! modified_regs = (char *) alloca (max_reg * sizeof (char));
! same_regs = (int *) alloca (max_reg * sizeof (int));
! all_reset = (int *) alloca (max_reg * sizeof (int));
for (i = 0; i < max_reg; i++)
all_reset[i] = -1;
--- 5182,5190 ----
int *all_reset;
/* Allocate register tables and quick-reset table. */
! modified_regs = (char *) xmalloc (max_reg * sizeof (char));
! same_regs = (int *) xmalloc (max_reg * sizeof (int));
! all_reset = (int *) xmalloc (max_reg * sizeof (int));
for (i = 0; i < max_reg; i++)
all_reset[i] = -1;
*************** thread_jumps (f, max_reg, flag_before_lo
*** 5342,5347 ****
--- 5342,5352 ----
}
}
}
+
+ /* Clean up. */
+ free (modified_regs);
+ free (same_regs);
+ free (all_reset);
}
/* This is like RTX_EQUAL_P except that it knows about our handling of
Index: loop.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/loop.c,v
retrieving revision 1.194
diff -c -p -r1.194 loop.c
*** loop.c 1999/11/01 01:11:21 1.194
--- loop.c 1999/11/01 22:50:24
*************** loop_optimize (f, dumpfile, unroll_p, bc
*** 464,472 ****
max_reg_before_loop = max_reg_num ();
- moved_once = (char *) alloca (max_reg_before_loop);
- bzero (moved_once, max_reg_before_loop);
-
regs_may_share = 0;
/* Count the number of loops. */
--- 464,469 ----
*************** loop_optimize (f, dumpfile, unroll_p, bc
*** 483,513 ****
if (max_loop_num == 0)
return;
/* Get size to use for tables indexed by uids.
Leave some space for labels allocated by find_and_verify_loops. */
max_uid_for_loop = get_max_uid () + 1 + max_loop_num * 32;
-
- uid_luid = (int *) alloca (max_uid_for_loop * sizeof (int));
- uid_loop_num = (int *) alloca (max_uid_for_loop * sizeof (int));
! bzero ((char *) uid_luid, max_uid_for_loop * sizeof (int));
! bzero ((char *) uid_loop_num, max_uid_for_loop * sizeof (int));
/* Allocate tables for recording each loop. We set each entry, so they need
not be zeroed. */
! loop_number_loop_starts = (rtx *) alloca (max_loop_num * sizeof (rtx));
! loop_number_loop_ends = (rtx *) alloca (max_loop_num * sizeof (rtx));
! loop_number_loop_cont = (rtx *) alloca (max_loop_num * sizeof (rtx));
! loop_number_cont_dominator = (rtx *) alloca (max_loop_num * sizeof (rtx));
! loop_outer_loop = (int *) alloca (max_loop_num * sizeof (int));
! loop_invalid = (char *) alloca (max_loop_num * sizeof (char));
! loop_number_exit_labels = (rtx *) alloca (max_loop_num * sizeof (rtx));
! loop_number_exit_count = (int *) alloca (max_loop_num * sizeof (int));
#ifdef HAVE_decrement_and_branch_on_count
/* Allocate for BCT optimization */
! loop_used_count_register = (int *) alloca (max_loop_num * sizeof (int));
! bzero ((char *) loop_used_count_register, max_loop_num * sizeof (int));
#endif /* HAVE_decrement_and_branch_on_count */
/* Find and process each loop.
--- 480,508 ----
if (max_loop_num == 0)
return;
+ moved_once = (char *) xcalloc (max_reg_before_loop, sizeof (char));
+
/* Get size to use for tables indexed by uids.
Leave some space for labels allocated by find_and_verify_loops. */
max_uid_for_loop = get_max_uid () + 1 + max_loop_num * 32;
! uid_luid = (int *) xcalloc (max_uid_for_loop, sizeof (int));
! uid_loop_num = (int *) xcalloc (max_uid_for_loop, sizeof (int));
/* Allocate tables for recording each loop. We set each entry, so they need
not be zeroed. */
! loop_number_loop_starts = (rtx *) xmalloc (max_loop_num * sizeof (rtx));
! loop_number_loop_ends = (rtx *) xmalloc (max_loop_num * sizeof (rtx));
! loop_number_loop_cont = (rtx *) xmalloc (max_loop_num * sizeof (rtx));
! loop_number_cont_dominator = (rtx *) xmalloc (max_loop_num * sizeof (rtx));
! loop_outer_loop = (int *) xmalloc (max_loop_num * sizeof (int));
! loop_invalid = (char *) xmalloc (max_loop_num * sizeof (char));
! loop_number_exit_labels = (rtx *) xmalloc (max_loop_num * sizeof (rtx));
! loop_number_exit_count = (int *) xmalloc (max_loop_num * sizeof (int));
#ifdef HAVE_decrement_and_branch_on_count
/* Allocate for BCT optimization */
! loop_used_count_register = (int *) xcalloc (max_loop_num, sizeof (int));
#endif /* HAVE_decrement_and_branch_on_count */
/* Find and process each loop.
*************** loop_optimize (f, dumpfile, unroll_p, bc
*** 574,579 ****
--- 569,591 ----
unroll_block_trees ();
end_alias_analysis ();
+
+ /* Clean up. */
+ free (moved_once);
+ free (uid_luid);
+ free (uid_loop_num);
+ free (loop_number_loop_starts);
+ free (loop_number_loop_ends);
+ free (loop_number_loop_cont);
+ free (loop_number_cont_dominator);
+ free (loop_outer_loop);
+ free (loop_invalid);
+ free (loop_number_exit_labels);
+ free (loop_number_exit_count);
+ #ifdef HAVE_decrement_and_branch_on_count
+ free (loop_used_count_register);
+ #endif /* HAVE_decrement_and_branch_on_count */
+
}
/* Returns the next insn, in execution order, after INSN. START and
*************** combine_givs (bl)
*** 7115,7126 ****
for (g1 = bl->giv; g1; g1 = g1->next_iv)
if (!g1->ignore)
giv_array[i++] = g1;
-
- stats = (struct combine_givs_stats *) alloca (giv_count * sizeof (*stats));
- bzero ((char *) stats, giv_count * sizeof (*stats));
! can_combine = (rtx *) alloca (giv_count * giv_count * sizeof(rtx));
! bzero ((char *) can_combine, giv_count * giv_count * sizeof(rtx));
for (i = 0; i < giv_count; i++)
{
--- 7127,7135 ----
for (g1 = bl->giv; g1; g1 = g1->next_iv)
if (!g1->ignore)
giv_array[i++] = g1;
! stats = (struct combine_givs_stats *) xcalloc (giv_count, sizeof (*stats));
! can_combine = (rtx *) xcalloc (giv_count, giv_count * sizeof(rtx));
for (i = 0; i < giv_count; i++)
{
*************** restart:
*** 7250,7255 ****
--- 7259,7268 ----
goto restart;
}
}
+
+ /* Clean up. */
+ free (stats);
+ free (can_combine);
}
struct recombine_givs_stats
*************** recombine_givs (bl, loop_start, loop_end
*** 7387,7394 ****
giv_count++;
}
giv_array
! = (struct induction **) alloca (giv_count * sizeof (struct induction *));
! stats = (struct recombine_givs_stats *) alloca (giv_count * sizeof *stats);
/* Initialize stats and set up the ix field for each giv in stats to name
the corresponding index into stats. */
--- 7400,7407 ----
giv_count++;
}
giv_array
! = (struct induction **) xmalloc (giv_count * sizeof (struct induction *));
! stats = (struct recombine_givs_stats *) xmalloc (giv_count * sizeof *stats);
/* Initialize stats and set up the ix field for each giv in stats to name
the corresponding index into stats. */
*************** recombine_givs (bl, loop_start, loop_end
*** 7679,7684 ****
--- 7692,7701 ----
rescan = i;
}
}
+
+ /* Clean up. */
+ free (giv_array);
+ free (stats);
}
/* EMIT code before INSERT_BEFORE to set REG = B * M + A. */
Index: reorg.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reorg.c,v
retrieving revision 1.40
diff -c -p -r1.40 reorg.c
*** reorg.c 1999/09/20 09:59:52 1.40
--- reorg.c 1999/11/01 22:50:25
*************** dbr_schedule (first, file)
*** 3531,3537 ****
epilogue_insn = insn;
}
! uid_to_ruid = (int *) alloca ((max_uid + 1) * sizeof (int));
for (i = 0, insn = first; insn; i++, insn = NEXT_INSN (insn))
uid_to_ruid[INSN_UID (insn)] = i;
--- 3531,3537 ----
epilogue_insn = insn;
}
! uid_to_ruid = (int *) xmalloc ((max_uid + 1) * sizeof (int));
for (i = 0, insn = first; insn; i++, insn = NEXT_INSN (insn))
uid_to_ruid[INSN_UID (insn)] = i;
*************** dbr_schedule (first, file)
*** 3676,3680 ****
--- 3676,3681 ----
REG_NOTES (insn));
}
free_resource_info ();
+ free (uid_to_ruid);
}
#endif /* DELAY_SLOTS */
Index: unroll.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/unroll.c,v
retrieving revision 1.74
diff -c -p -r1.74 unroll.c
*** unroll.c 1999/11/01 01:11:22 1.74
--- unroll.c 1999/11/01 22:50:30
*************** unroll_loop (loop_end, insn_count, loop_
*** 682,688 ****
max_labelno = max_label_num ();
max_insnno = get_max_uid ();
! map = (struct inline_remap *) alloca (sizeof (struct inline_remap));
map->integrating = 0;
map->const_equiv_varray = 0;
--- 682,688 ----
max_labelno = max_label_num ();
max_insnno = get_max_uid ();
! map = (struct inline_remap *) xmalloc (sizeof (struct inline_remap));
map->integrating = 0;
map->const_equiv_varray = 0;
*************** unroll_loop (loop_end, insn_count, loop_
*** 691,700 ****
if (max_labelno > 0)
{
! map->label_map = (rtx *) alloca (max_labelno * sizeof (rtx));
! local_label = (char *) alloca (max_labelno);
! bzero (local_label, max_labelno);
}
else
map->label_map = 0;
--- 691,699 ----
if (max_labelno > 0)
{
! map->label_map = (rtx *) xmalloc (max_labelno * sizeof (rtx));
! local_label = (char *) xcalloc (max_labelno, sizeof (char));
}
else
map->label_map = 0;
*************** unroll_loop (loop_end, insn_count, loop_
*** 742,748 ****
/* Allocate space for the insn map. */
! map->insn_map = (rtx *) alloca (max_insnno * sizeof (rtx));
/* Set this to zero, to indicate that we are doing loop unrolling,
not function inlining. */
--- 741,747 ----
/* Allocate space for the insn map. */
! map->insn_map = (rtx *) xmalloc (max_insnno * sizeof (rtx));
/* Set this to zero, to indicate that we are doing loop unrolling,
not function inlining. */
*************** unroll_loop (loop_end, insn_count, loop_
*** 768,784 ****
preconditioning code and find_splittable_regs will never be used
to access the splittable_regs[] and addr_combined_regs[] arrays. */
! splittable_regs = (rtx *) alloca (maxregnum * sizeof (rtx));
! bzero ((char *) splittable_regs, maxregnum * sizeof (rtx));
! derived_regs = (char *) alloca (maxregnum);
! bzero (derived_regs, maxregnum);
! splittable_regs_updates = (int *) alloca (maxregnum * sizeof (int));
! bzero ((char *) splittable_regs_updates, maxregnum * sizeof (int));
addr_combined_regs
! = (struct induction **) alloca (maxregnum * sizeof (struct induction *));
! bzero ((char *) addr_combined_regs, maxregnum * sizeof (struct induction *));
! local_regno = (char *) alloca (maxregnum);
! bzero (local_regno, maxregnum);
/* Mark all local registers, i.e. the ones which are referenced only
inside the loop. */
--- 767,778 ----
preconditioning code and find_splittable_regs will never be used
to access the splittable_regs[] and addr_combined_regs[] arrays. */
! splittable_regs = (rtx *) xcalloc (maxregnum, sizeof (rtx));
! derived_regs = (char *) xcalloc (maxregnum, sizeof (char));
! splittable_regs_updates = (int *) xcalloc (maxregnum, sizeof (int));
addr_combined_regs
! = (struct induction **) xcalloc (maxregnum, sizeof (struct induction *));
! local_regno = (char *) xcalloc (maxregnum, sizeof (char));
/* Mark all local registers, i.e. the ones which are referenced only
inside the loop. */
*************** unroll_loop (loop_end, insn_count, loop_
*** 884,890 ****
rtx *labels;
int abs_inc, neg_inc;
! map->reg_map = (rtx *) alloca (maxregnum * sizeof (rtx));
VARRAY_CONST_EQUIV_INIT (map->const_equiv_varray, maxregnum,
"unroll_loop");
--- 878,884 ----
rtx *labels;
int abs_inc, neg_inc;
! map->reg_map = (rtx *) xmalloc (maxregnum * sizeof (rtx));
VARRAY_CONST_EQUIV_INIT (map->const_equiv_varray, maxregnum,
"unroll_loop");
*************** unroll_loop (loop_end, insn_count, loop_
*** 930,936 ****
/* Now emit a sequence of branches to jump to the proper precond
loop entry point. */
! labels = (rtx *) alloca (sizeof (rtx) * unroll_number);
for (i = 0; i < unroll_number; i++)
labels[i] = gen_label_rtx ();
--- 924,930 ----
/* Now emit a sequence of branches to jump to the proper precond
loop entry point. */
! labels = (rtx *) xmalloc (sizeof (rtx) * unroll_number);
for (i = 0; i < unroll_number; i++)
labels[i] = gen_label_rtx ();
*************** unroll_loop (loop_end, insn_count, loop_
*** 1109,1114 ****
--- 1103,1111 ----
/* Set unroll type to MODULO now. */
unroll_type = UNROLL_MODULO;
loop_preconditioned = 1;
+
+ /* Clean up. */
+ free (labels);
}
}
*************** unroll_loop (loop_end, insn_count, loop_
*** 1146,1152 ****
the constant maps also. */
maxregnum = max_reg_num ();
! map->reg_map = (rtx *) alloca (maxregnum * sizeof (rtx));
init_reg_map (map, maxregnum);
--- 1143,1149 ----
the constant maps also. */
maxregnum = max_reg_num ();
! map->reg_map = (rtx *) xmalloc (maxregnum * sizeof (rtx));
init_reg_map (map, maxregnum);
*************** unroll_loop (loop_end, insn_count, loop_
*** 1286,1293 ****
emit_label_after (exit_label, loop_end);
egress:
! if (map && map->const_equiv_varray)
VARRAY_FREE (map->const_equiv_varray);
}
/* Return true if the loop can be safely, and profitably, preconditioned
--- 1283,1304 ----
emit_label_after (exit_label, loop_end);
egress:
! if (map->const_equiv_varray)
VARRAY_FREE (map->const_equiv_varray);
+ if (map->label_map)
+ {
+ free (map->label_map);
+ free (local_label);
+ }
+ free (map->insn_map);
+ free (splittable_regs);
+ free (derived_regs);
+ free (splittable_regs_updates);
+ free (addr_combined_regs);
+ free (local_regno);
+ if (map->reg_map)
+ free (map->reg_map);
+ free (map);
}
/* Return true if the loop can be safely, and profitably, preconditioned