Hi,

On Fri, Apr 06, 2012 at 06:13:20PM +0200, Eric Botcazou wrote:
> > 2012-04-03  Martin Jambor  <mjam...@suse.cz>
> >
> >     * expr.c (expand_expr_real_1): Pass type, not the expression, to
> >     set_mem_attributes for a memory temporary.  Do not call the
> >     function for temporaries with a different alias set.
> 
> The last sentence is unprecise, this would rather be: "Do not call
> the function for the memory temporary created for a bitfield".

OK

> 
> I wonder whether we should simplify the bitfield case in the process.  Once 
> we 
> remove the call to set_mem_attributes, I think the
> 
>               /* If the reference doesn't use the alias set of its type,
>                  we cannot create the temporary using that type.  */
> 
> is useless, so we could try to revert r122014 in the process.

Well, the commit did not add a testcase and when I looked up the patch
in the mailing list archive
(http://gcc.gnu.org/ml/gcc-patches/2006-11/msg01449.html) it said it
was fixing problems not reproducible on trunk so it's basically
impossible for me to evaluate whether it is still necessary by some
simple testing.  Having said that, I guess I can give it a round of
regular testing on all the platforms I have currently set up.

On Fri, Apr 06, 2012 at 06:21:55PM +0200, Eric Botcazou wrote:
> > @@ -9870,7 +9871,14 @@ expand_expr_real_1 (tree exp, rtx target
> >     if (op0 == orig_op0)
> >       op0 = copy_rtx (op0);
> >
> > -   set_mem_attributes (op0, exp, 0);
> > +   /* If op0 is a temporary because of forcing to memory, pass only the
> > +      type to set_mem_attributes so that the original expression is never
> > +      marked as ADDRESSABLE through MEM_EXPR of the temporary.  */
> > +   if (mem_attrs_from_type)
> > +     set_mem_attributes (op0, TREE_TYPE (exp), 0);
> 
> set_mem_attributes (op0, type, 0); is equivalent.
> 

OK.

So basically I'd like to commit the following.  It has been
successfully bootstrapped and tested on x86_64-linux, i686-linux,
sparc64-linux (without Java), ia64-linux (without Ada) and tested on
hppa-linux (C and C++ only).

OK for trunk?

Thanks,

Martin


2012-04-10  Martin Jambor  <mjam...@suse.cz>

        * expr.c (expand_expr_real_1): Pass type, not the expression, to
        set_mem_attributes for a memory temporary. Do not call the function
        for the memory temporary created for a bitfield.

Index: src/gcc/expr.c
===================================================================
--- src.orig/gcc/expr.c
+++ src/gcc/expr.c
@@ -9598,6 +9598,7 @@ expand_expr_real_1 (tree exp, rtx target
        tree tem = get_inner_reference (exp, &bitsize, &bitpos, &offset,
                                        &mode1, &unsignedp, &volatilep, true);
        rtx orig_op0, memloc;
+       bool mem_attrs_from_type = false;
 
        /* If we got back the original object, something is wrong.  Perhaps
           we are evaluating an expression too early.  In any event, don't
@@ -9703,6 +9704,7 @@ expand_expr_real_1 (tree exp, rtx target
            memloc = assign_temp (nt, 1, 1, 1);
            emit_move_insn (memloc, op0);
            op0 = memloc;
+           mem_attrs_from_type = true;
          }
 
        if (offset)
@@ -9875,7 +9877,6 @@ expand_expr_real_1 (tree exp, rtx target
                emit_move_insn (new_rtx, op0);
                op0 = copy_rtx (new_rtx);
                PUT_MODE (op0, BLKmode);
-               set_mem_attributes (op0, exp, 1);
              }
 
            return op0;
@@ -9896,7 +9897,14 @@ expand_expr_real_1 (tree exp, rtx target
        if (op0 == orig_op0)
          op0 = copy_rtx (op0);
 
-       set_mem_attributes (op0, exp, 0);
+       /* If op0 is a temporary because of forcing to memory, pass only the
+          type to set_mem_attributes so that the original expression is never
+          marked as ADDRESSABLE through MEM_EXPR of the temporary.  */
+       if (mem_attrs_from_type)
+         set_mem_attributes (op0, type, 0);
+       else
+         set_mem_attributes (op0, exp, 0);
+
        if (REG_P (XEXP (op0, 0)))
          mark_reg_pointer (XEXP (op0, 0), MEM_ALIGN (op0));
 

Reply via email to