]> gcc.gnu.org Git - gcc.git/commitdiff
Fix up dump_printf_loc format attribute and adjust uses [PR106782]
authorJakub Jelinek <jakub@redhat.com>
Thu, 1 Sep 2022 09:07:44 +0000 (11:07 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 1 Sep 2022 09:07:44 +0000 (11:07 +0200)
As discussed on IRC, the r13-2299-g68c61c2daa1f bug only got missed
because dump_printf_loc had incorrect format attribute and therefore
almost no -Wformat=* checking was performed on it.
3, 0 are suitable for function with (whatever, whatever, const char *, va_list)
arguments, not for (whatever, whatever, const char *, ...), that one should
use 3, 4.

The following patch fixes that and adjusts all spots to fix warnings.
In many cases it is just through an ugly cast (for %G casts to gimple *
from gassign */gphi * and the like and for %p casts to void * from slp_node
etc.).
There are 3 spots where the mismatch was worse though, two using %u or %d
for unsigned HOST_WIDE_INT argument and one %T for enum argument (promoted
to int).

2022-09-01  Jakub Jelinek  <jakub@redhat.com>

PR other/106782
* dumpfile.h (dump_printf_loc): Use ATTRIBUTE_GCC_DUMP_PRINTF (3, 4)
instead of ATTRIBUTE_GCC_DUMP_PRINTF (3, 0).
* tree-parloops.cc (parloops_is_slp_reduction): Cast pointers to
derived types of gimple to gimple * to avoid -Wformat warnings.
* tree-vect-loop-manip.cc (vect_set_loop_condition,
vect_update_ivs_after_vectorizer): Likewise.
* tree-vect-stmts.cc (vectorizable_load): Likewise.
* tree-vect-patterns.cc (vect_split_statement,
vect_recog_mulhs_pattern, vect_recog_average_pattern,
vect_determine_precisions_from_range,
vect_determine_precisions_from_users): Likewise.
* gimple-loop-versioning.cc
(loop_versioning::analyze_term_using_scevs): Likewise.
* tree-vect-slp.cc (vect_build_slp_tree_1): Likewise.
(vect_build_slp_tree): Cast slp_tree to void * to avoid
-Wformat warnings.
(optimize_load_redistribution_1, vect_match_slp_patterns,
vect_build_slp_instance, vect_optimize_slp_pass::materialize,
vect_optimize_slp_pass::dump, vect_slp_convert_to_external,
vect_slp_analyze_node_operations, vect_bb_partition_graph): Likewise.
(vect_print_slp_tree): Likewise.  Also use
HOST_WIDE_INT_PRINT_UNSIGNED instead of %u.
* tree-vect-loop.cc (vect_determine_vectorization_factor,
vect_analyze_scalar_cycles_1, vect_analyze_loop_operations,
vectorizable_induction, vect_transform_loop): Cast pointers to derived
types of gimple to gimple * to avoid -Wformat warnings.
(vect_analyze_loop_2): Cast slp_tree to void * to avoid
-Wformat warnings.
(vect_estimate_min_profitable_iters): Use HOST_WIDE_INT_PRINT_UNSIGNED
instead of %d.
* tree-vect-slp-patterns.cc (vect_pattern_validate_optab): Use %G
instead of %T and STMT_VINFO_STMT (SLP_TREE_REPRESENTATIVE (node))
instead of SLP_TREE_DEF_TYPE (node).

gcc/dumpfile.h
gcc/gimple-loop-versioning.cc
gcc/tree-parloops.cc
gcc/tree-vect-loop-manip.cc
gcc/tree-vect-loop.cc
gcc/tree-vect-patterns.cc
gcc/tree-vect-slp-patterns.cc
gcc/tree-vect-slp.cc
gcc/tree-vect-stmts.cc

index 3c47f099a803b3e33eeff9847e18a49765629108..b2219c55f15499d89f5fa22311050f897b2950dc 100644 (file)
@@ -574,7 +574,7 @@ extern void dump_printf (const dump_metadata_t &, const char *, ...)
 
 extern void dump_printf_loc (const dump_metadata_t &, const dump_user_location_t &,
                             const char *, ...)
-  ATTRIBUTE_GCC_DUMP_PRINTF (3, 0);
+  ATTRIBUTE_GCC_DUMP_PRINTF (3, 4);
 extern void dump_function (int phase, tree fn);
 extern void dump_basic_block (dump_flags_t, basic_block, int);
 extern void dump_generic_expr_loc (const dump_metadata_t &,
index 6bcf6eba691bb15def3477a02cc971080e52f8c7..b2e3c4319a1a5431e251d6e4af85d1805bd5eef8 100644 (file)
@@ -940,7 +940,7 @@ loop_versioning::analyze_term_using_scevs (address_info &address,
        {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_NOTE, address.stmt,
-                            "looking through %G", assign);
+                            "looking through %G", (gimple *) assign);
          stride = strip_casts (gimple_assign_rhs1 (assign));
        }
 
index 76483fcaaa2d297c267e66a6f300e2be7a291ca3..e4a148b5365134d0d424569f55074381570aeab1 100644 (file)
@@ -338,8 +338,8 @@ parloops_is_slp_reduction (loop_vec_info loop_info, gimple *phi,
              && parloops_valid_reduction_input_p (def_stmt_info))
            {
              if (dump_enabled_p ())
-               dump_printf_loc (MSG_NOTE, vect_location, "swapping oprnds: %G",
-                                next_stmt);
+               dump_printf_loc (MSG_NOTE, vect_location,
+                                "swapping oprnds: %G", (gimple *) next_stmt);
 
              swap_ssa_operands (next_stmt,
                                 gimple_assign_rhs1_ptr (next_stmt),
index 48a5f391d7f21d7758dc66d381bbbe3ea5803247..b68e6cd5be4a57390ec861442bca0762527572d0 100644 (file)
@@ -992,7 +992,7 @@ vect_set_loop_condition (class loop *loop, loop_vec_info loop_vinfo,
 
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location, "New loop exit condition: %G",
-                    cond_stmt);
+                    (gimple *) cond_stmt);
 }
 
 /* Helper routine of slpeel_tree_duplicate_loop_to_edge_cfg.
@@ -1539,7 +1539,8 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo,
       stmt_vec_info phi_info = loop_vinfo->lookup_stmt (phi);
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,
-                        "vect_update_ivs_after_vectorizer: phi: %G", phi);
+                        "vect_update_ivs_after_vectorizer: phi: %G",
+                        (gimple *) phi);
 
       /* Skip reduction and virtual phis.  */
       if (!iv_phi_p (phi_info))
index 2257b29a652699d03768704b047c0ec8a4d38eac..24556b5009a04e4d38c104411fad361520248cdc 100644 (file)
@@ -304,7 +304,7 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
          stmt_info = loop_vinfo->lookup_stmt (phi);
          if (dump_enabled_p ())
            dump_printf_loc (MSG_NOTE, vect_location, "==> examining phi: %G",
-                            phi);
+                            (gimple *) phi);
 
          gcc_assert (stmt_info);
 
