aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-copy.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2013-02-20 11:39:39 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2013-02-20 11:39:39 +0000
commite91c8ed63fa4d372a740ca8047bf42c0b86593c4 (patch)
treea9f201aa86270f426a1e1a693b80027bb5c40590 /gcc/tree-ssa-copy.c
parent3d916479cf3b6ec9a2a81fece2996a54ebb314c3 (diff)
downloadgcc-e91c8ed63fa4d372a740ca8047bf42c0b86593c4.zip
gcc-e91c8ed63fa4d372a740ca8047bf42c0b86593c4.tar.gz
gcc-e91c8ed63fa4d372a740ca8047bf42c0b86593c4.tar.bz2
re PR tree-optimization/56396 (memory corruption in cc1)
2013-02-20 Richard Biener <rguenther@suse.de> Jakub Jelinek <jakub@redhat.com> PR tree-optimization/56396 * tree-ssa-ccp.c (n_const_val): New static variable. (get_value): Return NULL for SSA names we don't have a lattice entry for. (ccp_initialize): Initialize n_const_val. * tree-ssa-copy.c (n_copy_of): New static variable. (init_copy_prop): Initialize n_copy_of. (get_value): Return NULL_TREE for SSA names we don't have a lattice entry for. * gcc.dg/pr56396.c: New testcase. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r196170
Diffstat (limited to 'gcc/tree-ssa-copy.c')
-rw-r--r--gcc/tree-ssa-copy.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c
index 551ebe3..75a4154 100644
--- a/gcc/tree-ssa-copy.c
+++ b/gcc/tree-ssa-copy.c
@@ -280,6 +280,7 @@ struct prop_value_d {
typedef struct prop_value_d prop_value_t;
static prop_value_t *copy_of;
+static unsigned n_copy_of;
/* Return true if this statement may generate a useful copy. */
@@ -664,7 +665,8 @@ init_copy_prop (void)
{
basic_block bb;
- copy_of = XCNEWVEC (prop_value_t, num_ssa_names);
+ n_copy_of = num_ssa_names;
+ copy_of = XCNEWVEC (prop_value_t, n_copy_of);
FOR_EACH_BB (bb)
{
@@ -728,7 +730,10 @@ init_copy_prop (void)
static tree
get_value (tree name)
{
- tree val = copy_of[SSA_NAME_VERSION (name)].value;
+ tree val;
+ if (SSA_NAME_VERSION (name) >= n_copy_of)
+ return NULL_TREE;
+ val = copy_of[SSA_NAME_VERSION (name)].value;
if (val && val != name)
return val;
return NULL_TREE;