use-after-scope: handle writes to a poisoned variable
authorMartin Liska <marxin@gcc.gnu.org>
Mon, 23 Jan 2017 12:06:13 +0000 (12:06 +0000)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 23 Jan 2017 12:06:13 +0000 (12:06 +0000)
commitf6b9f2ffc190054ca8f4dad110d85613964d2006
tree36be2ac0b98ff565f4e87f29d7da27515ced8305
parenta51368fad9985f84e3215cf9897f389698fbbba5
use-after-scope: handle writes to a poisoned variable

2017-01-23  Martin Liska  <mliska@suse.cz>

* gcc.dg/asan/use-after-scope-10.c: New test.
* gcc.dg/asan/use-after-scope-11.c: New test.
* g++.dg/asan/use-after-scope-5.C: New test.
2017-01-23  Jakub Jelinek  <jakub@redhat.com>
    Martin Liska  <mliska@suse.cz>

* asan.h: Define ASAN_USE_AFTER_SCOPE_ATTRIBUTE.
* asan.c (asan_expand_poison_ifn): Support stores and use
appropriate ASAN report function.
* internal-fn.c (expand_ASAN_POISON_USE): New function.
* internal-fn.def (ASAN_POISON_USE): Declare.
* tree-into-ssa.c (maybe_add_asan_poison_write): New function.
(maybe_register_def): Create ASAN_POISON_USE when sanitizing.
* tree-ssa-dce.c (eliminate_unnecessary_stmts): Remove
ASAN_POISON calls w/o LHS.
* tree-ssa.c (execute_update_addresses_taken): Create clobber
for ASAN_MARK (UNPOISON, &x, ...) in order to prevent usage of a LHS
from ASAN_MARK (POISON, &x, ...) coming to a PHI node.
* gimplify.c (asan_poison_variables): Add attribute
use_after_scope_memory to variables that really needs to live
in memory.
* tree-ssa.c (is_asan_mark_p): Do not rewrite into SSA when
having the attribute.

From-SVN: r244793
13 files changed:
gcc/ChangeLog
gcc/asan.c
gcc/asan.h
gcc/gimplify.c
gcc/internal-fn.c
gcc/internal-fn.def
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/asan/use-after-scope-5.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/asan/use-after-scope-10.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/asan/use-after-scope-11.c [new file with mode: 0644]
gcc/tree-into-ssa.c
gcc/tree-ssa-dce.c
gcc/tree-ssa.c