On Tue, 18 May 2021, Richard Sandiford wrote:

> Richard Biener <rguent...@suse.de> writes:
> > @@ -6621,9 +6637,31 @@ pass_expand::execute (function *fun)
> >              (int) param_ssp_buffer_size);
> >      }
> >  
> > +  /* Temporarily mark PARM_DECLs and RESULT_DECLs we need to expand to
> > +     memory addressable so expand_function_start can emit the required
> > +     copies.  */
> > +  for (tree parm = DECL_ARGUMENTS (current_function_decl); parm;
> > +       parm = DECL_CHAIN (parm))
> > +    if (bitmap_bit_p (forced_stack_vars, DECL_UID (parm)))
> > +      TREE_ADDRESSABLE (parm) = 1;
> > +  if (DECL_RESULT (current_function_decl)
> > +      && bitmap_bit_p (forced_stack_vars,
> > +                  DECL_UID (DECL_RESULT (current_function_decl))))
> > +    TREE_ADDRESSABLE (DECL_RESULT (current_function_decl)) = 1;
> > +
> >    /* Set up parameters and prepare for return, for the function.  */
> >    expand_function_start (current_function_decl);
> >  
> > +  /* Clear TREE_ADDRESSABLE again.  */
> > +  for (tree parm = DECL_ARGUMENTS (current_function_decl); parm;
> > +       parm = DECL_CHAIN (parm))
> > +    if (bitmap_bit_p (forced_stack_vars, DECL_UID (parm)))
> > +      TREE_ADDRESSABLE (parm) = 0;
> > +  if (DECL_RESULT (current_function_decl)
> > +      && bitmap_bit_p (forced_stack_vars,
> > +                  DECL_UID (DECL_RESULT (current_function_decl))))
> > +    TREE_ADDRESSABLE (DECL_RESULT (current_function_decl)) = 0;
> > +
> >    /* If we emitted any instructions for setting up the variables,
> >       emit them before the FUNCTION_START note.  */
> >    if (var_seq)
> 
> Is TREE_ADDRESSABLE guaranteed to be 0 for these decls before the code
> is hit?  I was surprised that we didn't need to protect against net
> 1->0 transitions.

Yes, bits are only set for decls satisfying use_register_for_decl.
Oops, now that I'm double-checking, we fail to check that in
discover_nonconstant_array_refs_r - I'll fix that.  I can also make
the above fool-proof by recoding the decls I marked addressable
in a vec and traverse that for unsetting - would that be prefered?

Thanks,
Richard.

Reply via email to