@@ -489,7 +489,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, class loop *loop,
       stmt_vec_info stmt_vinfo = loop_vinfo->lookup_stmt (phi);
 
       if (dump_enabled_p ())
-       dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: %G", phi);
+       dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: %G",
+                        (gimple *) phi);
 
       /* Skip virtual phi's.  The data dependences that are associated with
          virtual defs/uses (i.e., memory accesses) are analyzed elsewhere.  */
@@ -540,7 +541,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, class loop *loop,
       tree def = PHI_RESULT (phi);
 
       if (dump_enabled_p ())
-       dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: %G", phi);
+       dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: %G",
+                        (gimple *) phi);
 
       gcc_assert (!virtual_operand_p (def)
                  && STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_unknown_def_type);
@@ -1679,7 +1681,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
 
          stmt_info = loop_vinfo->lookup_stmt (phi);
           if (dump_enabled_p ())
-           dump_printf_loc (MSG_NOTE, vect_location, "examining phi: %G", phi);
+           dump_printf_loc (MSG_NOTE, vect_location, "examining phi: %G",
+                            (gimple *) phi);
          if (virtual_operand_p (gimple_phi_result (phi)))
            continue;
 
@@ -2526,7 +2529,7 @@ start_over:
              if (can_use_lanes && dump_enabled_p ())
                dump_printf_loc (MSG_NOTE, vect_location,
                                 "SLP instance %p can use load/store-lanes\n",
-                                instance);
+                                (void *) instance);
            }
          else
            {
@@ -4320,7 +4323,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
       if (dump_enabled_p ())
        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                         "can't unroll as unrolled vectorization factor larger"
-                        " than maximum vectorization factor: %d\n",
+                        " than maximum vectorization factor: "
+                        HOST_WIDE_INT_PRINT_UNSIGNED "\n",
                         LOOP_VINFO_MAX_VECT_FACTOR (loop_vinfo));
       *suggested_unroll_factor = 1;
     }
