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: update address taken: don't drop clobbers


On Thu, 10 Jul 2014, Richard Biener wrote:

--- gcc/tree-into-ssa.c (revision 212109)
+++ gcc/tree-into-ssa.c (working copy)
@@ -1831,26 +1831,38 @@ maybe_register_def (def_operand_p def_p,
 {
   tree def = DEF_FROM_PTR (def_p);
   tree sym = DECL_P (def) ? def : SSA_NAME_VAR (def);

   /* If DEF is a naked symbol that needs renaming, create a new
      name for it.  */
   if (marked_for_renaming (sym))
     {
       if (DECL_P (def))
        {
-         tree tracked_var;
-
-         def = make_ssa_name (def, stmt);
+         if (gimple_clobber_p (stmt) && is_gimple_reg (sym))

sym should always be a gimple reg here (it's marked for renaming).

Not quite. If I remove the is_gimple_reg check, I get:

/data/repos/gcc/sra/libgcc/libgcc2.c: In function '__divti3':
/data/repos/gcc/sra/libgcc/libgcc2.c:1246:1: error: non-trivial conversion at assignment
 }
 ^
const union DWunion
void
# .MEM_149 = VDEF <.MEM_148>
nn ={v} .MEM_7(D);


+           {
+             /* Replace clobber stmts with a default def.  Create a new
+                variable so we don't later think we must coalesce, which
would
+                fail with some ada abnormal PHIs.  Still, we try to keep a
+                similar name so error messages make sense.  */
+             unlink_stmt_vdef (stmt);

I think that's redundant with gsi_replace (note that using gsi_replace
looks dangerous here as it calls update_stmt during SSA rewrite...
that might open a can of worms).

+             gsi_replace (&gsi, gimple_build_nop (), true);
+             tree id = DECL_NAME (sym);
+             const char* name = id ? IDENTIFIER_POINTER (id) : 0;
+             tree newvar = create_tmp_var (TREE_TYPE (sym), name);
+             def = get_or_create_ssa_default_def (cfun, newvar);

So - can't you simply do

   gimple_assign_set_rhs_from_tree (&gsi,
get_or_create_dda_default_def (cfun, sym));

?  Thus replace x = CLOBBER; with x_3 = x_2(D);

If I write just that, I get a failure because of a missing USE. I need to run update_stmt (but then you are saying it is dangerous...).

And it also fails to warn for the C++ testcase because SRA sets nowarning_flag (it doesn't if I create a new variable), but I guess we can see about changing that next.

--
Marc Glisse


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