Commit 4da896b2 by Mark Mitchell Committed by Mark Mitchell

cse.c (delete_trivially_dead_insns): Replace alloca with xmalloc/xcalloc.

	* cse.c (delete_trivially_dead_insns): Replace alloca with
	xmalloc/xcalloc.
	* except.c (update_rethrow_references): Likewise.
	(init_eh_nesting_info): Likewise.
	* function.c (identify_blocks): Likewise.
	* gcse.c (dump_hash_table): Likewise.
	* graph.c (print_rtl_graph_with_bb): Likewise.
	* loop.c (combine_movables): Likewise.
	(move_movables): Likewise.
	(count_loop_regs_set): Likewise.
	(strength_reduce): Likewise.
	* profile.c (compute_branch_probabilities): New function, split
	out from ...
	(branch_prob): Here.  Replace alloca with xmalloc/xcalloc.
	* regclass.c (regclass): Likewise.
	* regmove.c (regmove_optimize): Likewise.
	* toplev.c (compile_file): Likewise.
	(main): Don't mess with the stack rlimit.

From-SVN: r30445
parent 8d170590
Sun Nov 7 20:55:14 1999 Mark Mitchell <mark@codesourcery.com>
* cse.c (delete_trivially_dead_insns): Replace alloca with
xmalloc/xcalloc.
* except.c (update_rethrow_references): Likewise.
(init_eh_nesting_info): Likewise.
* function.c (identify_blocks): Likewise.
* gcse.c (dump_hash_table): Likewise.
* graph.c (print_rtl_graph_with_bb): Likewise.
* loop.c (combine_movables): Likewise.
(move_movables): Likewise.
(count_loop_regs_set): Likewise.
(strength_reduce): Likewise.
* profile.c (compute_branch_probabilities): New function, split
out from ...
(branch_prob): Here. Replace alloca with xmalloc/xcalloc.
* regclass.c (regclass): Likewise.
* regmove.c (regmove_optimize): Likewise.
* toplev.c (compile_file): Likewise.
(main): Don't mess with the stack rlimit.
Sun Nov 7 19:41:17 1999 Catherine Moore <clm@cygnus.com>
* config/elfos.h (ASM_DECLARE_FUNCTION_NAME): Conditionally define.
......
......@@ -7364,7 +7364,7 @@ delete_trivially_dead_insns (insns, nreg)
rtx insns;
int nreg;
{
int *counts = (int *) alloca (nreg * sizeof (int));
int *counts;
rtx insn, prev;
#ifdef HAVE_cc0
rtx tem;
......@@ -7373,7 +7373,7 @@ delete_trivially_dead_insns (insns, nreg)
int in_libcall = 0, dead_libcall = 0;
/* First count the number of times each register is used. */
bzero ((char *) counts, sizeof (int) * nreg);
counts = (int *) xcalloc (nreg, sizeof (int));
for (insn = next_real_insn (insns); insn; insn = next_real_insn (insn))
count_reg_usage (insn, counts, NULL_RTX, 1);
......@@ -7508,4 +7508,7 @@ delete_trivially_dead_insns (insns, nreg)
dead_libcall = 0;
}
}
/* Clean up. */
free (counts);
}
......@@ -2703,10 +2703,8 @@ update_rethrow_references ()
if (!flag_new_exceptions)
return;
saw_region = (int *) alloca (current_func_eh_entry * sizeof (int));
saw_rethrow = (int *) alloca (current_func_eh_entry * sizeof (int));
bzero ((char *) saw_region, (current_func_eh_entry * sizeof (int)));
bzero ((char *) saw_rethrow, (current_func_eh_entry * sizeof (int)));
saw_region = (int *) xcalloc (current_func_eh_entry, sizeof (int));
saw_rethrow = (int *) xcalloc (current_func_eh_entry, sizeof (int));
/* Determine what regions exist, and whether there are any rethrows
to those regions or not. */
......@@ -2735,6 +2733,10 @@ update_rethrow_references ()
for (x = 0; x < current_func_eh_entry; x++)
if (saw_region[x])
function_eh_regions[x].rethrow_ref = saw_rethrow[x];
/* Clean up. */
free (saw_region);
free (saw_rethrow);
}
/* Various hooks for the DWARF 2 __throw routine. */
......@@ -3155,9 +3157,7 @@ init_eh_nesting_info ()
info = (eh_nesting_info *) xmalloc (sizeof (eh_nesting_info));
info->region_index = (int *) xcalloc ((max_label_num () + 1), sizeof (int));
nested_eh_region = (int *) alloca ((max_label_num () + 1) * sizeof (int));
bzero ((char *) nested_eh_region, (max_label_num () + 1) * sizeof (int));
nested_eh_region = (int *) xcalloc (max_label_num () + 1, sizeof (int));
/* Create the nested_eh_region list. If indexed with a block number, it
returns the block number of the next outermost region, if any.
......@@ -3189,6 +3189,7 @@ init_eh_nesting_info ()
{
free (info->region_index);
free (info);
free (nested_eh_region);
return NULL;
}
......@@ -3205,6 +3206,10 @@ init_eh_nesting_info ()
process_nestinfo (x, info, nested_eh_region);
}
info->region_count = region_count;
/* Clean up. */
free (nested_eh_region);
return info;
}
......
......@@ -5558,7 +5558,7 @@ identify_blocks (block, insns)
block_vector = (tree *) xmalloc (n_blocks * sizeof (tree));
all_blocks (block, block_vector);
block_stack = (tree *) alloca (n_blocks * sizeof (tree));
block_stack = (tree *) xmalloc (n_blocks * sizeof (tree));
for (insn = insns; insn; insn = NEXT_INSN (insn))
if (GET_CODE (insn) == NOTE)
......@@ -5594,6 +5594,7 @@ identify_blocks (block, insns)
abort ();
free (block_vector);
free (block_stack);
}
/* Given a revised instruction chain, rebuild the tree structure of
......
......@@ -2067,10 +2067,13 @@ dump_hash_table (file, name, table, table_size, total_size)
{
int i;
/* Flattened out table, so it's printed in proper order. */
struct expr **flat_table = (struct expr **) alloca (total_size * sizeof (struct expr *));
unsigned int *hash_val = (unsigned int *) alloca (total_size * sizeof (unsigned int));
struct expr **flat_table;
unsigned int *hash_val;
flat_table
= (struct expr **) xcalloc (total_size, sizeof (struct expr *));
hash_val = (unsigned int *) xmalloc (total_size * sizeof (unsigned int));
bzero ((char *) flat_table, total_size * sizeof (struct expr *));
for (i = 0; i < table_size; i++)
{
struct expr *expr;
......@@ -2096,6 +2099,10 @@ dump_hash_table (file, name, table, table_size, total_size)
}
fprintf (file, "\n");
/* Clean up. */
free (flat_table);
free (hash_val);
}
/* Record register first/last/block set information for REGNO in INSN.
......
......@@ -284,10 +284,10 @@ print_rtl_graph_with_bb (base, suffix, rtx_first)
int i;
enum bb_state { NOT_IN_BB, IN_ONE_BB, IN_MULTIPLE_BB };
int max_uid = get_max_uid ();
int *start = (int *) alloca (max_uid * sizeof (int));
int *end = (int *) alloca (max_uid * sizeof (int));
int *start = (int *) xmalloc (max_uid * sizeof (int));
int *end = (int *) xmalloc (max_uid * sizeof (int));
enum bb_state *in_bb_p = (enum bb_state *)
alloca (max_uid * sizeof (enum bb_state));
xmalloc (max_uid * sizeof (enum bb_state));
basic_block bb;
for (i = 0; i < max_uid; ++i)
......@@ -410,6 +410,11 @@ print_rtl_graph_with_bb (base, suffix, rtx_first)
dump_for_graph = 0;
end_fct (fp);
/* Clean up. */
free (start);
free (end);
free (in_bb_p);
}
fclose (fp);
......
......@@ -1449,7 +1449,7 @@ combine_movables (movables, nregs)
int nregs;
{
register struct movable *m;
char *matched_regs = (char *) alloca (nregs);
char *matched_regs = (char *) xmalloc (nregs);
enum machine_mode mode;
/* Regs that are set more than once are not allowed to match
......@@ -1552,6 +1552,9 @@ combine_movables (movables, nregs)
overlap: ;
}
}
/* Clean up. */
free (matched_regs);
}
/* Return 1 if regs X and Y will become the same if moved. */
......@@ -1753,11 +1756,8 @@ move_movables (movables, threshold, insn_count, loop_start, end, nregs)
/* Map of pseudo-register replacements to handle combining
when we move several insns that load the same value
into different pseudo-registers. */
rtx *reg_map = (rtx *) alloca (nregs * sizeof (rtx));
char *already_moved = (char *) alloca (nregs);
bzero (already_moved, nregs);
bzero ((char *) reg_map, nregs * sizeof (rtx));
rtx *reg_map = (rtx *) xcalloc (nregs, sizeof (rtx));
char *already_moved = (char *) xcalloc (nregs, sizeof (char));
num_movables = 0;
......@@ -2240,6 +2240,10 @@ move_movables (movables, threshold, insn_count, loop_start, end, nregs)
replace_regs (REG_NOTES (p), reg_map, nregs, 0);
INSN_CODE (p) = -1;
}
/* Clean up. */
free (reg_map);
free (already_moved);
}
#if 0
......@@ -3580,11 +3584,10 @@ count_loop_regs_set (from, to, may_not_move, single_usage, count_ptr, nregs)
int *count_ptr;
int nregs;
{
register rtx *last_set = (rtx *) alloca (nregs * sizeof (rtx));
register rtx *last_set = (rtx *) xcalloc (nregs, sizeof (rtx));
register rtx insn;
register int count = 0;
bzero ((char *) last_set, nregs * sizeof (rtx));
for (insn = from; insn != to; insn = NEXT_INSN (insn))
{
if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
......@@ -3614,6 +3617,9 @@ count_loop_regs_set (from, to, may_not_move, single_usage, count_ptr, nregs)
bzero ((char *) last_set, nregs * sizeof (rtx));
}
*count_ptr = count;
/* Clean up. */
free (last_set);
}
/* Given a loop that is bounded by LOOP_START and LOOP_END
......@@ -3770,7 +3776,7 @@ strength_reduce (scan_start, end, loop_top, insn_count,
/* ??? could set this to last value of threshold in move_movables */
int threshold = (loop_info->has_call ? 1 : 2) * (3 + n_non_fixed_regs);
/* Map of pseudo-register replacements. */
rtx *reg_map;
rtx *reg_map = NULL;
int reg_map_size;
int call_seen;
rtx test;
......@@ -3787,9 +3793,7 @@ strength_reduce (scan_start, end, loop_top, insn_count,
VARRAY_INT_INIT (reg_iv_type, max_reg_before_loop, "reg_iv_type");
VARRAY_GENERIC_PTR_INIT (reg_iv_info, max_reg_before_loop, "reg_iv_info");
reg_biv_class = (struct iv_class **)
alloca (max_reg_before_loop * sizeof (struct iv_class *));
bzero ((char *) reg_biv_class, (max_reg_before_loop
* sizeof (struct iv_class *)));
xcalloc (max_reg_before_loop, sizeof (struct iv_class *));
loop_iv_list = 0;
addr_placeholder = gen_reg_rtx (Pmode);
......@@ -4676,8 +4680,7 @@ strength_reduce (scan_start, end, loop_top, insn_count,
Some givs might have been made from biv increments, so look at
reg_iv_type for a suitable size. */
reg_map_size = reg_iv_type->num_elements;
reg_map = (rtx *) alloca (reg_map_size * sizeof (rtx));
bzero ((char *) reg_map, reg_map_size * sizeof (rtx));
reg_map = (rtx *) xcalloc (reg_map_size, sizeof (rtx));
/* Examine each iv class for feasibility of strength reduction/induction
variable elimination. */
......@@ -5300,6 +5303,9 @@ strength_reduce (scan_start, end, loop_top, insn_count,
egress:
VARRAY_FREE (reg_iv_type);
VARRAY_FREE (reg_iv_info);
free (reg_biv_class);
if (reg_map)
free (reg_map);
}
/* Return 1 if X is a valid source for an initial value (or as value being
......
......@@ -965,7 +965,7 @@ regclass (f, nregs)
#ifdef FORBIDDEN_INC_DEC_CLASSES
in_inc_dec = (char *) alloca (nregs);
in_inc_dec = (char *) xmalloc (nregs);
/* Initialize information about which register classes can be used for
pseudos that are auto-incremented or auto-decremented. It would
......@@ -1109,6 +1109,9 @@ regclass (f, nregs)
}
}
#ifdef FORBIDDEN_INC_DEC_CLASSES
free (in_inc_dec);
#endif
free (costs);
}
......
......@@ -1099,10 +1099,10 @@ regmove_optimize (f, nregs, regmove_dump_file)
can supress some optimizations in those zones. */
mark_flags_life_zones (discover_flags_reg ());
regno_src_regno = (int *)alloca (sizeof *regno_src_regno * nregs);
regno_src_regno = (int *) xmalloc (sizeof *regno_src_regno * nregs);
for (i = nregs; --i >= 0; ) regno_src_regno[i] = -1;
regmove_bb_head = (int *)alloca (sizeof (int) * (old_max_uid + 1));
regmove_bb_head = (int *) xmalloc (sizeof (int) * (old_max_uid + 1));
for (i = old_max_uid; i >= 0; i--) regmove_bb_head[i] = -1;
for (i = 0; i < n_basic_blocks; i++)
regmove_bb_head[INSN_UID (BLOCK_HEAD (i))] = i;
......@@ -1114,7 +1114,7 @@ regmove_optimize (f, nregs, regmove_dump_file)
for (pass = 0; pass <= 2; pass++)
{
if (! flag_regmove && pass >= flag_expensive_optimizations)
return;
goto done;
if (regmove_dump_file)
fprintf (regmove_dump_file, "Starting %s pass...\n",
......@@ -1574,6 +1574,11 @@ regmove_optimize (f, nregs, regmove_dump_file)
new = next, next = NEXT_INSN (new);
BLOCK_END (i) = new;
}
done:
/* Clean up. */
free (regno_src_regno);
free (regmove_bb_head);
}
/* Returns nonzero if INSN's pattern has matching constraints for any operand.
......
......@@ -3240,7 +3240,7 @@ compile_file (name)
{
int len = list_length (globals);
tree *vec = (tree *) alloca (sizeof (tree) * len);
tree *vec = (tree *) xmalloc (sizeof (tree) * len);
int i;
tree decl;
......@@ -3267,6 +3267,9 @@ compile_file (name)
output_exception_table ();
check_global_declarations (vec, len);
/* Clean up. */
free (vec);
}
/* Write out any pending weak symbol declarations. */
......@@ -5289,18 +5292,6 @@ main (argc, argv)
--p;
progname = p;
#if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
/* Get rid of any avoidable limit on stack size. */
{
struct rlimit rlim;
/* Set the stack limit huge so that alloca does not fail. */
getrlimit (RLIMIT_STACK, &rlim);
rlim.rlim_cur = rlim.rlim_max;
setrlimit (RLIMIT_STACK, &rlim);
}
#endif
#ifdef HAVE_LC_MESSAGES
setlocale (LC_MESSAGES, "");
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment