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" } } */
14 /* __builtin___asan_report_store1 called 2 times for the two stores
19 /* This load should not be instrumented because it is to the same
20 memory location as above. */
29 __attribute__((noinline
, noclone
)) static int
34 /*__builtin___asan_report_store1 called 1 time here to instrument
35 the initialization. */
38 /*__builtin___asan_report_store_n called once here to instrument
39 the store to the memory region of tab. */
40 __builtin_memset (tab
, 3, sizeof (tab
));
42 /* There is no instrumentation for the two memset calls below. */
43 __builtin_memset (tab
, 4, sizeof (tab
));
44 __builtin_memset (tab
, 5, sizeof (tab
));
46 /* There is a call to __builtin___asan_report_store_n and a call
47 to __builtin___asan_report_load_n to instrument the store to
48 (subset of) the memory region of tab. */
49 __builtin_memcpy (&tab
[1], foo
+ i
, 3);
51 /* This should not generate a __builtin___asan_report_load1 because
52 the reference to tab[1] has been already instrumented above. */
55 /* So for these functions, there should be 3 calls to
56 __builtin___asan_report_store1. */
62 return test0 () && test1 (0);
65 /* { dg-final { scan-tree-dump-times "__builtin___asan_report_store1" 3 "asan0" } } */
66 /* { dg-final { scan-tree-dump-times "__builtin___asan_report_store_n" 2 "asan0" } } */
67 /* { dg-final { scan-tree-dump-times "__builtin___asan_report_load" 1 "asan0" } } */
68 /* { dg-final { cleanup-tree-dump "asan0" } } */