aboutsummaryrefslogtreecommitdiff
path: root/gcc/sese.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-05-25 12:05:08 +0200
committerJakub Jelinek <jakub@redhat.com>2022-05-25 12:05:08 +0200
commitaf02daff557a0abbf5521c143f1cdda406848a9b (patch)
tree551d2b74dc05d6324dcedc6e3eaa4f88850fb03f /gcc/sese.h
parentc125f504c43a1d863b040375872b6696a6c2b681 (diff)
downloadgcc-af02daff557a0abbf5521c143f1cdda406848a9b.zip
gcc-af02daff557a0abbf5521c143f1cdda406848a9b.tar.gz
gcc-af02daff557a0abbf5521c143f1cdda406848a9b.tar.bz2
asan: Fix up instrumentation of assignments which are both loads and stores [PR105714]
On the following testcase with -Os asan pass sees: <bb 6> [local count: 354334800]: # h_21 = PHI <h_15(6), 0(5)> *c.3_5 = *d.2_4; h_15 = h_21 + 1; if (h_15 != 3) goto <bb 6>; [75.00%] else goto <bb 7>; [25.00%] <bb 7> [local count: 118111600]: *c.3_5 = MEM[(struct a *)&b + 12B]; _13 = c.3_5->x; return _13; It instruments the *c.3_5 = *d.2_4; assignment by adding .ASAN_CHECK (7, c.3_5, 4, 4); .ASAN_CHECK (6, d.2_4, 4, 4); before it (which later lowers to checking the corresponding shadow memory). But when considering instrumentation of *c.3_5 = MEM[(struct a *)&b + 12B]; it doesn't instrument anything, because it sees that *c.3_5 store is already instrumented in a dominating block and so there is no need to instrument *c.3_5 store again (i.e. add another .ASAN_CHECK (7, c.3_5, 4, 4); ). That is true, but misses the fact that we still want to instrument the MEM[(struct a *)&b + 12B] load. The following patch fixes that by changing has_stmt_been_instrumented_p to consider both store and load in the assignment if it does both (returning true iff both have been instrumented). That matches how we handle e.g. builtin calls, where we also perform AND of all the memory locs involved in the call. I've verified that we still don't add the redundant .ASAN_CHECK (7, c.3_5, 4, 4); call but just add _18 = &MEM[(struct a *)&b + 12B]; .ASAN_CHECK (6, _18, 4, 4); to instrument the load. 2022-05-25 Jakub Jelinek <jakub@redhat.com> PR sanitizer/105714 * asan.cc (has_stmt_been_instrumented_p): For assignments which are both stores and loads, return true only if both destination and source have been instrumented. * gcc.dg/asan/pr105714.c: New test.
Diffstat (limited to 'gcc/sese.h')
0 files changed, 0 insertions, 0 deletions