From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id E2D64382DB0E; Thu, 1 Sep 2022 09:08:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2D64382DB0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662023298; bh=dysirdk/0STNfzUVb3hy0hCmHcLG9rp5iRQHrrJA3EM=; h=From:To:Subject:Date:From; b=rKW8pxXsPrwmkiuFjPBQcP/sU93YBO2ew62KI7fdJRRN/1acPzLloaK88pk5k0I8R twKiM5WwgbsVHfbokMgdi4npfpOQ2kh0ZJoDZMQ4UnyJcoC07V3qrAxRfWjhiSH+p2 uOmxemZgHAqW1ryuiU4DVWxJJcWLBCobAzhpTiB8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2336] Fix up dump_printf_loc format attribute and adjust uses [PR106782] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 0b8c57ed40f19086e30ce54faec3222ac21cc0df X-Git-Newrev: 953e08fde44a596e4ec2491efd15cd645e1ddc48 Message-Id: <20220901090818.E2D64382DB0E@sourceware.org> Date: Thu, 1 Sep 2022 09:08:18 +0000 (GMT) List-Id: https://gcc.gnu.org/g:953e08fde44a596e4ec2491efd15cd645e1ddc48 commit r13-2336-g953e08fde44a596e4ec2491efd15cd645e1ddc48 Author: Jakub Jelinek Date: Thu Sep 1 11:07:44 2022 +0200 Fix up dump_printf_loc format attribute and adjust uses [PR106782] 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 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). Diff: --- gcc/dumpfile.h | 2 +- gcc/gimple-loop-versioning.cc | 2 +- gcc/tree-parloops.cc | 4 ++-- gcc/tree-vect-loop-manip.cc | 5 ++-- gcc/tree-vect-loop.cc | 20 +++++++++------- gcc/tree-vect-patterns.cc | 11 +++++---- gcc/tree-vect-slp-patterns.cc | 4 ++-- gcc/tree-vect-slp.cc | 55 ++++++++++++++++++++++++++----------------- gcc/tree-vect-stmts.cc | 3 ++- 9 files changed, 62 insertions(+), 44 deletions(-) diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h index 3c47f099a80..b2219c55f15 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -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 &, diff --git a/gcc/gimple-loop-versioning.cc b/gcc/gimple-loop-versioning.cc index 6bcf6eba691..b2e3c4319a1 100644 --- a/gcc/gimple-loop-versioning.cc +++ b/gcc/gimple-loop-versioning.cc @@ -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)); } diff --git a/gcc/tree-parloops.cc b/gcc/tree-parloops.cc index 76483fcaaa2..e4a148b5365 100644 --- a/gcc/tree-parloops.cc +++ b/gcc/tree-parloops.cc @@ -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), diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index 48a5f391d7f..b68e6cd5be4 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -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)) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 2257b29a652..24556b5009a 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -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; diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index 09574bb1a26..d2bd15b5e90 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -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)); } diff --git a/gcc/tree-vect-slp-patterns.cc b/gcc/tree-vect-slp-patterns.cc index e6a6db8beba..dc694b8e531 100644 --- a/gcc/tree-vect-slp-patterns.cc +++ b/gcc/tree-vect-slp-patterns.cc @@ -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 " diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 226550635cc..0d3b273bb42 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -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 (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); } } diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 7748c42c70f..c8d1efc45e5 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -9042,7 +9042,8 @@ vectorizable_load (vec_info *vinfo, gassign *stmt = as_a (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);