@@ -8862,7 +8866,7 @@ vectorizable_induction (loop_vec_info loop_vinfo,
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                     "transform induction: created def-use cycle: %G%G",
-                    induction_phi, SSA_NAME_DEF_STMT (vec_def));
+                    (gimple *) induction_phi, SSA_NAME_DEF_STMT (vec_def));
 
   return true;
 }
@@ -9941,7 +9945,7 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call)
          gphi *phi = si.phi ();
          if (dump_enabled_p ())
            dump_printf_loc (MSG_NOTE, vect_location,
-                            "------>vectorizing phi: %G", phi);
+                            "------>vectorizing phi: %G", (gimple *) phi);
          stmt_info = loop_vinfo->lookup_stmt (phi);
          if (!stmt_info)
            continue;
index 09574bb1a2696b3438a4ce9f09f74b42e784aca0..d2bd15b5e9005bce2612f0b32c0acf6ffe776343 100644 (file)
@@ -742,7 +742,8 @@ vect_split_statement (vec_info *vinfo, stmt_vec_info stmt2_info, tree new_rhs,
        {
          dump_printf_loc (MSG_NOTE, vect_location,
                           "into pattern statements: %G", stmt1);
-         dump_printf_loc (MSG_NOTE, vect_location, "and: %G", new_stmt2);
+         dump_printf_loc (MSG_NOTE, vect_location, "and: %G",
+                          (gimple *) new_stmt2);
        }
 
       return true;
@@ -2267,7 +2268,7 @@ vect_recog_mulhs_pattern (vec_info *vinfo,
 
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
-                    "created pattern stmt: %G", mulhrs_stmt);
+                    "created pattern stmt: %G", (gimple *) mulhrs_stmt);
 
   return vect_convert_output (vinfo, last_stmt_info, lhs_type,
                              mulhrs_stmt, new_vectype);
@@ -2473,7 +2474,7 @@ vect_recog_average_pattern (vec_info *vinfo,
 
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
-                    "created pattern stmt: %G", average_stmt);
+                    "created pattern stmt: %G", (gimple *) average_stmt);
 
   return vect_convert_output (vinfo, last_stmt_info,
                              type, average_stmt, new_vectype);
@@ -5269,7 +5270,7 @@ vect_determine_precisions_from_range (stmt_vec_info stmt_info, gassign *stmt)
     dump_printf_loc (MSG_NOTE, vect_location, "can narrow to %s:%d"
                     " without loss of precision: %G",
                     sign == SIGNED ? "signed" : "unsigned",
-                    value_precision, stmt);
+                    value_precision, (gimple *) stmt);
 
   vect_set_operation_type (stmt_info, type, value_precision, sign);
   vect_set_min_input_precision (stmt_info, type, value_precision);
@@ -5350,7 +5351,7 @@ vect_determine_precisions_from_users (stmt_vec_info stmt_info, gassign *stmt)
        dump_printf_loc (MSG_NOTE, vect_location, "can narrow to %s:%d"
                         " without affecting users: %G",
                         TYPE_UNSIGNED (type) ? "unsigned" : "signed",
-                        operation_precision, stmt);
+                        operation_precision, (gimple *) stmt);
       vect_set_operation_type (stmt_info, type, operation_precision,
                               TYPE_SIGN (type));
     }
index e6a6db8bebacc01ff359c401fb4e57837e4e2315..dc694b8e531886bdccf53b39e8981f22a2e9e8c6 100644 (file)
@@ -96,8 +96,8 @@ vect_pattern_validate_optab (internal_fn ifn, slp_tree node)
         {
          if (!vectype)
            dump_printf_loc (MSG_NOTE, vect_location,
-                            "Target does not support vector type for %T\n",
-                            SLP_TREE_DEF_TYPE (node));
+                            "Target does not support vector type for %G\n",
+                            STMT_VINFO_STMT (SLP_TREE_REPRESENTATIVE (node)));
          else
            dump_printf_loc (MSG_NOTE, vect_location,
                             "Target does not support %s for vector type "
index 226550635cc3b31e2066b3f7e887c0843d7db7eb..0d3b273bb422805c1261cac4a60108c0a823c52b 100644 (file)
@@ -1046,7 +1046,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
              if (dump_enabled_p ())
                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                                 "Build SLP failed: unsupported call type %G",
-                                call_stmt);
+                                (gimple *) call_stmt);
              if (is_a <bb_vec_info> (vinfo) && i != 0)
                continue;
              /* Fatal mismatch.  */
