From 4b48e88382ab6c37aa981881adac0390a74eaeaa Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 8 Mar 2017 09:35:20 +0100 Subject: [PATCH] re PR target/79904 (ICE in annotate_constant_pool_refs, at config/s390/s390.c:7909) 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 | 7 +++++++ gcc/internal-fn.c | 20 ++++++++++++++------ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/ubsan/pr79904.c | 11 +++++++++++ 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/ubsan/pr79904.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 250bd8cf512..fcca6aa4cc3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-03-08 Jakub Jelinek + + 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 PR middle-end/79809 diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index ffe291d62cf..df7b930e801 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 bfff262e048..f2fd40e876d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-08 Jakub Jelinek + + PR sanitizer/79904 + * gcc.dg/ubsan/pr79904.c: New test. + 2017-03-07 Jakub Jelinek 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 00000000000..af8166930a9 --- /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; +} -- 2.30.2