diff options
author | Jakub Jelinek <jakub@gcc.gnu.org> | 2015-04-09 21:51:08 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2015-04-09 21:51:08 +0200 |
commit | f66d8ec8cad7d28d81b3ce55af92fb0169f8edeb (patch) | |
tree | 56c73dc57db10b175afc7f8555c35f76881ce281 | |
parent | 8fd827b8e58b04cdefeb3d5c4de4d53566fdc3ff (diff) | |
download | gcc-f66d8ec8cad7d28d81b3ce55af92fb0169f8edeb.zip gcc-f66d8ec8cad7d28d81b3ce55af92fb0169f8edeb.tar.gz gcc-f66d8ec8cad7d28d81b3ce55af92fb0169f8edeb.tar.bz2 |
re PR tree-optimization/65709 (Bad code for LZ4 decompression with -O3 on x86_64)
PR tree-optimization/65709
* ubsan.c (instrument_mem_ref): Use TREE_TYPE (base) instead of
TREE_TYPE (TREE_TYPE (t)).
* c-c++-common/ubsan/align-9.c: New test.
From-SVN: r221958
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/align-9.c | 21 | ||||
-rw-r--r-- | gcc/ubsan.c | 4 |
4 files changed, 35 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 17fe5a1..cedbd18 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-04-09 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/65709 + * ubsan.c (instrument_mem_ref): Use TREE_TYPE (base) instead of + TREE_TYPE (TREE_TYPE (t)). + 2015-04-09 Vladimir Makarov <vmakarov@redhat.com> PR target/65710 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index da590b1..4be085d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,7 +1,12 @@ +2015-04-09 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/65709 + * c-c++-common/ubsan/align-9.c: New test. + 2013-04-09 Paul Thomas <pault@gcc.gnu.org> PR fortran/56852 - * gfortran.dg/pr56852.f90 : New test + * gfortran.dg/pr56852.f90: New test. 2015-04-09 Marek Polacek <polacek@redhat.com> Jakub Jelinek <jakub@redhat.com> diff --git a/gcc/testsuite/c-c++-common/ubsan/align-9.c b/gcc/testsuite/c-c++-common/ubsan/align-9.c new file mode 100644 index 0000000..24cba94 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/align-9.c @@ -0,0 +1,21 @@ +/* Limit this to known non-strict alignment targets. */ +/* { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } */ +/* { dg-options "-O2 -fsanitize=alignment -fsanitize-recover=alignment" } */ + +__attribute__((noinline, noclone)) void +foo (void *p, const void *q) +{ + *(long int *) p = *(const long int *) q; +} + +int +main () +{ + struct S { long c; char f[64]; char d; char e[2 * sizeof (long)]; char g[64]; } s; + __builtin_memset (&s, '\0', sizeof s); + foo (&s.e[0], &s.e[sizeof (long)]); + return 0; +} + +/* { dg-output "\.c:8:\[0-9]*: \[^\n\r]*load of misaligned address 0x\[0-9a-fA-F]* for type 'const long int', which requires \[48] byte alignment.*" } */ +/* { dg-output "\.c:8:\[0-9]*: \[^\n\r]*store to misaligned address 0x\[0-9a-fA-F]* for type 'long int', which requires \[48] byte alignment" } */ diff --git a/gcc/ubsan.c b/gcc/ubsan.c index b9d9f30..701e9f2 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -1232,9 +1232,9 @@ instrument_mem_ref (tree mem, tree base, gimple_stmt_iterator *iter, tree t = TREE_OPERAND (base, 0); if (!POINTER_TYPE_P (TREE_TYPE (t))) return; - if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_TYPE (t))) && mem != base) + if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (base)) && mem != base) ikind = UBSAN_MEMBER_ACCESS; - tree kind = build_int_cst (TREE_TYPE (t), ikind); + tree kind = build_int_cst (build_pointer_type (TREE_TYPE (base)), ikind); tree alignt = build_int_cst (pointer_sized_int_node, align); gcall *g = gimple_build_call_internal (IFN_UBSAN_NULL, 3, t, kind, alignt); gimple_set_location (g, gimple_location (gsi_stmt (*iter))); |