From: Martin Liska Date: Mon, 6 Mar 2017 10:20:33 +0000 (+0100) Subject: Fix ICE in use-after-scope w/ -fno-tree-dce (PR sanitize/79783). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a50a32aa3cbd139b2fbc56bcd80a82dc7f6ca5e5;p=gcc.git Fix ICE in use-after-scope w/ -fno-tree-dce (PR sanitize/79783). 2017-03-06 Martin Liska PR sanitize/79783 * asan.c (asan_expand_poison_ifn): Do not expand ASAN_POISON when having a SSA NAME w/o VAR_DECL assigned to it. 2017-03-06 Martin Liska PR sanitize/79783 * g++.dg/asan/pr79783.C: New test. From-SVN: r245912 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b588b47231b..35f5288c798 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-03-06 Martin Liska + + PR sanitize/79783 + * asan.c (asan_expand_poison_ifn): Do not expand ASAN_POISON + when having a SSA NAME w/o VAR_DECL assigned to it. + 2017-03-06 Prachi Godbole * config/mips/mips-msa.md (msa_dotp__d, msa_dpadd__d, diff --git a/gcc/asan.c b/gcc/asan.c index 6cdd59b7ea7..7223e3cc68d 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -3107,12 +3107,16 @@ asan_expand_poison_ifn (gimple_stmt_iterator *iter, { gimple *g = gsi_stmt (*iter); tree poisoned_var = gimple_call_lhs (g); - if (!poisoned_var) + if (!poisoned_var || has_zero_uses (poisoned_var)) { gsi_remove (iter, true); return true; } + if (SSA_NAME_VAR (poisoned_var) == NULL_TREE) + SET_SSA_NAME_VAR_OR_IDENTIFIER (poisoned_var, + create_tmp_var (TREE_TYPE (poisoned_var))); + tree shadow_var = create_asan_shadow_var (SSA_NAME_VAR (poisoned_var), shadow_vars_mapping); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9a44150b931..83e7a99b514 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-06 Martin Liska + + PR sanitize/79783 + * g++.dg/asan/pr79783.C: New test. + 2017-03-06 Prachi Godbole * gcc.target/mips/msa-dotp.c: New tests. diff --git a/gcc/testsuite/g++.dg/asan/pr79783.C b/gcc/testsuite/g++.dg/asan/pr79783.C new file mode 100644 index 00000000000..939f60b2819 --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr79783.C @@ -0,0 +1,19 @@ +// PR sanitizer/79783 +// { dg-options "-fno-tree-dce" } + +struct A +{ + static void foo(const char&) {} +}; + +struct B +{ + B() { A::foo(char()); } +}; + +struct C +{ + virtual void bar() const { B b; } +}; + +C c;