This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tuples][patch] Convert pass_ccp and pass_store_ccp to tuples


Hi,

> 	* gimple.c (gimple_copy_no_def_use): New function.
> 	* gimple.h (gimple_copy_no_def_use): Declare new function.
> 
> +/* Return a copy of statement STMT.  The copy should not retain any use
> +   information for the variables that appear within it.  */
> +/* FIXME tuples.  The charter of this function is unclear.  It was
> +   introduced to replace occurrences of unshare_expr in cases where
> +   a statement is copied temporarily in order to present a "before
> +   and after" diagnostic, e.g., showing folding in substitute_and_fold.
> +   In that case, uses occuring in the saved statement were linked from
> +   definitions elsewhere, confusing code that expected no such uses to
> +   exist.  It might be preferable to rewrite such diagnostics to simply
> +   dump the "before" diagnostic to a string, rather than retaining a
> +   statement for later processing.  */

as far as I can tell, this function only differs from gimple_copy for
phi nodes, and by not calling update_stmt for the copy.  The unsharing of
args of phi nodes should be done in gimple_copy as well; and not calling
update_stmt would be better handled either by adding a parameter
to gimple_copy, or making gimple_copy use gimple_copy_no_def_use
internally (rather than duplicating its code),

Zdenek

> +gimple
> +gimple_copy_no_def_use (gimple stmt)
> +{
> +  enum gimple_code code = gimple_code (stmt);
> +
> +  if (code == GIMPLE_PHI)
> +    {
> +      unsigned i;
> +      size_t size = (sizeof (struct gimple_statement_phi)
> +                     + (sizeof (struct phi_arg_d) * (stmt->gimple_phi.capacity - 1)));
> +      gimple copy = ggc_alloc_cleared (size);
> +
> +      memcpy (copy, stmt, size);
> +      gimple_phi_set_result (copy, unshare_expr (gimple_phi_result (stmt)));
> +      for (i = 0; i < gimple_phi_num_args(stmt); i++)
> +      {
> +        struct phi_arg_d * arg_ptr = gimple_phi_arg (copy, i);
> +        arg_ptr->def = unshare_expr (gimple_phi_arg_def (stmt, i));
> +        /*
> +        arg_ptr->imm_use.prev = &arg_ptr->imm_use;
> +        arg_ptr->imm_use.next = &arg_ptr->imm_use;
> +        arg_ptr->imm_use.loc.ssa_name = NULL;
> +        arg_ptr->imm_use.use = NULL;
> +        */
> +      }
> +
> +      return copy;
> +    }
> +  else
> +    {
> +      size_t num_ops = gimple_num_ops (stmt);
> +      gimple copy = gimple_alloc (code);
> +      unsigned i;
> +
> +      memcpy (copy, stmt, gimple_size (code));
> +      if (num_ops > 0)
> +      {
> +        gimple_alloc_ops (copy, num_ops);
> +        for (i = 0; i < num_ops; i++)
> +          gimple_set_op (copy, i, unshare_expr (gimple_op (stmt, i)));
> +
> +        gimple_set_def_ops (copy, NULL);
> +        gimple_set_use_ops (copy, NULL);
> +      }
> +
> +      return copy;
> +    }
> +}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]