diff mbox

[PR77862] ICE in add_equivalence

Message ID 9d990d11-b566-062e-6258-81ec60c8c994@linaro.org
State New
Headers show

Commit Message

Kugan Vivekanandarajah Oct. 6, 2016, 4:45 a.m. UTC
Hi,

In VRP we can generate new SSA variables while performing the 
propagation, at least in EVRP. Therefore, when we access array vr_values 
we have to check num_vr_values. This caused ICE for the PR77862. 
Attached patch fixes this.

Bootstrapped and regression tested on x86_64-linux-gnu with no new 
regressions. Is this OK for trunk?

Thanks,
Kugan


gcc/testsuite/ChangeLog:

2016-10-06  Kugan Vivekanandarajah  <kuganv@linaro.org>

	PR tree-optimization/77862
	* gcc.dg/pr77862.c: New test.

gcc/ChangeLog:

2016-10-06  Kugan Vivekanandarajah  <kuganv@linaro.org>

	PR tree-optimization/77862
	* tree-vrp.c (add_equivalence): Use get_value_range so that
	num_vr_values is checked before accessing vr_values.
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.dg/pr77862.c b/gcc/testsuite/gcc.dg/pr77862.c
index e69de29..e9096d2 100644
--- a/gcc/testsuite/gcc.dg/pr77862.c
+++ b/gcc/testsuite/gcc.dg/pr77862.c
@@ -0,0 +1,19 @@ 
+
+/* PR tree-optimization/77862 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fPIC -w" } */
+
+struct paramed_type
+{
+};
+int a;
+
+int memcmp ( int*, void *, long );
+
+void
+cur_token (void)
+{
+  if ( 1 != a || memcmp ( cur_token, "", a ) )
+    return;
+  struct paramed_type b = { };
+}
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index bfb6b2f..db9dc23 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -843,7 +843,7 @@  static void
 add_equivalence (bitmap *equiv, const_tree var)
 {
   unsigned ver = SSA_NAME_VERSION (var);
-  value_range *vr = vr_value[ver];
+  value_range *vr = get_value_range (var);
 
   if (*equiv == NULL)
     *equiv = BITMAP_ALLOC (&vrp_equiv_obstack);