summaryrefslogtreecommitdiff
path: root/gcc/genattrtab.c
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>1994-10-12 15:31:29 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>1994-10-12 15:31:29 +0000
commita2a759d9416b0d1dc73f4804c53454276e661205 (patch)
treed034641d75967896c29c04661e8c7d61d7978164 /gcc/genattrtab.c
parent62ebd7d04ac5c5f82db906535599f0fc75b133e7 (diff)
downloadgcc-a2a759d9416b0d1dc73f4804c53454276e661205.tar.gz
Allocate attr_value_list with xmalloc rather than alloca
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@8261 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/genattrtab.c')
-rw-r--r--gcc/genattrtab.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index cd5ae43b11e..aaed2343f49 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -310,6 +310,7 @@ static int length_used;
static int num_delays;
static int have_annul_true, have_annul_false;
static int num_units;
+static int num_insn_ents;
/* Used as operand to `operate_exp': */
@@ -2545,6 +2546,8 @@ remove_insn_ent (av, ie)
av->num_insns--;
if (ie->insn_code == -1)
av->has_asm_insn = 0;
+
+ num_insn_ents--;
}
/* Insert an insn entry in an attribute value list. */
@@ -2559,6 +2562,8 @@ insert_insn_ent (av, ie)
av->num_insns++;
if (ie->insn_code == -1)
av->has_asm_insn = 1;
+
+ num_insn_ents++;
}
/* This is a utility routine to take an expression that is a tree of either
@@ -3293,6 +3298,7 @@ optimize_attrs ()
struct attr_desc * attr;
struct attr_value_list *next; };
struct attr_value_list **insn_code_values;
+ struct attr_value_list *ivbuf;
struct attr_value_list *iv;
/* For each insn code, make a list of all the insn_ent's for it,
@@ -3308,20 +3314,29 @@ optimize_attrs ()
/* Offset the table address so we can index by -2 or -1. */
insn_code_values += 2;
+ /* Allocate the attr_value_list structures using xmalloc rather than
+ alloca, because using alloca can overflow the maximum permitted
+ stack limit on SPARC Lynx. */
+ iv = ivbuf = ((struct attr_value_list *)
+ xmalloc (num_insn_ents * sizeof (struct attr_value_list)));
+
for (i = 0; i < MAX_ATTRS_INDEX; i++)
for (attr = attrs[i]; attr; attr = attr->next)
for (av = attr->first_value; av; av = av->next)
for (ie = av->first_insn; ie; ie = ie->next)
{
- iv = ((struct attr_value_list *)
- alloca (sizeof (struct attr_value_list)));
iv->attr = attr;
iv->av = av;
iv->ie = ie;
iv->next = insn_code_values[ie->insn_code];
insn_code_values[ie->insn_code] = iv;
+ iv++;
}
+ /* Sanity check on num_insn_ents. */
+ if (iv != ivbuf + num_insn_ents)
+ abort ();
+
/* Process one insn code at a time. */
for (i = -2; i < insn_code_number; i++)
{
@@ -3371,6 +3386,8 @@ optimize_attrs ()
}
}
}
+
+ free (ivbuf);
}
#if 0