re PR tree-optimization/70876 (ICE in chkp_find_bounds: Unexpected tree code with_siz...
authorIlya Enkovich <ilya.enkovich@intel.com>
Tue, 10 May 2016 15:56:27 +0000 (15:56 +0000)
committerIlya Enkovich <ienkovich@gcc.gnu.org>
Tue, 10 May 2016 15:56:27 +0000 (15:56 +0000)
gcc/

PR tree-optimization/70786
* tree-chkp.c (chkp_find_bounds_1): Support WITH_SIZE_EXPR.
* gcc/calls.c (initialize_argument_information): Bind bounds
with corresponding args passed by reference.

gcc/testsuite/

PR tree-optimization/70786
* gcc.target/i386/pr70876.c: New test.

From-SVN: r236086

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr70876.c [new file with mode: 0644]
gcc/tree-chkp.c

index dfbb1c3e0736245df68fd64b388916c8d7317ac8..e43a062ce9d0ddcf895372030b452cfe29ffd3a7 100644 (file)
@@ -1,3 +1,10 @@
+2016-05-10  Ilya Enkovich  <ilya.enkovich@intel.com>
+
+       PR tree-optimization/70786
+       * tree-chkp.c (chkp_find_bounds_1): Support WITH_SIZE_EXPR.
+       * gcc/calls.c (initialize_argument_information): Bind bounds
+       with corresponding args passed by reference.
+
 2016-05-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/70927
index 6415e08b28d48a1e708fde827890ae948ae444f6..6cc1fc721e45aa19d5ab98f7522b8f2d7e14ae38 100644 (file)
@@ -1188,6 +1188,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED,
            j--;
          }
       }
+    argpos = 0;
     FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
       {
        tree argtype = TREE_TYPE (arg);
@@ -1206,6 +1207,14 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED,
                chkp_find_bound_slots (argtype, slots);
              }
          }
+       else if (CALL_WITH_BOUNDS_P (exp)
+                && pass_by_reference (NULL, TYPE_MODE (argtype), argtype,
+                                      argpos < n_named_args))
+         {
+           if (slots)
+             BITMAP_FREE (slots);
+           ptr_arg = j;
+         }
        else if (POINTER_BOUNDS_TYPE_P (argtype))
          {
            /* We expect bounds in instrumented calls only.
@@ -1249,6 +1258,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED,
        else
          args[j].tree_value = arg;
        j--;
+       argpos++;
       }
 
     if (slots)
index deec34e8bbd74256337ac90818cd56e2f10fb6c3..7cf507f51f62ee21ae2333f4b1ddf2014069bf8e 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-10  Ilya Enkovich  <ilya.enkovich@intel.com>
+
+       PR tree-optimization/70786
+       * gcc.target/i386/pr70876.c: New test.
+
 2016-05-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/70927
diff --git a/gcc/testsuite/gcc.target/i386/pr70876.c b/gcc/testsuite/gcc.target/i386/pr70876.c
new file mode 100644 (file)
index 0000000..c9bab69
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -Wno-implicit-function-declaration" } */
+
+void f (char *s1, char *s2)
+{
+  int z = 5;
+
+  struct { char a[z]; } x;
+
+  s1[0] = s2[0];
+
+  foo (x, x);
+}
index 3fba12c2ae46ac07999b3710c6498c1af77e9f39..8c7d214e0e3b3c809386d2e20fa68837941059de 100644 (file)
@@ -3646,6 +3646,7 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter)
       break;
 
     case ADDR_EXPR:
+    case WITH_SIZE_EXPR:
       bounds = chkp_make_addressed_object_bounds (TREE_OPERAND (ptr_src, 0), iter);
       break;