Message ID | 543F8435.5050708@samsung.com |
---|---|
State | New |
Headers | show |
On Thu, Oct 16, 2014 at 12:39:17PM +0400, Yury Gribov wrote: > Difference from mainline: replaced non-C-friendly bool with unsigned char > (see patch 0001 for explanation). Where? I don't see unsigned char being used anywhere in the patch. bool is certainly fine in GCC itself. > Do not instrument first byte in strlen if already instrumented. > > 2014-10-15 Yury Gribov <y.gribov@samsung.com> > > Backport from mainline > 2014-06-24 Max Ostapenko <m.ostapenko@partner.samsung.com> > > * asan.c (instrument_strlen_call): Do not instrument first byte in strlen > if already instrumented. > > * c-c++-common/asan/no-redundant-instrumentation-9.c: New test. Ok. Jakub
On 10/16/2014 12:49 PM, Jakub Jelinek wrote: > On Thu, Oct 16, 2014 at 12:39:17PM +0400, Yury Gribov wrote: >> Difference from mainline: replaced non-C-friendly bool with unsigned char >> (see patch 0001 for explanation). > > Where? I don't see unsigned char being used anywhere in the patch. > bool is certainly fine in GCC itself. Probably slipped from a neighbor patch :/ In summary all patches that have #include "asan_interface.h" have this quirk which I'll try to replace with #include "stdbool.h" per your suggestion. -Y
Do not instrument first byte in strlen if already instrumented. 2014-10-15 Yury Gribov <y.gribov@samsung.com> Backport from mainline 2014-06-24 Max Ostapenko <m.ostapenko@partner.samsung.com> * asan.c (instrument_strlen_call): Do not instrument first byte in strlen if already instrumented. * c-c++-common/asan/no-redundant-instrumentation-9.c: New test. diff --git a/gcc/asan.c b/gcc/asan.c index 06177ac..0789ad3 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -2026,6 +2026,7 @@ instrument_strlen_call (gimple_stmt_iterator *iter) location_t loc = gimple_location (call); tree str_arg = gimple_call_arg (call, 0); + bool start_instrumented = has_mem_ref_been_instrumented (str_arg, 1); tree cptr_type = build_pointer_type (char_type_node); gimple str_arg_ssa = @@ -2037,7 +2038,8 @@ instrument_strlen_call (gimple_stmt_iterator *iter) build_check_stmt (loc, gimple_assign_lhs (str_arg_ssa), NULL_TREE, 1, iter, /*non_zero_len_p*/true, /*before_p=*/true, - /*is_store=*/false, /*is_scalar_access*/true, /*align*/0); + /*is_store=*/false, /*is_scalar_access*/true, /*align*/0, + start_instrumented, start_instrumented); gimple g = gimple_build_assign_with_ops (POINTER_PLUS_EXPR, diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-9.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-9.c new file mode 100644 index 0000000..c6575ad --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-9.c @@ -0,0 +1,13 @@ +/* { dg-options "-fdump-tree-asan0" } */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ + +__SIZE_TYPE__ +f (char *a) +{ + a[0] = '1'; + return __builtin_strlen (a); +} + +/* { dg-final { scan-tree-dump-times "__asan_report_load1" 1 "asan0" } } */ +/* { dg-final { cleanup-tree-dump "asan0" } } */