]> gcc.gnu.org Git - gcc.git/commitdiff
Replace more DEBUG_EXPR_DECL creations with build_debug_expr_decl
authorMartin Jambor <mjambor@suse.cz>
Tue, 16 Nov 2021 09:44:54 +0000 (10:44 +0100)
committerMartin Jambor <mjambor@suse.cz>
Tue, 16 Nov 2021 09:45:46 +0000 (10:45 +0100)
As discussed on the mailing list, this patch replaces all but one
remaining open coded constructions of DEBUG_EXPR_DECL with calls to
build_debug_expr_decl, even if - in order not to introduce any
functional change - the mode of the constructed decl is then
overwritten.

It is not clear if changing the mode has any effect in practice and
therefore I have added a FIXME note to code which does it, as
requested.

After this patch, DEBUG_EXPR_DECLs are created only by
build_debug_expr_decl and make_debug_expr_from_rtl which looks like
it should be left alone.

gcc/ChangeLog:

2021-11-11  Martin Jambor  <mjambor@suse.cz>

* cfgexpand.c (expand_gimple_basic_block): Use build_debug_expr_decl,
add a fixme note about the mode assignment perhaps being unnecessary.
* ipa-param-manipulation.c (ipa_param_adjustments::modify_call):
Likewise.
(ipa_param_body_adjustments::mark_dead_statements): Likewise.
(ipa_param_body_adjustments::reset_debug_stmts): Likewise.
* tree-inline.c (remap_ssa_name): Likewise.
(tree_function_versioning): Likewise.
* tree-into-ssa.c (rewrite_debug_stmt_uses): Likewise.
* tree-ssa-loop-ivopts.c (remove_unused_ivs): Likewise.
* tree-ssa.c (insert_debug_temp_for_var_def): Likewise.

gcc/cfgexpand.c
gcc/ipa-param-manipulation.c
gcc/tree-inline.c
gcc/tree-into-ssa.c
gcc/tree-ssa-loop-ivopts.c
gcc/tree-ssa.c

index 55ff75bd78e369c783e0f04fa6322e837d9f2940..eb6466f4be6f72f589abb1055f69d0d323af5c80 100644 (file)
@@ -5898,18 +5898,17 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls)
                       temporary.  */
                    gimple *debugstmt;
                    tree value = gimple_assign_rhs_to_tree (def);
-                   tree vexpr = make_node (DEBUG_EXPR_DECL);
+                   tree vexpr = build_debug_expr_decl (TREE_TYPE (value));
                    rtx val;
                    machine_mode mode;
 
                    set_curr_insn_location (gimple_location (def));
 
-                   DECL_ARTIFICIAL (vexpr) = 1;
-                   TREE_TYPE (vexpr) = TREE_TYPE (value);
                    if (DECL_P (value))
                      mode = DECL_MODE (value);
                    else
                      mode = TYPE_MODE (TREE_TYPE (value));
+                   /* FIXME: Is setting the mode really necessary? */
                    SET_DECL_MODE (vexpr, mode);
 
                    val = gen_rtx_VAR_LOCATION
index 0a5ed858a28bf248d71933b6cdabfe92ae069298..cec1dba701f0d99bf5cf2b1bf592a2287c03a992 100644 (file)
@@ -888,9 +888,8 @@ ipa_param_adjustments::modify_call (cgraph_edge *cs,
              }
          if (ddecl == NULL)
            {
-             ddecl = make_node (DEBUG_EXPR_DECL);
-             DECL_ARTIFICIAL (ddecl) = 1;
-             TREE_TYPE (ddecl) = TREE_TYPE (origin);
+             ddecl = build_debug_expr_decl (TREE_TYPE (origin));
+             /* FIXME: Is setting the mode really necessary? */
              SET_DECL_MODE (ddecl, DECL_MODE (origin));
 
              vec_safe_push (*debug_args, origin);
@@ -1120,9 +1119,8 @@ ipa_param_body_adjustments::mark_dead_statements (tree dead_param,
       return;
     }
 
-  tree dp_ddecl = make_node (DEBUG_EXPR_DECL);
-  DECL_ARTIFICIAL (dp_ddecl) = 1;
-  TREE_TYPE (dp_ddecl) = TREE_TYPE (dead_param);
+  tree dp_ddecl = build_debug_expr_decl (TREE_TYPE (dead_param));
+  /* FIXME: Is setting the mode really necessary? */
   SET_DECL_MODE (dp_ddecl, DECL_MODE (dead_param));
   m_dead_ssa_debug_equiv.put (parm_ddef, dp_ddecl);
 }
@@ -2285,11 +2283,10 @@ ipa_param_body_adjustments::reset_debug_stmts ()
            gcc_assert (is_gimple_debug (stmt));
            if (vexpr == NULL && gsip != NULL)
              {
-               vexpr = make_node (DEBUG_EXPR_DECL);
-               def_temp = gimple_build_debug_source_bind (vexpr, decl, NULL);
-               DECL_ARTIFICIAL (vexpr) = 1;
-               TREE_TYPE (vexpr) = TREE_TYPE (name);
+               vexpr = build_debug_expr_decl (TREE_TYPE (name));
+               /* FIXME: Is setting the mode really necessary? */
                SET_DECL_MODE (vexpr, DECL_MODE (decl));
+               def_temp = gimple_build_debug_source_bind (vexpr, decl, NULL);
                gsi_insert_before (gsip, def_temp, GSI_SAME_STMT);
              }
            if (vexpr)
