1 /* This tests that when faced with two references to the same memory
2 location in the same basic block, the second reference should not
3 be instrumented by the Address Sanitizer. */
5 /* { dg-options "-fdump-tree-asan0" } */
6 /* { dg-do compile } */
7 /* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
9 static char tab[4] = {0};
14 /* __builtin___asan_report_store1 called 2 times for the two stores
19 /* __builtin___asan_report_load1 called 1 time for the store
23 /* This load should not be instrumented because it is to the same
24 memory location as above. */
33 /*__builtin___asan_report_store1 called 1 time here to instrument
34 the initialization. */
37 /*__builtin___asan_report_store1 called 2 times here to instrument
38 the store to the memory region of tab. */
39 __builtin_memset (tab, 3, sizeof (tab));
41 /* There is no instrumentation for the two memset calls below. */
42 __builtin_memset (tab, 4, sizeof (tab));
43 __builtin_memset (tab, 5, sizeof (tab));
45 /* There are 2 calls to __builtin___asan_report_store1 and 2 calls
46 to __builtin___asan_report_load1 to instrument the store to
47 (subset of) the memory region of tab. */
48 __builtin_memcpy (&tab[1], foo, 3);
50 /* This should not generate a __builtin___asan_report_load1 because
51 the reference to tab[1] has been already instrumented above. */
54 /* So for these function, there should be 7 calls to
55 __builtin___asan_report_store1. */
61 return test0 () && test1 ();
64 /* { dg-final { scan-tree-dump-times "__builtin___asan_report_store1" 7 "asan0" } } */
65 /* { dg-final { scan-tree-dump-times "__builtin___asan_report_load" 2 "asan0" } } */
66 /* { dg-final { cleanup-tree-dump "asan0" } } */