aboutsummaryrefslogtreecommitdiff
path: root/gcc/asan.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2014-09-24 11:14:17 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2014-09-24 11:14:17 +0200
commitacf816a3aca64e21ba98cedff112919313fdf6ce (patch)
tree746bddba6f5c3ef46034c2673ec3a1f5543519bd /gcc/asan.c
parentaa29ea0cd4054b64d9dbc9adba3bfd2db2a86be1 (diff)
downloadgcc-acf816a3aca64e21ba98cedff112919313fdf6ce.zip
gcc-acf816a3aca64e21ba98cedff112919313fdf6ce.tar.gz
gcc-acf816a3aca64e21ba98cedff112919313fdf6ce.tar.bz2
re PR sanitizer/63316 (False asan positive)
PR sanitizer/63316 * asan.c (asan_expand_check_ifn): Fix up align >= 8 optimization. * c-c++-common/asan/pr63316.c: New test. From-SVN: r215547
Diffstat (limited to 'gcc/asan.c')
-rw-r--r--gcc/asan.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/gcc/asan.c b/gcc/asan.c
index 6917950..fef4b73 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -2585,19 +2585,26 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls)
gimple shadow_test = build_assign (NE_EXPR, shadow, 0);
gimple_seq seq = NULL;
gimple_seq_add_stmt (&seq, shadow_test);
- /* Aligned (>= 8 bytes) access do not need & 7. */
+ /* Aligned (>= 8 bytes) can test just
+ (real_size_in_bytes - 1 >= shadow), as base_addr & 7 is known
+ to be 0. */
if (align < 8)
- gimple_seq_add_stmt (&seq, build_assign (BIT_AND_EXPR,
- base_addr, 7));
- gimple_seq_add_stmt (&seq, build_type_cast (shadow_type,
- gimple_seq_last (seq)));
- if (real_size_in_bytes > 1)
- gimple_seq_add_stmt (&seq,
- build_assign (PLUS_EXPR, gimple_seq_last (seq),
- real_size_in_bytes - 1));
- gimple_seq_add_stmt (&seq, build_assign (GE_EXPR,
+ {
+ gimple_seq_add_stmt (&seq, build_assign (BIT_AND_EXPR,
+ base_addr, 7));
+ gimple_seq_add_stmt (&seq,
+ build_type_cast (shadow_type,
+ gimple_seq_last (seq)));
+ if (real_size_in_bytes > 1)
+ gimple_seq_add_stmt (&seq,
+ build_assign (PLUS_EXPR,
gimple_seq_last (seq),
- shadow));
+ real_size_in_bytes - 1));
+ t = gimple_assign_lhs (gimple_seq_last_stmt (seq));
+ }
+ else
+ t = build_int_cst (shadow_type, real_size_in_bytes - 1);
+ gimple_seq_add_stmt (&seq, build_assign (GE_EXPR, t, shadow));
gimple_seq_add_stmt (&seq, build_assign (BIT_AND_EXPR, shadow_test,
gimple_seq_last (seq)));
t = gimple_assign_lhs (gimple_seq_last (seq));