From a50a32aa3cbd139b2fbc56bcd80a82dc7f6ca5e5 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 6 Mar 2017 11:20:33 +0100 Subject: [PATCH] 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 --- gcc/ChangeLog | 6 ++++++ gcc/asan.c | 6 +++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/asan/pr79783.C | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/asan/pr79783.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b588b47..35f5288 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 6cdd59b..7223e3c 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 9a44150..83e7a99 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 0000000..939f60b --- /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; -- 2.7.4