From a68d4b75929b0247ce8dfd6e63e8ef17d2549111 Mon Sep 17 00:00:00 2001 From: Brendan Kehoe Date: Mon, 9 Jun 1997 18:24:52 -0400 Subject: [PATCH] reload1.c (reload): Use xmalloc instead of alloca for the label offsets in OFFSETS_AT and... * reload1.c (reload): Use xmalloc instead of alloca for the label offsets in OFFSETS_AT and OFFSETS_KNOWN_AT. From-SVN: r14194 --- gcc/reload1.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/gcc/reload1.c b/gcc/reload1.c index 85790f890b24..ed6a07d000bf 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -545,6 +545,11 @@ reload (first, global, dumpfile) register rtx insn; register struct elim_table *ep; + /* The two pointers used to track the true location of the memory used + for label offsets. */ + char *real_known_ptr = NULL_PTR; + int (*real_at_ptr)[NUM_ELIMINABLE_REGS]; + int something_changed; int something_needs_reloads; int something_needs_elimination; @@ -751,13 +756,17 @@ reload (first, global, dumpfile) num_labels = max_label_num () - get_first_label_num (); /* Allocate the tables used to store offset information at labels. */ - offsets_known_at = (char *) alloca (num_labels); - offsets_at + /* 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 + cause a core dump. */ + real_known_ptr = xmalloc (num_labels); + real_at_ptr = (int (*)[NUM_ELIMINABLE_REGS]) - alloca (num_labels * NUM_ELIMINABLE_REGS * sizeof (int)); + xmalloc (num_labels * NUM_ELIMINABLE_REGS * sizeof (int)); - offsets_known_at -= get_first_label_num (); - offsets_at -= get_first_label_num (); + offsets_known_at = real_known_ptr - get_first_label_num (); + offsets_at + = (int (*)[NUM_ELIMINABLE_REGS]) (real_at_ptr - get_first_label_num ()); /* Alter each pseudo-reg rtx to contain its hard reg number. Assign stack slots to the pseudos that lack hard regs or equivalents. @@ -789,7 +798,11 @@ reload (first, global, dumpfile) break; if (i == max_regno && num_eliminable == 0 && ! caller_save_needed) - return; + { + free (real_known_ptr); + free (real_at_ptr); + return; + } #endif /* Compute the order of preference for hard registers to spill. @@ -2154,6 +2167,11 @@ reload (first, global, dumpfile) reg_equiv_constant = 0; reg_equiv_memory_loc = 0; + if (real_known_ptr) + free (real_known_ptr); + if (real_at_ptr) + free (real_at_ptr); + if (scratch_list) free (scratch_list); scratch_list = 0; -- 2.43.5