@@ -1553,7 +1553,8 @@ vect_build_slp_tree (vec_info *vinfo,
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location, "re-using %sSLP tree %p\n",
-                        !(*leader)->failed ? "" : "failed ", *leader);
+                        !(*leader)->failed ? "" : "failed ",
+                        (void *) *leader);
       if (!(*leader)->failed)
        {
          SLP_TREE_REF_COUNT (*leader)++;
@@ -1590,7 +1591,7 @@ vect_build_slp_tree (vec_info *vinfo,
 
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
-                    "starting SLP discovery for node %p\n", res);
+                    "starting SLP discovery for node %p\n", (void *) res);
 
   poly_uint64 this_max_nunits = 1;
   slp_tree res_ = vect_build_slp_tree_2 (vinfo, res, stmts, group_size,
@@ -1600,7 +1601,7 @@ vect_build_slp_tree (vec_info *vinfo,
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,
-                        "SLP discovery for node %p failed\n", res);
+                        "SLP discovery for node %p failed\n", (void *) res);
       /* Mark the node invalid so we can detect those when still in use
         as backedge destinations.  */
       SLP_TREE_SCALAR_STMTS (res) = vNULL;
@@ -1620,7 +1621,8 @@ vect_build_slp_tree (vec_info *vinfo,
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,
-                        "SLP discovery for node %p succeeded\n", res);
+                        "SLP discovery for node %p succeeded\n",
+                        (void *) res);
       gcc_assert (res_ == res);
       res->max_nunits = this_max_nunits;
       vect_update_max_nunits (max_nunits, this_max_nunits);
@@ -2525,12 +2527,14 @@ vect_print_slp_tree (dump_flags_t dump_kind, dump_location_t loc,
 
   dump_metadata_t metadata (dump_kind, loc.get_impl_location ());
   dump_user_location_t user_loc = loc.get_user_location ();
-  dump_printf_loc (metadata, user_loc, "node%s %p (max_nunits=%u, refcnt=%u)",
+  dump_printf_loc (metadata, user_loc,
+                  "node%s %p (max_nunits=" HOST_WIDE_INT_PRINT_UNSIGNED
+                  ", refcnt=%u)",
                   SLP_TREE_DEF_TYPE (node) == vect_external_def
                   ? " (external)"
                   : (SLP_TREE_DEF_TYPE (node) == vect_constant_def
                      ? " (constant)"
-                     : ""), node,
+                     : ""), (void *) node,
                   estimated_poly_value (node->max_nunits),
                                         SLP_TREE_REF_COUNT (node));
   if (SLP_TREE_VECTYPE (node))
@@ -2893,7 +2897,8 @@ optimize_load_redistribution_1 (scalar_stmts_to_slp_tree_map_t *bst_map,
 
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,
-                        "converting stmts on permute node %p\n", root);
+                        "converting stmts on permute node %p\n",
+                        (void *) root);
 
       bool *matches = XALLOCAVEC (bool, group_size);
       poly_uint64 max_nunits = 1;
@@ -3025,7 +3030,7 @@ vect_match_slp_patterns (slp_instance instance, vec_info *vinfo,
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                     "Analyzing SLP tree %p for patterns\n",
-                    SLP_INSTANCE_TREE (instance));
+                    (void *) SLP_INSTANCE_TREE (instance));
 
   return vect_match_slp_patterns_2 (ref_node, vinfo, perm_cache, compat_cache,
                                    visited);
@@ -3217,7 +3222,8 @@ vect_build_slp_instance (vec_info *vinfo,
          if (dump_enabled_p ())
            {
              dump_printf_loc (MSG_NOTE, vect_location,
-                              "Final SLP tree for instance %p:\n", new_instance);
+                              "Final SLP tree for instance %p:\n",
+                              (void *) new_instance);
              vect_print_slp_graph (MSG_NOTE, vect_location,
                                    SLP_INSTANCE_TREE (new_instance));
            }