index 53d664ec2e4f589a0c6ccb54b48a0fbbee540dc3..8c108d8e4e701fa0ef1cbd0a831ef1f9f05b4bcb 100644 (file)
@@ -193,7 +193,6 @@ remap_ssa_name (tree name, copy_body_data *id)
          && id->entry_bb == NULL
          && single_succ_p (ENTRY_BLOCK_PTR_FOR_FN (cfun)))
        {
-         tree vexpr = make_node (DEBUG_EXPR_DECL);
          gimple *def_temp;
          gimple_stmt_iterator gsi;
          tree val = SSA_NAME_VAR (name);
@@ -210,10 +209,10 @@ remap_ssa_name (tree name, copy_body_data *id)
          n = id->decl_map->get (val);
          if (n && TREE_CODE (*n) == DEBUG_EXPR_DECL)
            return *n;
-         def_temp = gimple_build_debug_source_bind (vexpr, val, NULL);
-         DECL_ARTIFICIAL (vexpr) = 1;
-         TREE_TYPE (vexpr) = TREE_TYPE (name);
+         tree vexpr = build_debug_expr_decl (TREE_TYPE (name));
+         /* FIXME: Is setting the mode really necessary? */
          SET_DECL_MODE (vexpr, DECL_MODE (SSA_NAME_VAR (name)));
+         def_temp = gimple_build_debug_source_bind (vexpr, val, NULL);
          gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
          gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT);
          insert_decl_map (id, val, vexpr);
@@ -6450,9 +6449,8 @@ tree_function_versioning (tree old_decl, tree new_decl,
              debug_args = decl_debug_args_insert (new_decl);
              len = vec_safe_length (*debug_args);
            }
-         ddecl = make_node (DEBUG_EXPR_DECL);
-         DECL_ARTIFICIAL (ddecl) = 1;
-         TREE_TYPE (ddecl) = TREE_TYPE (parm);
+         ddecl = build_debug_expr_decl (TREE_TYPE (parm));
+         /* FIXME: Is setting the mode really necessary? */
          SET_DECL_MODE (ddecl, DECL_MODE (parm));
          vec_safe_push (*debug_args, DECL_ORIGIN (parm));
          vec_safe_push (*debug_args, ddecl);
@@ -6488,9 +6486,8 @@ tree_function_versioning (tree old_decl, tree new_decl,
                  vexpr = *d;
              if (!vexpr)
                {
-                 vexpr = make_node (DEBUG_EXPR_DECL);
-                 DECL_ARTIFICIAL (vexpr) = 1;
-                 TREE_TYPE (vexpr) = TREE_TYPE (parm);
+                 vexpr = build_debug_expr_decl (TREE_TYPE (parm));
+                 /* FIXME: Is setting the mode really necessary? */
                  SET_DECL_MODE (vexpr, DECL_MODE (parm));
                }
              def_temp = gimple_build_debug_bind (var, vexpr, NULL);
index 8045e34df261c841f7537c037145b4ffdbf27239..265dcc5d42fcda0f837e2ad0edb88e5d56e90e47 100644 (file)
@@ -1284,11 +1284,10 @@ rewrite_debug_stmt_uses (gimple *stmt)
              if (def == NULL_TREE)
                {
                  gimple *def_temp;
-                 def = make_node (DEBUG_EXPR_DECL);
-                 def_temp = gimple_build_debug_source_bind (def, var, NULL);
-                 DECL_ARTIFICIAL (def) = 1;
-                 TREE_TYPE (def) = TREE_TYPE (var);
+                 def = build_debug_expr_decl (TREE_TYPE (var));
+                 /* FIXME: Is setting the mode really necessary? */
                  SET_DECL_MODE (def, DECL_MODE (var));
+                 def_temp = gimple_build_debug_source_bind (def, var, NULL);
                  gsi =
                 gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
                  gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT);
index 4a498abe3b018b68f25c4fec3ae6321f7ad15bc3..5a7fd305d91da7bd66a7a2132b230fd55ba976a7 100644 (file)
@@ -7742,9 +7742,8 @@ remove_unused_ivs (struct ivopts_data *data, bitmap toremove)
              comp = unshare_expr (comp);
              if (count > 1)
                {
-                 tree vexpr = make_node (DEBUG_EXPR_DECL);
-                 DECL_ARTIFICIAL (vexpr) = 1;
-                 TREE_TYPE (vexpr) = TREE_TYPE (comp);
+                 tree vexpr = build_debug_expr_decl (TREE_TYPE (comp));
+                 /* FIXME: Is setting the mode really necessary? */
                  if (SSA_NAME_VAR (def))
                    SET_DECL_MODE (vexpr, DECL_MODE (SSA_NAME_VAR (def)));
                  else
index 3f25d654d3f2826594726e31fbcf8a580e07eab2..1565e21d9832c8cb60909ce9cac5f525d9b8dd00 100644 (file)
@@ -434,14 +434,13 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var)
       else
        {
          gdebug *def_temp;
-         tree vexpr = make_node (DEBUG_EXPR_DECL);
+         tree vexpr = build_debug_expr_decl (TREE_TYPE (value));
 
          def_temp = gimple_build_debug_bind (vexpr,
                                              unshare_expr (value),
                                              def_stmt);
 
-         DECL_ARTIFICIAL (vexpr) = 1;
-         TREE_TYPE (vexpr) = TREE_TYPE (value);
+         /* FIXME: Is setting the mode really necessary? */
          if (DECL_P (value))
            SET_DECL_MODE (vexpr, DECL_MODE (value));
          else
This page took 0.072712 seconds and 5 git commands to generate.