From: Jakub Jelinek Date: Thu, 8 Jan 2015 09:20:24 +0000 (+0100) Subject: re PR sanitizer/64336 (Template functions are not instrumented at -O0 and -Og) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd84df1879c9f7acf4e25a2b7d638013d17e6896;p=gcc.git re PR sanitizer/64336 (Template functions are not instrumented at -O0 and -Og) PR sanitizer/64336 * tree.c (build2_stat): Fix up initialization of TREE_READONLY and TREE_THIS_VOLATILE for MEM_REFs. (build5_stat): Fix up initialization of TREE_READONLY and TREE_THIS_VOLATILE for TARGET_MEM_REFs. From-SVN: r219339 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 55ffb7b7ad3..26615505ec8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-01-08 Jakub Jelinek + + PR sanitizer/64336 + * tree.c (build2_stat): Fix up initialization of TREE_READONLY + and TREE_THIS_VOLATILE for MEM_REFs. + (build5_stat): Fix up initialization of TREE_READONLY and + TREE_THIS_VOLATILE for TARGET_MEM_REFs. + 2015-01-08 Kaz Kojima PR target/64533 diff --git a/gcc/tree.c b/gcc/tree.c index d8807a03528..a3dd6cdae6d 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -4358,12 +4358,24 @@ build2_stat (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL) PROCESS_ARG (0); PROCESS_ARG (1); - TREE_READONLY (t) = read_only; - TREE_CONSTANT (t) = constant; TREE_SIDE_EFFECTS (t) = side_effects; - TREE_THIS_VOLATILE (t) - = (TREE_CODE_CLASS (code) == tcc_reference - && arg0 && TREE_THIS_VOLATILE (arg0)); + if (code == MEM_REF) + { + if (arg0 && TREE_CODE (arg0) == ADDR_EXPR) + { + tree o = TREE_OPERAND (arg0, 0); + TREE_READONLY (t) = TREE_READONLY (o); + TREE_THIS_VOLATILE (t) = TREE_THIS_VOLATILE (o); + } + } + else + { + TREE_READONLY (t) = read_only; + TREE_CONSTANT (t) = constant; + TREE_THIS_VOLATILE (t) + = (TREE_CODE_CLASS (code) == tcc_reference + && arg0 && TREE_THIS_VOLATILE (arg0)); + } return t; } @@ -4458,9 +4470,19 @@ build5_stat (enum tree_code code, tree tt, tree arg0, tree arg1, PROCESS_ARG (4); TREE_SIDE_EFFECTS (t) = side_effects; - TREE_THIS_VOLATILE (t) - = (TREE_CODE_CLASS (code) == tcc_reference - && arg0 && TREE_THIS_VOLATILE (arg0)); + if (code == TARGET_MEM_REF) + { + if (arg0 && TREE_CODE (arg0) == ADDR_EXPR) + { + tree o = TREE_OPERAND (arg0, 0); + TREE_READONLY (t) = TREE_READONLY (o); + TREE_THIS_VOLATILE (t) = TREE_THIS_VOLATILE (o); + } + } + else + TREE_THIS_VOLATILE (t) + = (TREE_CODE_CLASS (code) == tcc_reference + && arg0 && TREE_THIS_VOLATILE (arg0)); return t; }