@@ -5153,11 +5159,11 @@ vect_optimize_slp_pass::get_result_with_layout (slp_tree node,
            dump_printf_loc (MSG_NOTE, vect_location,
                             "duplicating permutation node %p with"
                             " layout %d\n",
-                            node, to_layout_i);
+                            (void *) node, to_layout_i);
          else
            dump_printf_loc (MSG_NOTE, vect_location,
                             "inserting permutation node in place of %p\n",
-                            node);
+                            (void *) node);
        }
 
       unsigned int num_lanes = SLP_TREE_LANES (node);
@@ -5245,7 +5251,8 @@ vect_optimize_slp_pass::materialize ()
                  && !std::equal (tmp_perm.begin (), tmp_perm.end (),
                                  perm.begin ()))
                dump_printf_loc (MSG_NOTE, vect_location,
-                                "absorbing input layouts into %p\n", node);
+                                "absorbing input layouts into %p\n",
+                                (void *) node);
              std::copy (tmp_perm.begin (), tmp_perm.end (), perm.begin ());
              bitmap_set_bit (fully_folded, node_i);
            }
@@ -5255,7 +5262,7 @@ vect_optimize_slp_pass::materialize ()
              if (dump_enabled_p ())
                dump_printf_loc (MSG_NOTE, vect_location,
                                 "failed to absorb input layouts into %p\n",
-                                node);
+                                (void *) node);
              change_vec_perm_layout (nullptr, perm, layout_i, layout_i);
            }
        }
@@ -5436,13 +5443,15 @@ vect_optimize_slp_pass::dump ()
              if (other_vertex.partition < vertex.partition)
                dump_printf_loc (MSG_NOTE, vect_location,
                                 "      - %p [%d] --> %p\n",
-                                other_vertex.node, other_vertex.partition,
-                                vertex.node);
+                                (void *) other_vertex.node,
+                                other_vertex.partition,
+                                (void *) vertex.node);
              else
                dump_printf_loc (MSG_NOTE, vect_location,
                                 "      - %p --> [%d] %p\n",
-                                vertex.node, other_vertex.partition,
-                                other_vertex.node);
+                                (void *) vertex.node,
+                                other_vertex.partition,
+                                (void *) other_vertex.node);
            };
          for_each_partition_edge (node_i, print_edge);
        }
@@ -5886,7 +5895,8 @@ vect_slp_convert_to_external (vec_info *vinfo, slp_tree node,
 
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
-                    "Building vector operands of %p from scalars instead\n", node);
+                    "Building vector operands of %p from scalars instead\n",
+                    (void *) node);
 
   /* Don't remove and free the child nodes here, since they could be
      referenced by other structures.  The analysis and scheduling phases
@@ -6013,7 +6023,7 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,
-                        "Failed cyclic SLP reference in %p\n", node);
+                        "Failed cyclic SLP reference in %p\n", (void *) node);
       return false;
     }
   gcc_assert (SLP_TREE_DEF_TYPE (node) == vect_internal_def);
@@ -6045,7 +6055,8 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,
-                        "Cannot vectorize all-constant op node %p\n", node);
+                        "Cannot vectorize all-constant op node %p\n",
+                        (void *) node);
       res = false;
     }
 
@@ -6478,7 +6489,7 @@ vect_bb_partition_graph (bb_vec_info bb_vinfo)
          && leader != instance)
        dump_printf_loc (MSG_NOTE, vect_location,
                         "instance %p is leader of %p\n",
-                        leader, instance);
+                        (void *) leader, (void *) instance);
     }
 }
 
index 7748c42c70f2f15898e3c8fedaf6944c99dfb041..c8d1efc45e5176eec988e5886e7e745bd542ca85 100644 (file)
@@ -9042,7 +9042,8 @@ vectorizable_load (vec_info *vinfo,
          gassign *stmt = as_a <gassign *> (stmt_info->stmt);
          if (dump_enabled_p ())
            dump_printf_loc (MSG_NOTE, vect_location,
-                            "hoisting out of the vectorized loop: %G", stmt);
+                            "hoisting out of the vectorized loop: %G",
+                            (gimple *) stmt);
          scalar_dest = copy_ssa_name (scalar_dest);
          tree rhs = unshare_expr (gimple_assign_rhs1 (stmt));
          edge pe = loop_preheader_edge (loop);
This page took 0.108349 seconds and 5 git commands to generate.