diff options
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/internal-fn.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ubsan/pr79904.c | 11 |
4 files changed, 37 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 250bd8c..fcca6aa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index ffe291d..df7b930 100644 --- a/gcc/internal-fn.c +++ b/gcc/internal-fn.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bfff262..f2fd40e87 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..af81669 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ubsan/pr79904.c @@ -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; +} |