Commit 419d45db by Kyrylo Tkachov Committed by Kyrylo Tkachov

[genattrtab] Fix memory corruption, allocate enough memory for all bypassed reservations

	* genattrtab.c (n_bypassed): New variable.
	(process_bypasses): Initialise n_bypassed.
	Count number of bypassed reservations.
	(make_automaton_attrs): Allocate space for bypassed reservations
	rather than number of bypasses.

From-SVN: r211771
parent 25b7069a
2014-06-18 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* genattrtab.c (n_bypassed): New variable.
(process_bypasses): Initialise n_bypassed.
Count number of bypassed reservations.
(make_automaton_attrs): Allocate space for bypassed reservations
rather than number of bypasses.
2014-06-18 Richard Biener <rguenther@suse.de> 2014-06-18 Richard Biener <rguenther@suse.de>
* tree-ssa-propagate.c (replace_phi_args_in): Return whether * tree-ssa-propagate.c (replace_phi_args_in): Return whether
......
...@@ -4766,6 +4766,7 @@ struct bypass_list ...@@ -4766,6 +4766,7 @@ struct bypass_list
static struct bypass_list *all_bypasses; static struct bypass_list *all_bypasses;
static size_t n_bypasses; static size_t n_bypasses;
static size_t n_bypassed;
static void static void
gen_bypass_1 (const char *s, size_t len) gen_bypass_1 (const char *s, size_t len)
...@@ -4811,12 +4812,18 @@ process_bypasses (void) ...@@ -4811,12 +4812,18 @@ process_bypasses (void)
struct bypass_list *b; struct bypass_list *b;
struct insn_reserv *r; struct insn_reserv *r;
n_bypassed = 0;
/* The reservation list is likely to be much longer than the bypass /* The reservation list is likely to be much longer than the bypass
list. */ list. */
for (r = all_insn_reservs; r; r = r->next) for (r = all_insn_reservs; r; r = r->next)
for (b = all_bypasses; b; b = b->next) for (b = all_bypasses; b; b = b->next)
if (fnmatch (b->pattern, r->name, 0) == 0) if (fnmatch (b->pattern, r->name, 0) == 0)
r->bypassed = true; {
n_bypassed++;
r->bypassed = true;
break;
}
} }
/* Check that attribute NAME is used in define_insn_reservation condition /* Check that attribute NAME is used in define_insn_reservation condition
...@@ -5075,7 +5082,7 @@ make_automaton_attrs (void) ...@@ -5075,7 +5082,7 @@ make_automaton_attrs (void)
process_bypasses (); process_bypasses ();
byps_exp = rtx_alloc (COND); byps_exp = rtx_alloc (COND);
XVEC (byps_exp, 0) = rtvec_alloc (n_bypasses * 2); XVEC (byps_exp, 0) = rtvec_alloc (n_bypassed * 2);
XEXP (byps_exp, 1) = make_numeric_value (0); XEXP (byps_exp, 1) = make_numeric_value (0);
for (decl = all_insn_reservs, i = 0; for (decl = all_insn_reservs, i = 0;
decl; decl;
......
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