aboutsummaryrefslogtreecommitdiff
path: root/gcc/sched.c
diff options
context:
space:
mode:
authorJim Wilson <wilson@cygnus.com>1998-06-18 20:17:26 +0000
committerJim Wilson <wilson@gcc.gnu.org>1998-06-18 13:17:26 -0700
commit7c74b010d72a4bb1fb6e2647c75a88b865e137b2 (patch)
tree93fbc1459e6675b3c705a7f66d20d7194d504e4b /gcc/sched.c
parent243e7835fb7d2015eee565f70b17c2fdb238cdab (diff)
downloadgcc-7c74b010d72a4bb1fb6e2647c75a88b865e137b2.zip
gcc-7c74b010d72a4bb1fb6e2647c75a88b865e137b2.tar.gz
gcc-7c74b010d72a4bb1fb6e2647c75a88b865e137b2.tar.bz2
Fix stack overflow found by glibc compile with max optimizations.
* sched.c (schedule_insns): Use xmalloc not alloca for max_uid indexed arrays. Call free at the end of the function for them. * haifa-sched.c (schedule_insns): Likewise. From-SVN: r20563
Diffstat (limited to 'gcc/sched.c')
-rw-r--r--gcc/sched.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/gcc/sched.c b/gcc/sched.c
index 2cd9d12..5b54028 100644
--- a/gcc/sched.c
+++ b/gcc/sched.c
@@ -4293,14 +4293,18 @@ schedule_insns (dump_file)
remember how far we can cut back the stack on exit. */
/* Allocate data for this pass. See comments, above,
- for what these vectors do. */
- insn_luid = (int *) alloca (max_uid * sizeof (int));
- insn_priority = (int *) alloca (max_uid * sizeof (int));
- insn_tick = (int *) alloca (max_uid * sizeof (int));
- insn_costs = (short *) alloca (max_uid * sizeof (short));
- insn_units = (short *) alloca (max_uid * sizeof (short));
- insn_blockage = (unsigned int *) alloca (max_uid * sizeof (unsigned int));
- insn_ref_count = (int *) alloca (max_uid * sizeof (int));
+ for what these vectors do.
+
+ We use xmalloc instead of alloca, because max_uid can be very large
+ when there is a lot of function inlining. If we used alloca, we could
+ exceed stack limits on some hosts for some inputs. */
+ insn_luid = (int *) xmalloc (max_uid * sizeof (int));
+ insn_priority = (int *) xmalloc (max_uid * sizeof (int));
+ insn_tick = (int *) xmalloc (max_uid * sizeof (int));
+ insn_costs = (short *) xmalloc (max_uid * sizeof (short));
+ insn_units = (short *) xmalloc (max_uid * sizeof (short));
+ insn_blockage = (unsigned int *) xmalloc (max_uid * sizeof (unsigned int));
+ insn_ref_count = (int *) xmalloc (max_uid * sizeof (int));
if (reload_completed == 0)
{
@@ -4324,7 +4328,7 @@ schedule_insns (dump_file)
{
rtx line;
- line_note = (rtx *) alloca (max_uid * sizeof (rtx));
+ line_note = (rtx *) xmalloc (max_uid * sizeof (rtx));
bzero ((char *) line_note, max_uid * sizeof (rtx));
line_note_head = (rtx *) alloca (n_basic_blocks * sizeof (rtx));
bzero ((char *) line_note_head, n_basic_blocks * sizeof (rtx));
@@ -4561,6 +4565,17 @@ schedule_insns (dump_file)
}
}
+ free (insn_luid);
+ free (insn_priority);
+ free (insn_tick);
+ free (insn_costs);
+ free (insn_units);
+ free (insn_blockage);
+ free (insn_ref_count);
+
+ if (write_symbols != NO_DEBUG)
+ free (line_note);
+
if (reload_completed == 0)
{
FREE_REG_SET (bb_dead_regs);