From: Richard Biener Date: Mon, 29 Jul 2019 10:10:15 +0000 (+0000) Subject: re PR middle-end/91267 (SEGV in value_range_base::equal_p) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c2f6fae598f997003b73ab93bb85cb33471f389;p=gcc.git re PR middle-end/91267 (SEGV in value_range_base::equal_p) 2019-07-29 Richard Biener PR tree-optimization/91267 * vr-values.c (vr_values::update_value_range): Add early return for effectively VARYING lattice entry. * gcc.dg/torture/pr91267.c: New testcase. From-SVN: r273874 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8cd321ea61b..01e4666051d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-07-29 Richard Biener + + PR tree-optimization/91267 + * vr-values.c (vr_values::update_value_range): Add early return + for effectively VARYING lattice entry. + 2019-07-29 Richard Sandiford PR debug/86638 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cc1aadfac55..30671620e43 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-07-29 Richard Biener + + PR tree-optimization/91267 + * gcc.dg/torture/pr91267.c: New testcase. + 2019-07-29 Richard Sandiford * c-c++-common/guality/Og-dce-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/torture/pr91267.c b/gcc/testsuite/gcc.dg/torture/pr91267.c new file mode 100644 index 00000000000..084bd248439 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91267.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +void bar (void); +void baz (int); +char *qux (void); +int a, b; + +void +foo (int f, char *d) +{ + char *e; + while (d) + { + if (f) + if (e) + bar (); + baz (e - (d + a)); + b = e - d; + d = qux (); + } +} diff --git a/gcc/vr-values.c b/gcc/vr-values.c index d6a8847369c..d03309942af 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -202,8 +202,12 @@ vr_values::update_value_range (const_tree var, value_range *new_vr) new_vr->intersect (&nr); } - /* Update the value range, if necessary. */ + /* Update the value range, if necessary. If we cannot allocate a lattice + entry for VAR keep it at VARYING. This happens when DOM feeds us stmts + with SSA names allocated after setting up the lattice. */ old_vr = get_lattice_entry (var); + if (!old_vr) + return false; is_new = !old_vr->equal_p (*new_vr, /*ignore_equivs=*/false); if (is_new)