This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Don't make all MEM_REFs with TREE_READONLY arguments TREE_READONLY (PR sanitizer/64336)
- From: Richard Biener <rguenther at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 17 Dec 2014 15:28:15 +0100 (CET)
- Subject: Re: [PATCH] Don't make all MEM_REFs with TREE_READONLY arguments TREE_READONLY (PR sanitizer/64336)
- Authentication-results: sourceware.org; auth=none
- References: <20141217131815 dot GX1667 at tucnak dot redhat dot com>
On Wed, 17 Dec 2014, Jakub Jelinek wrote:
> Hi!
>
> MEM_REF (the only tcc_reference code with 2 operands) has TREE_READONLY set
> whenever all the arguments are TREE_READONLY, which is wrong, if the
> pointer/reference is read-only, it doesn't say anything about whether
> what it points to is also read-only.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
Thinking about this some more I think that we should instead do sth like
read_only = 1;
side_effects = TREE_SIDE_EFFECTS (t);
if (code == MEM_REF)
{
if (TREE_CODE (arg0) == ADDR_EXPR)
{
tree t = arg0;
PROCESS_ARG (0);
}
else
read_only = 0;
}
else
{
PROCESS_ARG (0);
PROCESS_ARG (1);
}
as otherwise read_only will be wrong for MEM_REFs of const decls?
That is, in your patch PROCESS_ARG (0) will still do bogus stuff
for MEM_REFs.
Thanks,
Richard.
> I'll work on TREE_THIS_VOLATILE for MEM_REF/TARGET_MEM_REF later on, as
> a follow-up.
>
> 2014-12-17 Jakub Jelinek <jakub@redhat.com>
>
> PR sanitizer/64336
> * tree.c (build2_stat): Don't set TREE_READONLY on MEM_REF
> even when the arguments are TREE_READONLY.
>
> --- gcc/tree.c.jj 2014-12-15 10:36:23.000000000 +0100
> +++ gcc/tree.c 2014-12-17 10:48:07.216729576 +0100
> @@ -4352,7 +4352,7 @@ build2_stat (enum tree_code code, tree t
> arguments are as well. */
> constant = (TREE_CODE_CLASS (code) == tcc_comparison
> || TREE_CODE_CLASS (code) == tcc_binary);
> - read_only = 1;
> + read_only = code != MEM_REF;
> side_effects = TREE_SIDE_EFFECTS (t);
>
> PROCESS_ARG (0);
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Jennifer Guild,
Dilip Upmanyu, Graham Norton HRB 21284 (AG Nuernberg)