re PR target/79904 (ICE in annotate_constant_pool_refs, at config/s390/s390.c:7909)
authorJakub Jelinek <jakub@redhat.com>
Wed, 8 Mar 2017 08:35:20 +0000 (09:35 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 8 Mar 2017 08:35:20 +0000 (09:35 +0100)
PR sanitizer/79904
* internal-fn.c (expand_vector_ubsan_overflow): If arg0 or arg1
is a uniform vector, use uniform_vector_p return value instead of
building ARRAY_REF on folded VIEW_CONVERT_EXPR to array type.

* gcc.dg/ubsan/pr79904.c: New test.

From-SVN: r245967

gcc/ChangeLog
gcc/internal-fn.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ubsan/pr79904.c [new file with mode: 0644]

index 250bd8cf512e76c5953bdaeb8b9b5c6c8bd34e37..fcca6aa4cc3000d7f1c513107746030a484de392 100644 (file)
@@ -1,3 +1,10 @@
+2017-03-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/79904
+       * internal-fn.c (expand_vector_ubsan_overflow): If arg0 or arg1
+       is a uniform vector, use uniform_vector_p return value instead of
+       building ARRAY_REF on folded VIEW_CONVERT_EXPR to array type.
+
 2017-03-07  Marek Polacek  <polacek@redhat.com>
 
        PR middle-end/79809
index ffe291d62cf5936af2acc81e0c2efd7103966198..df7b930e801f1ab63e207f237b3e5851f9a09837 100644 (file)
@@ -1869,12 +1869,20 @@ expand_vector_ubsan_overflow (location_t loc, enum tree_code code, tree lhs,
       if (cnt > 4)
        {
          tree atype = build_array_type_nelts (eltype, cnt);
-         op0 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, atype, arg0);
-         op0 = build4_loc (loc, ARRAY_REF, eltype, op0, cntv,
-                           NULL_TREE, NULL_TREE);
-         op1 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, atype, arg1);
-         op1 = build4_loc (loc, ARRAY_REF, eltype, op1, cntv,
-                           NULL_TREE, NULL_TREE);
+         op0 = uniform_vector_p (arg0);
+         if (op0 == NULL_TREE)
+           {
+             op0 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, atype, arg0);
+             op0 = build4_loc (loc, ARRAY_REF, eltype, op0, cntv,
+                               NULL_TREE, NULL_TREE);
+           }
+         op1 = uniform_vector_p (arg1);
+         if (op1 == NULL_TREE)
+           {
+             op1 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, atype, arg1);
+             op1 = build4_loc (loc, ARRAY_REF, eltype, op1, cntv,
+                               NULL_TREE, NULL_TREE);
+           }
          if (resv)
            {
              res = fold_build1_loc (loc, VIEW_CONVERT_EXPR, atype, resv);
index bfff262e048e28e2980cf254df07d27ba08b830c..f2fd40e876deedc8475d45e75ebe41000f44b934 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/79904
+       * gcc.dg/ubsan/pr79904.c: New test.
+
 2017-03-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/79834
diff --git a/gcc/testsuite/gcc.dg/ubsan/pr79904.c b/gcc/testsuite/gcc.dg/ubsan/pr79904.c
new file mode 100644 (file)
index 0000000..af81669
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR sanitizer/79904 */
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=signed-integer-overflow -Wno-psabi" } */
+
+typedef signed char V __attribute__((vector_size (8))); 
+
+void
+foo (V *a) 
+{ 
+  *a = *a * 3; 
+}