aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>2014-06-18 08:07:16 +0000
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>2014-06-18 08:07:16 +0000
commit419d45db8e25741704b8ccd06699e4d4cfcfbc4e (patch)
tree62c9b5b73d285f6b069bdd234209b12af89e1478
parent25b7069af201bcecc06fdc0b9a0fc455f5985c77 (diff)
downloadgcc-419d45db8e25741704b8ccd06699e4d4cfcfbc4e.zip
gcc-419d45db8e25741704b8ccd06699e4d4cfcfbc4e.tar.gz
gcc-419d45db8e25741704b8ccd06699e4d4cfcfbc4e.tar.bz2
[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
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/genattrtab.c11
2 files changed, 17 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5eb312b..98042bb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+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>
* tree-ssa-propagate.c (replace_phi_args_in): Return whether
diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index c5ce51c..9db2ade 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -4766,6 +4766,7 @@ struct bypass_list
static struct bypass_list *all_bypasses;
static size_t n_bypasses;
+static size_t n_bypassed;
static void
gen_bypass_1 (const char *s, size_t len)
@@ -4811,12 +4812,18 @@ process_bypasses (void)
struct bypass_list *b;
struct insn_reserv *r;
+ n_bypassed = 0;
+
/* The reservation list is likely to be much longer than the bypass
list. */
for (r = all_insn_reservs; r; r = r->next)
for (b = all_bypasses; b; b = b->next)
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
@@ -5075,7 +5082,7 @@ make_automaton_attrs (void)
process_bypasses ();
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);
for (decl = all_insn_reservs, i = 0;
decl;