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
This commit is contained in:
parent
aa29ea0cd4
commit
acf816a3ac
@ -1,3 +1,8 @@
|
||||
2014-09-24 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR sanitizer/63316
|
||||
* asan.c (asan_expand_check_ifn): Fix up align >= 8 optimization.
|
||||
|
||||
2014-09-24 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
||||
|
||||
PR tree-optimization/63266
|
||||
|
29
gcc/asan.c
29
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));
|
||||
|
@ -1,3 +1,8 @@
|
||||
2014-09-24 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR sanitizer/63316
|
||||
* c-c++-common/asan/pr63316.c: New test.
|
||||
|
||||
2014-09-24 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
||||
|
||||
PR tree-optimization/63266
|
||||
|
22
gcc/testsuite/c-c++-common/asan/pr63316.c
Normal file
22
gcc/testsuite/c-c++-common/asan/pr63316.c
Normal file
@ -0,0 +1,22 @@
|
||||
/* PR sanitizer/63316 */
|
||||
/* { dg-do run } */
|
||||
/* { dg-options "-fsanitize=address -O2" } */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void *malloc (__SIZE_TYPE__);
|
||||
extern void free (void *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int *p = (int *) malloc (sizeof (int));
|
||||
*p = 3;
|
||||
asm volatile ("" : : "r" (p) : "memory");
|
||||
free (p);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user