From patchwork Wed Jul 14 08:18:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 1505044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GPr5g2Zphz9sXV for ; Wed, 14 Jul 2021 18:19:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5A17F3982411 for ; Wed, 14 Jul 2021 08:19:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from paperclip.tbsaunde.org (tbsaunde.org [66.228.47.254]) by sourceware.org (Postfix) with ESMTP id 579BA397EC2A for ; Wed, 14 Jul 2021 08:18:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 579BA397EC2A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tbsaunde.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tbsaunde.org Received: from caber.home (pool-108-24-42-131.cmdnnj.fios.verizon.net [108.24.42.131]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id E1163C08A; Wed, 14 Jul 2021 08:18:33 +0000 (UTC) From: Trevor Saunders To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/4] force decls to be allocated through build_decl to initialize them Date: Wed, 14 Jul 2021 04:18:24 -0400 Message-Id: <20210714081827.12185-1-tbsaunde@tbsaunde.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Trevor Saunders Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" prior to this commit all calls to build_decl used input_location, even if temporarily until build_decl reset the location to something else that it was told was the proper location. To avoid using the global we need the caller to pass in the location it wants, however that's not possible with make_node since it makes other types of nodes. So we force all callers who wish to make a decl to go through build_decl which already takes a location argument. To avoid changing behavior this just explicitly passes in input_location to build_decl for callers of make_node that create a decl, however it would seem in many of these cases that the location of the decl being coppied might be a better location. bootstrapped and regtested on x86_64-linux-gnu, ok? Trev gcc/ChangeLog: * cfgexpand.c (avoid_deep_ter_for_debug): Call build_decl not make_node. (expand_gimple_basic_block): Likewise. * ipa-param-manipulation.c (ipa_param_adjustments::modify_call): * Likewise. (ipa_param_body_adjustments::reset_debug_stmts): Likewise. * omp-simd-clone.c (ipa_simd_modify_stmt_ops): Likewise. * stor-layout.c (start_bitfield_representative): Likewise. * tree-inline.c (remap_ssa_name): Likewise. (tree_function_versioning): Likewise. * tree-into-ssa.c (rewrite_debug_stmt_uses): Likewise. * tree-nested.c (lookup_field_for_decl): Likewise. (get_chain_field): Likewise. (create_field_for_decl): Likewise. (get_nl_goto_field): Likewise. (finalize_nesting_tree_1): Likewise. * tree-ssa-ccp.c (optimize_atomic_bit_test_and): Likewise. * tree-ssa-loop-ivopts.c (remove_unused_ivs): Likewise. * tree-ssa-phiopt.c (spaceship_replacement): Likewise. * tree-ssa-reassoc.c (make_new_ssa_for_def): Likewise. * tree-ssa.c (insert_debug_temp_for_var_def): Likewise. * tree-streamer-in.c (streamer_alloc_tree): Adjust. * tree.c (make_node): Add argument to specify the caller. (build_decl): Move initialization from make_node. * tree.h (enum make_node_caller): new enum. (make_node): Adjust prototype. * varasm.c (make_debug_expr_from_rtl): call build_decl. gcc/cp/ChangeLog: * constraint.cc (build_type_constraint): Call build_decl not make_node. * cp-gimplify.c (cp_genericize_r): Likewise. * parser.c (cp_parser_introduction_list): Likewise. * module.cc (trees_in::start): Adjust. gcc/fortran/ChangeLog: * trans-decl.c (generate_namelist_decl): Call build_decl not make_node. * trans-types.c (gfc_get_array_descr_info): Likewise. gcc/objc/ChangeLog: * objc-act.c (objc_add_property_declaration): Call build_decl not make_node. (maybe_make_artificial_property_decl): Likewise. (objc_build_keyword_decl): Likewise. (build_method_decl): Likewise. --- gcc/cfgexpand.c | 8 ++++---- gcc/cp/constraint.cc | 2 +- gcc/cp/cp-gimplify.c | 5 +++-- gcc/cp/module.cc | 2 +- gcc/cp/parser.c | 6 ++---- gcc/fortran/trans-decl.c | 5 ++--- gcc/fortran/trans-types.c | 4 ++-- gcc/ipa-param-manipulation.c | 8 ++++---- gcc/objc/objc-act.c | 16 ++++++---------- gcc/omp-simd-clone.c | 4 ++-- gcc/stor-layout.c | 2 +- gcc/tree-inline.c | 13 +++++++------ gcc/tree-into-ssa.c | 4 ++-- gcc/tree-nested.c | 24 ++++++++++-------------- gcc/tree-ssa-ccp.c | 4 ++-- gcc/tree-ssa-loop-ivopts.c | 4 ++-- gcc/tree-ssa-phiopt.c | 8 ++++---- gcc/tree-ssa-reassoc.c | 4 ++-- gcc/tree-ssa.c | 4 ++-- gcc/tree-streamer-in.c | 2 +- gcc/tree.c | 35 ++++++++++++++++++----------------- gcc/tree.h | 13 ++++++++++++- gcc/varasm.c | 12 ++++++------ 23 files changed, 96 insertions(+), 93 deletions(-) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 3edd53c37dc..fea8c837c80 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -4342,10 +4342,10 @@ avoid_deep_ter_for_debug (gimple *stmt, int depth) tree &vexpr = deep_ter_debug_map->get_or_insert (use); if (vexpr != NULL) continue; - vexpr = make_node (DEBUG_EXPR_DECL); + vexpr = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + TREE_TYPE (use)); gimple *def_temp = gimple_build_debug_bind (vexpr, use, g); DECL_ARTIFICIAL (vexpr) = 1; - TREE_TYPE (vexpr) = TREE_TYPE (use); SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (use))); gimple_stmt_iterator gsi = gsi_for_stmt (g); gsi_insert_after (&gsi, def_temp, GSI_NEW_STMT); @@ -5899,14 +5899,14 @@ 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); rtx val; machine_mode mode; set_curr_insn_location (gimple_location (def)); + tree vexpr = build_decl (input_location, DEBUG_EXPR_DECL, + nullptr, TREE_TYPE (value)); DECL_ARTIFICIAL (vexpr) = 1; - TREE_TYPE (vexpr) = TREE_TYPE (value); if (DECL_P (value)) mode = DECL_MODE (value); else diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 4ee5215df50..ae75e5df32b 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -1464,7 +1464,7 @@ build_concept_id (tree expr) tree build_type_constraint (tree decl, tree args, tsubst_flags_t complain) { - tree wildcard = build_nt (WILDCARD_DECL); + tree wildcard = build_decl (input_location, WILDCARD_DECL, nullptr, nullptr); ++processing_template_decl; tree check = build_concept_check (decl, wildcard, args, complain); --processing_template_decl; diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 00b7772fe0d..d537e547169 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1217,8 +1217,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) /* Omit from the GENERIC, the back-end can't handle it. */; else { - tree using_directive = make_node (IMPORTED_DECL); - TREE_TYPE (using_directive) = void_type_node; + tree using_directive = build_decl (input_location, + IMPORTED_DECL, nullptr, + void_type_node); DECL_CONTEXT (using_directive) = current_function_decl; IMPORTED_DECL_ASSOCIATED_DECL (using_directive) = decl; diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index ccbde292c22..5c9461ff66b 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -5103,7 +5103,7 @@ trees_in::start (unsigned code) t = build_vl_exp (tree_code (code), ops); } else - t = make_node (tree_code (code)); + t = make_node (tree_code (code), MODULE_STREAMER_MKNODE_CALLER); break; case INTEGER_CST: diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 93698aa14c9..ea7cdb06789 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -17056,10 +17056,8 @@ cp_parser_introduction_list (cp_parser *parser) break; /* Build placeholder. */ - tree parm = build_nt (WILDCARD_DECL); - DECL_SOURCE_LOCATION (parm) - = cp_lexer_peek_token (parser->lexer)->location; - DECL_NAME (parm) = identifier; + tree parm = build_decl (cp_lexer_peek_token (parser->lexer)->location, + WILDCARD_DECL, identifier, nullptr); WILDCARD_PACK_P (parm) = is_pack; vec_safe_push (introduction_vec, parm); diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index a73ce8a3f40..1ec8760037b 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -5262,10 +5262,9 @@ generate_namelist_decl (gfc_symbol * sym) CONSTRUCTOR_APPEND_ELT (nml_decls, NULL_TREE, nml->sym->backend_decl); } - decl = make_node (NAMELIST_DECL); - TREE_TYPE (decl) = void_type_node; + decl = build_decl (input_location, NAMELIST_DECL, get_identifier (sym->name), + void_type_node); NAMELIST_DECL_ASSOCIATED_DECL (decl) = build_constructor (NULL_TREE, nml_decls); - DECL_NAME (decl) = get_identifier (sym->name); return decl; } diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index d715838a046..9ca288df962 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -3417,9 +3417,9 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info) base_decl = GFC_TYPE_ARRAY_BASE_DECL (type, indirect); if (!base_decl) { - base_decl = make_node (DEBUG_EXPR_DECL); + base_decl = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + indirect ? build_pointer_type (ptype) : ptype); DECL_ARTIFICIAL (base_decl) = 1; - TREE_TYPE (base_decl) = indirect ? build_pointer_type (ptype) : ptype; SET_DECL_MODE (base_decl, TYPE_MODE (TREE_TYPE (base_decl))); GFC_TYPE_ARRAY_BASE_DECL (type, indirect) = base_decl; } diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c index 26b02d7aa95..ac72b7e4de8 100644 --- a/gcc/ipa-param-manipulation.c +++ b/gcc/ipa-param-manipulation.c @@ -829,9 +829,9 @@ ipa_param_adjustments::modify_call (cgraph_edge *cs, } if (ddecl == NULL) { - ddecl = make_node (DEBUG_EXPR_DECL); + ddecl = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + TREE_TYPE (origin)); DECL_ARTIFICIAL (ddecl) = 1; - TREE_TYPE (ddecl) = TREE_TYPE (origin); SET_DECL_MODE (ddecl, DECL_MODE (origin)); vec_safe_push (*debug_args, origin); @@ -2055,10 +2055,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); + vexpr = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + TREE_TYPE (name)); def_temp = gimple_build_debug_source_bind (vexpr, decl, NULL); DECL_ARTIFICIAL (vexpr) = 1; - TREE_TYPE (vexpr) = TREE_TYPE (name); SET_DECL_MODE (vexpr, DECL_MODE (decl)); gsi_insert_before (gsip, def_temp, GSI_SAME_STMT); } diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index ec20891152b..9fdfe89ed4d 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -1295,12 +1295,11 @@ objc_add_property_declaration (location_t location, tree decl, } /* Create a PROPERTY_DECL node. */ - tree property_decl = make_node (PROPERTY_DECL); + tree property_decl = build_decl (DECL_SOURCE_LOCATION (decl), PROPERTY_DECL, + nullptr, TREE_TYPE (decl)); /* Copy the basic information from the original decl. */ tree p_type = TREE_TYPE (decl); - TREE_TYPE (property_decl) = p_type; - DECL_SOURCE_LOCATION (property_decl) = DECL_SOURCE_LOCATION (decl); TREE_DEPRECATED (property_decl) = TREE_DEPRECATED (decl); /* Add property-specific information. */ @@ -1434,10 +1433,9 @@ maybe_make_artificial_property_decl (tree interface, tree implementation, /* Create an artificial property declaration with the information we collected on the type and getter/setter names. */ - property_decl = make_node (PROPERTY_DECL); + property_decl = build_decl (input_location, PROPERTY_DECL, nullptr, + type); - TREE_TYPE (property_decl) = type; - DECL_SOURCE_LOCATION (property_decl) = input_location; TREE_DEPRECATED (property_decl) = 0; DECL_ARTIFICIAL (property_decl) = 1; @@ -4890,9 +4888,8 @@ objc_build_keyword_decl (tree key_name, tree arg_type, /* If no type is specified, default to "id". */ arg_type = adjust_type_for_id_default (arg_type); - keyword_decl = make_node (KEYWORD_DECL); + keyword_decl = build_decl (input_location, KEYWORD_DECL, nullptr, arg_type); - TREE_TYPE (keyword_decl) = arg_type; KEYWORD_ARG_NAME (keyword_decl) = arg_name; KEYWORD_KEY_NAME (keyword_decl) = key_name; DECL_ATTRIBUTES (keyword_decl) = attributes; @@ -4976,8 +4973,7 @@ build_method_decl (enum tree_code code, tree ret_type, tree selector, type of the method. We may want to change this, and store the entire function type in there (eg, it may be used to simplify dealing with attributes below). */ - method_decl = make_node (code); - TREE_TYPE (method_decl) = ret_type; + method_decl = build_decl (input_location, code, nullptr, ret_type); /* If we have a keyword selector, create an identifier_node that represents the full selector name (`:' included)... */ diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c index b772b7ff520..03189f4c50f 100644 --- a/gcc/omp-simd-clone.c +++ b/gcc/omp-simd-clone.c @@ -910,10 +910,10 @@ ipa_simd_modify_stmt_ops (tree *tp, int *walk_subtrees, void *data) gimple *stmt; if (is_gimple_debug (info->stmt)) { - tree vexpr = make_node (DEBUG_EXPR_DECL); + tree vexpr = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + TREE_TYPE (repl)); stmt = gimple_build_debug_source_bind (vexpr, repl, NULL); DECL_ARTIFICIAL (vexpr) = 1; - TREE_TYPE (vexpr) = TREE_TYPE (repl); SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (repl))); repl = vexpr; } diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 242452f2acf..7811fc6c302 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2024,7 +2024,7 @@ finalize_type_size (tree type) static tree start_bitfield_representative (tree field) { - tree repr = make_node (FIELD_DECL); + tree repr = build_decl (input_location, FIELD_DECL, nullptr, nullptr); DECL_FIELD_OFFSET (repr) = DECL_FIELD_OFFSET (field); /* Force the representative to begin at a BITS_PER_UNIT aligned boundary - C++ may use tail-padding of a base object to diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index f605e763f4a..8d104408156 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -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,9 +209,11 @@ 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; + + tree vexpr = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + TREE_TYPE (name)); def_temp = gimple_build_debug_source_bind (vexpr, val, NULL); DECL_ARTIFICIAL (vexpr) = 1; - TREE_TYPE (vexpr) = TREE_TYPE (name); SET_DECL_MODE (vexpr, DECL_MODE (SSA_NAME_VAR (name))); gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun))); gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT); @@ -6411,9 +6412,9 @@ 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); + ddecl = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + TREE_TYPE (parm)); DECL_ARTIFICIAL (ddecl) = 1; - TREE_TYPE (ddecl) = TREE_TYPE (parm); SET_DECL_MODE (ddecl, DECL_MODE (parm)); vec_safe_push (*debug_args, DECL_ORIGIN (parm)); vec_safe_push (*debug_args, ddecl); @@ -6442,10 +6443,10 @@ tree_function_versioning (tree old_decl, tree new_decl, var = TREE_CHAIN (var); if (var == NULL_TREE) break; - vexpr = make_node (DEBUG_EXPR_DECL); tree parm = (**debug_args)[i]; + vexpr = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + TREE_TYPE (parm)); DECL_ARTIFICIAL (vexpr) = 1; - TREE_TYPE (vexpr) = TREE_TYPE (parm); SET_DECL_MODE (vexpr, DECL_MODE (parm)); def_temp = gimple_build_debug_bind (var, vexpr, NULL); gsi_insert_before (&cgsi, def_temp, GSI_NEW_STMT); diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 8045e34df26..f9933305957 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -1284,10 +1284,10 @@ rewrite_debug_stmt_uses (gimple *stmt) if (def == NULL_TREE) { gimple *def_temp; - def = make_node (DEBUG_EXPR_DECL); + def = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + TREE_TYPE (var)); def_temp = gimple_build_debug_source_bind (def, var, NULL); DECL_ARTIFICIAL (def) = 1; - TREE_TYPE (def) = TREE_TYPE (var); SET_DECL_MODE (def, DECL_MODE (var)); gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun))); diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 9edd922a303..37e229477ec 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -394,8 +394,8 @@ lookup_field_for_decl (struct nesting_info *info, tree decl, if (!*slot) { tree type = get_frame_type (info); - tree field = make_node (FIELD_DECL); - DECL_NAME (field) = DECL_NAME (decl); + tree field = build_decl (input_location, FIELD_DECL, DECL_NAME (decl), + nullptr); if (use_pointer_in_frame (decl)) { @@ -510,9 +510,8 @@ get_chain_field (struct nesting_info *info) { tree type = build_pointer_type (get_frame_type (info->outer)); - field = make_node (FIELD_DECL); - DECL_NAME (field) = get_identifier ("__chain"); - TREE_TYPE (field) = type; + field = build_decl (input_location, FIELD_DECL, + get_identifier ("__chain"), type); SET_DECL_ALIGN (field, TYPE_ALIGN (type)); DECL_NONADDRESSABLE_P (field) = 1; @@ -694,9 +693,7 @@ lookup_element_for_decl (struct nesting_info *info, tree decl, static tree create_field_for_decl (struct nesting_info *info, tree decl, tree type) { - tree field = make_node (FIELD_DECL); - DECL_NAME (field) = DECL_NAME (decl); - TREE_TYPE (field) = type; + tree field = build_decl (input_location, FIELD_DECL, DECL_NAME (decl), type); TREE_ADDRESSABLE (field) = 1; insert_field_into_struct (get_frame_type (info), field); return field; @@ -783,9 +780,8 @@ get_nl_goto_field (struct nesting_info *info) type = build_array_type (type, build_index_type (size_int (size))); - field = make_node (FIELD_DECL); - DECL_NAME (field) = get_identifier ("__nl_goto_buf"); - TREE_TYPE (field) = type; + field = build_decl (input_location, FIELD_DECL, + get_identifier ("__nl_goto_buf"), type); SET_DECL_ALIGN (field, TYPE_ALIGN (type)); TREE_ADDRESSABLE (field) = 1; @@ -3378,10 +3374,10 @@ finalize_nesting_tree_1 (struct nesting_info *root) /* Create a field in the FRAME record to hold the frame base address for this stack frame. Since it will be used only by the debugger, put it at the end of the record in order not to shift all other offsets. */ - tree fb_decl = make_node (FIELD_DECL); + tree fb_decl = build_decl (input_location, FIELD_DECL, + get_identifier ("FRAME_BASE.PARENT"), + ptr_type_node); - DECL_NAME (fb_decl) = get_identifier ("FRAME_BASE.PARENT"); - TREE_TYPE (fb_decl) = ptr_type_node; TREE_ADDRESSABLE (fb_decl) = 1; DECL_CONTEXT (fb_decl) = root->frame_type; TYPE_FIELDS (root->frame_type) = chainon (TYPE_FIELDS (root->frame_type), diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 9ce6214d7e2..533ed1cfd15 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -3067,9 +3067,9 @@ optimize_atomic_bit_test_and (gimple_stmt_iterator *gsip, tree temp = NULL_TREE; if (!throws || after || single_pred_p (e->dest)) { - temp = make_node (DEBUG_EXPR_DECL); + temp = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + TREE_TYPE (lhs)); DECL_ARTIFICIAL (temp) = 1; - TREE_TYPE (temp) = TREE_TYPE (lhs); SET_DECL_MODE (temp, TYPE_MODE (TREE_TYPE (lhs))); tree t = build2 (LSHIFT_EXPR, TREE_TYPE (lhs), new_lhs, bit); g = gimple_build_debug_bind (temp, t, g); diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 12a8a49a307..953b3d0b2f1 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -7677,9 +7677,9 @@ remove_unused_ivs (struct ivopts_data *data, bitmap toremove) comp = unshare_expr (comp); if (count > 1) { - tree vexpr = make_node (DEBUG_EXPR_DECL); + tree vexpr = build_decl (input_location, DEBUG_EXPR_DECL, + nullptr, TREE_TYPE (comp)); DECL_ARTIFICIAL (vexpr) = 1; - TREE_TYPE (vexpr) = TREE_TYPE (comp); if (SSA_NAME_VAR (def)) SET_DECL_MODE (vexpr, DECL_MODE (SSA_NAME_VAR (def))); else diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index c6adbbd28a0..025977eeff8 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -2430,18 +2430,18 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb, all floating point numbers should be comparable. */ gimple_stmt_iterator gsi = gsi_after_labels (gimple_bb (phi)); tree type = TREE_TYPE (phires); - tree temp1 = make_node (DEBUG_EXPR_DECL); + tree temp1 = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + type); DECL_ARTIFICIAL (temp1) = 1; - TREE_TYPE (temp1) = type; SET_DECL_MODE (temp1, TYPE_MODE (type)); tree t = build2 (one_cmp, boolean_type_node, lhs1, rhs2); t = build3 (COND_EXPR, type, t, build_one_cst (type), build_int_cst (type, -1)); gimple *g = gimple_build_debug_bind (temp1, t, phi); gsi_insert_before (&gsi, g, GSI_SAME_STMT); - tree temp2 = make_node (DEBUG_EXPR_DECL); + tree temp2 = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, + type); DECL_ARTIFICIAL (temp2) = 1; - TREE_TYPE (temp2) = type; SET_DECL_MODE (temp2, TYPE_MODE (type)); t = build2 (EQ_EXPR, boolean_type_node, lhs1, rhs2); t = build3 (COND_EXPR, type, t, build_zero_cst (type), temp1); diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 2dd4435b981..48f6117a731 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -1214,14 +1214,14 @@ make_new_ssa_for_def (gimple *stmt, enum tree_code opcode, tree op) { if (new_debug_lhs == NULL_TREE) { - new_debug_lhs = make_node (DEBUG_EXPR_DECL); + new_debug_lhs = build_decl (input_location, DEBUG_EXPR_DECL, + nullptr, TREE_TYPE (lhs)); gdebug *def_temp = gimple_build_debug_bind (new_debug_lhs, build2 (opcode, TREE_TYPE (lhs), new_lhs, op), stmt); DECL_ARTIFICIAL (new_debug_lhs) = 1; - TREE_TYPE (new_debug_lhs) = TREE_TYPE (lhs); SET_DECL_MODE (new_debug_lhs, TYPE_MODE (TREE_TYPE (lhs))); gimple_set_uid (def_temp, gimple_uid (stmt)); gimple_stmt_iterator gsi = gsi_for_stmt (stmt); diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 4cc400d3c2e..83caadb37c8 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -434,14 +434,14 @@ 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_decl (input_location, DEBUG_EXPR_DECL, nullptr, + 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); if (DECL_P (value)) SET_DECL_MODE (vexpr, DECL_MODE (value)); else diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c index e0522bf2ac1..fe95692acc9 100644 --- a/gcc/tree-streamer-in.c +++ b/gcc/tree-streamer-in.c @@ -634,7 +634,7 @@ streamer_alloc_tree (class lto_input_block *ib, class data_in *data_in, { /* For all other nodes, materialize the tree with a raw make_node call. */ - result = make_node (code); + result = make_node (code, TREE_STREAMER_MKNODE_CALLER); } return result; diff --git a/gcc/tree.c b/gcc/tree.c index 1aa6e557a04..9c5236a280d 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1175,7 +1175,7 @@ allocate_decl_uid (void) Achoo! I got a code in the node. */ tree -make_node (enum tree_code code MEM_STAT_DECL) +make_node (enum tree_code code, make_node_caller caller MEM_STAT_DECL) { tree t; enum tree_code_class type = TREE_CODE_CLASS (code); @@ -1194,17 +1194,9 @@ make_node (enum tree_code code MEM_STAT_DECL) break; case tcc_declaration: - if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) - { - if (code == FUNCTION_DECL) - { - SET_DECL_ALIGN (t, FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY)); - SET_DECL_MODE (t, FUNCTION_MODE); - } - else - SET_DECL_ALIGN (t, 1); - } - DECL_SOURCE_LOCATION (t) = input_location; + gcc_checking_assert (caller == BUILD_DECL_MKNODE_CALLER + || caller == TREE_STREAMER_MKNODE_CALLER + || caller == MODULE_STREAMER_MKNODE_CALLER); if (TREE_CODE (t) == DEBUG_EXPR_DECL) DECL_UID (t) = --next_debug_decl_uid; else @@ -1212,9 +1204,6 @@ make_node (enum tree_code code MEM_STAT_DECL) DECL_UID (t) = allocate_decl_uid (); SET_DECL_PT_UID (t, -1); } - if (TREE_CODE (t) == LABEL_DECL) - LABEL_DECL_UID (t) = -1; - break; case tcc_type: @@ -5257,10 +5246,22 @@ tree build_decl (location_t loc, enum tree_code code, tree name, tree type MEM_STAT_DECL) { - tree t; + gcc_checking_assert (TREE_CODE_CLASS (code) == tcc_declaration); + tree t = make_node (code, BUILD_DECL_MKNODE_CALLER PASS_MEM_STAT); + if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) + { + if (code == FUNCTION_DECL) + { + SET_DECL_ALIGN (t, FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY)); + SET_DECL_MODE (t, FUNCTION_MODE); + } + else + SET_DECL_ALIGN (t, 1); + } - t = make_node (code PASS_MEM_STAT); DECL_SOURCE_LOCATION (t) = loc; + if (TREE_CODE (t) == LABEL_DECL) + LABEL_DECL_UID (t) = -1; /* if (type == error_mark_node) type = integer_type_node; */ diff --git a/gcc/tree.h b/gcc/tree.h index 8bdf16d8b4a..c68997408e2 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4357,11 +4357,22 @@ extern size_t tree_code_size (enum tree_code); /* Allocate and return a new UID from the DECL_UID namespace. */ extern int allocate_decl_uid (void); +/* expected callers of make_node. */ +enum make_node_caller +{ + UNKNOWN_MKNODE_CALLER, + BUILD_DECL_MKNODE_CALLER, + TREE_STREAMER_MKNODE_CALLER, + MODULE_STREAMER_MKNODE_CALLER, +}; + /* Lowest level primitive for allocating a node. The TREE_CODE is the only argument. Contents are initialized to zero except for a few of the common fields. */ -extern tree make_node (enum tree_code CXX_MEM_STAT_INFO); +extern tree make_node (enum tree_code, + enum make_node_caller caller = UNKNOWN_MKNODE_CALLER + CXX_MEM_STAT_INFO); /* Free tree node. */ diff --git a/gcc/varasm.c b/gcc/varasm.c index 53cf6dea3f3..fa6799e48fb 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -8229,21 +8229,21 @@ output_file_directive (FILE *asm_file, const char *input_name) rtx make_debug_expr_from_rtl (const_rtx exp) { - tree ddecl = make_node (DEBUG_EXPR_DECL), type; + tree type; machine_mode mode = GET_MODE (exp); rtx dval; - DECL_ARTIFICIAL (ddecl) = 1; if (REG_P (exp) && REG_EXPR (exp)) type = TREE_TYPE (REG_EXPR (exp)); else if (MEM_P (exp) && MEM_EXPR (exp)) type = TREE_TYPE (MEM_EXPR (exp)); else type = NULL_TREE; - if (type && TYPE_MODE (type) == mode) - TREE_TYPE (ddecl) = type; - else - TREE_TYPE (ddecl) = lang_hooks.types.type_for_mode (mode, 1); + if (!type || TYPE_MODE (type) != mode) + type = lang_hooks.types.type_for_mode (mode, 1); + + tree ddecl = build_decl (input_location, DEBUG_EXPR_DECL, nullptr, type); + DECL_ARTIFICIAL (ddecl) = 1; SET_DECL_MODE (ddecl, mode); dval = gen_rtx_DEBUG_EXPR (mode); DEBUG_EXPR_TREE_DECL (dval) = ddecl; From patchwork Wed Jul 14 08:18:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 1505045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GPr6S0rzfz9sXV for ; Wed, 14 Jul 2021 18:20:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E814B3982439 for ; Wed, 14 Jul 2021 08:20:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from paperclip.tbsaunde.org (unknown [IPv6:2600:3c03::f03c:91ff:fe6e:c625]) by sourceware.org (Postfix) with ESMTP id 9D69E3973122 for ; Wed, 14 Jul 2021 08:18:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9D69E3973122 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tbsaunde.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tbsaunde.org Received: from caber.home (pool-108-24-42-131.cmdnnj.fios.verizon.net [108.24.42.131]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id DDBDBC08A; Wed, 14 Jul 2021 08:18:41 +0000 (UTC) From: Trevor Saunders To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/4] use error_at and warning_at in cfgexpand.c Date: Wed, 14 Jul 2021 04:18:25 -0400 Message-Id: <20210714081827.12185-2-tbsaunde@tbsaunde.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210714081827.12185-1-tbsaunde@tbsaunde.org> References: <20210714081827.12185-1-tbsaunde@tbsaunde.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_ABUSEAT, RCVD_IN_XBL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Trevor Saunders Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" bootstrapped and regtested on x86_64-linux-gnu, ok? Trev gcc/ChangeLog: * cfgexpand.c (tree_conflicts_with_clobbers_p): Pass location to diagnostics. (expand_asm_stmt): Likewise. --- gcc/cfgexpand.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index fea8c837c80..46f2960c491 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2954,7 +2954,8 @@ check_operand_nalternatives (const vec &constraints) variable definition for error, NULL_TREE for ok. */ static bool -tree_conflicts_with_clobbers_p (tree t, HARD_REG_SET *clobbered_regs) +tree_conflicts_with_clobbers_p (tree t, HARD_REG_SET *clobbered_regs, + location_t loc) { /* Conflicts between asm-declared register variables and the clobber list are not allowed. */ @@ -2962,9 +2963,8 @@ tree_conflicts_with_clobbers_p (tree t, HARD_REG_SET *clobbered_regs) if (overlap) { - error ("% specifier for variable %qE conflicts with " - "% clobber list", - DECL_NAME (overlap)); + error_at (loc, "% specifier for variable %qE conflicts with " + "% clobber list", DECL_NAME (overlap)); /* Reset registerness to stop multiple errors emitted for a single variable. */ @@ -3087,7 +3087,7 @@ expand_asm_stmt (gasm *stmt) /* ??? Diagnose during gimplification? */ if (ninputs + noutputs + nlabels > MAX_RECOG_OPERANDS) { - error ("more than %d operands in %", MAX_RECOG_OPERANDS); + error_at (locus, "more than %d operands in %", MAX_RECOG_OPERANDS); return; } @@ -3140,7 +3140,8 @@ expand_asm_stmt (gasm *stmt) if (j == -2) { /* ??? Diagnose during gimplification? */ - error ("unknown register name %qs in %", regname); + error_at (locus, "unknown register name %qs in %", + regname); error_seen = true; } else if (j == -4) @@ -3205,7 +3206,8 @@ expand_asm_stmt (gasm *stmt) && HARD_REGISTER_P (DECL_RTL (output_tvec[j])) && output_hregno == REGNO (DECL_RTL (output_tvec[j]))) { - error ("invalid hard register usage between output operands"); + error_at (locus, "invalid hard register usage between output " + "operands"); error_seen = true; } @@ -3231,16 +3233,16 @@ expand_asm_stmt (gasm *stmt) if (i == match && output_hregno != input_hregno) { - error ("invalid hard register usage between output " - "operand and matching constraint operand"); + error_at (locus, "invalid hard register usage between " + "output operand and matching constraint operand"); error_seen = true; } else if (early_clobber_p && i != match && output_hregno == input_hregno) { - error ("invalid hard register usage between " - "earlyclobber operand and input operand"); + error_at (locus, "invalid hard register usage between " + "earlyclobber operand and input operand"); error_seen = true; } } @@ -3319,7 +3321,7 @@ expand_asm_stmt (gasm *stmt) if (! allows_reg && !MEM_P (op)) { - error ("output number %d not directly addressable", i); + error_at (locus, "output number %d not directly addressable", i); error_seen = true; } if ((! allows_mem && MEM_P (op) && GET_MODE (op) != BLKmode) @@ -3415,9 +3417,8 @@ expand_asm_stmt (gasm *stmt) if (allows_reg && TYPE_MODE (type) != BLKmode) op = force_reg (TYPE_MODE (type), op); else if (!allows_mem) - warning (0, "% operand %d probably does not match " - "constraints", - i + noutputs); + warning_at (locus, 0, "% operand %d probably does not match " + "constraints", i + noutputs); else if (MEM_P (op)) { /* We won't recognize either volatile memory or memory @@ -3471,10 +3472,10 @@ expand_asm_stmt (gasm *stmt) bool clobber_conflict_found = 0; for (i = 0; i < noutputs; ++i) - if (tree_conflicts_with_clobbers_p (output_tvec[i], &clobbered_regs)) + if (tree_conflicts_with_clobbers_p (output_tvec[i], &clobbered_regs, locus)) clobber_conflict_found = 1; for (i = 0; i < ninputs - ninout; ++i) - if (tree_conflicts_with_clobbers_p (input_tvec[i], &clobbered_regs)) + if (tree_conflicts_with_clobbers_p (input_tvec[i], &clobbered_regs, locus)) clobber_conflict_found = 1; /* Make vectors for the expression-rtx, constraint strings, From patchwork Wed Jul 14 08:18:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 1505046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GPr7M3vW7z9sXV for ; Wed, 14 Jul 2021 18:21:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 125563973122 for ; Wed, 14 Jul 2021 08:21:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from paperclip.tbsaunde.org (tbsaunde.org [66.228.47.254]) by sourceware.org (Postfix) with ESMTP id 820D7397EC05 for ; Wed, 14 Jul 2021 08:18:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 820D7397EC05 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tbsaunde.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tbsaunde.org Received: from caber.home (pool-108-24-42-131.cmdnnj.fios.verizon.net [108.24.42.131]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id 5ECDCC0E3; Wed, 14 Jul 2021 08:18:43 +0000 (UTC) From: Trevor Saunders To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/4] use diagnostic location in diagnostic_report_current_function Date: Wed, 14 Jul 2021 04:18:26 -0400 Message-Id: <20210714081827.12185-3-tbsaunde@tbsaunde.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210714081827.12185-1-tbsaunde@tbsaunde.org> References: <20210714081827.12185-1-tbsaunde@tbsaunde.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Trevor Saunders Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" It appears that input_location was used here before the diagnostic's location was available, and never updated, when the other part of the header was added that uses it, so this makes it consistent. bootstrapped and regtested on x86_64-linux-gnu, ok? Trev gcc/ChangeLog: * tree-diagnostic.c (diagnostic_report_current_function): Use the diagnostic's location, not input_location. --- gcc/tree-diagnostic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c index 8bb214b2cf5..705da94637d 100644 --- a/gcc/tree-diagnostic.c +++ b/gcc/tree-diagnostic.c @@ -36,9 +36,9 @@ void diagnostic_report_current_function (diagnostic_context *context, diagnostic_info *diagnostic) { - diagnostic_report_current_module (context, diagnostic_location (diagnostic)); - lang_hooks.print_error_function (context, LOCATION_FILE (input_location), - diagnostic); + location_t loc = diagnostic_location (diagnostic); + diagnostic_report_current_module (context, loc); + lang_hooks.print_error_function (context, LOCATION_FILE (loc), diagnostic); } static void From patchwork Wed Jul 14 08:18:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 1505047 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GPr7j6Hlmz9sXb for ; Wed, 14 Jul 2021 18:21:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A26C5398241B for ; Wed, 14 Jul 2021 08:21:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from paperclip.tbsaunde.org (tbsaunde.org [66.228.47.254]) by sourceware.org (Postfix) with ESMTP id 854EE397EC27 for ; Wed, 14 Jul 2021 08:18:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 854EE397EC27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tbsaunde.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tbsaunde.org Received: from caber.home (pool-108-24-42-131.cmdnnj.fios.verizon.net [108.24.42.131]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id 5AD34C08A; Wed, 14 Jul 2021 08:18:44 +0000 (UTC) From: Trevor Saunders To: gcc-patches@gcc.gnu.org Subject: [PATCH 4/4] pass location to md_asm_adjust Date: Wed, 14 Jul 2021 04:18:27 -0400 Message-Id: <20210714081827.12185-4-tbsaunde@tbsaunde.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210714081827.12185-1-tbsaunde@tbsaunde.org> References: <20210714081827.12185-1-tbsaunde@tbsaunde.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Trevor Saunders Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" So the hook can use it as the location of diagnostics. bootstrapped and regtested on x86_64-linux-gnu, also tested one make all-gcc for each effected cpu, ok? Trev gcc/ChangeLog: * cfgexpand.c (expand_asm_loc): Adjust. (expand_asm_stmt): Likewise. * config/arm/aarch-common-protos.h (arm_md_asm_adjust): Likewise. * config/arm/aarch-common.c (arm_md_asm_adjust): Likewise. * config/arm/arm.c (thumb1_md_asm_adjust): Likewise. * config/avr/avr.c (avr_md_asm_adjust): Likewise. * config/cris/cris.c (cris_md_asm_adjust): Likewise. * config/i386/i386.c (ix86_md_asm_adjust): Likewise. * config/mn10300/mn10300.c (mn10300_md_asm_adjust): Likewise. * config/nds32/nds32.c (nds32_md_asm_adjust): Likewise. * config/pdp11/pdp11.c (pdp11_md_asm_adjust): Likewise. * config/rs6000/rs6000.c (rs6000_md_asm_adjust): Likewise. * config/s390/s390.c (s390_md_asm_adjust): Likewise. * config/vax/vax.c (vax_md_asm_adjust): Likewise. * config/visium/visium.c (visium_md_asm_adjust): Likewise. * doc/tm.texi: Regenerate. * target.def: Add location argument to md_asm_adjust. --- gcc/cfgexpand.c | 9 +++++---- gcc/config/arm/aarch-common-protos.h | 3 ++- gcc/config/arm/aarch-common.c | 8 ++++---- gcc/config/arm/arm.c | 4 ++-- gcc/config/avr/avr.c | 3 ++- gcc/config/cris/cris.c | 4 ++-- gcc/config/i386/i386.c | 8 ++++---- gcc/config/mn10300/mn10300.c | 2 +- gcc/config/nds32/nds32.c | 3 ++- gcc/config/pdp11/pdp11.c | 4 ++-- gcc/config/rs6000/rs6000.c | 2 +- gcc/config/s390/s390.c | 2 +- gcc/config/vax/vax.c | 5 +++-- gcc/config/visium/visium.c | 4 ++-- gcc/doc/tm.texi | 5 +++-- gcc/target.def | 5 +++-- 16 files changed, 39 insertions(+), 32 deletions(-) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 46f2960c491..88fd7014941 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2897,7 +2897,8 @@ expand_asm_loc (tree string, int vol, location_t locus) if (targetm.md_asm_adjust) targetm.md_asm_adjust (output_rvec, input_rvec, input_mode, - constraints, clobber_rvec, clobbered_regs); + constraints, clobber_rvec, clobbered_regs, + locus); asm_op = body; nclobbers = clobber_rvec.length (); @@ -3074,8 +3075,7 @@ expand_asm_stmt (gasm *stmt) return; } - /* There are some legacy diagnostics in here, and also avoids an extra - parameter to targetm.md_asm_adjust. */ + /* There are some legacy diagnostics in here. */ save_input_location s_i_l(locus); unsigned noutputs = gimple_asm_noutputs (stmt); @@ -3456,7 +3456,8 @@ expand_asm_stmt (gasm *stmt) if (targetm.md_asm_adjust) after_md_seq = targetm.md_asm_adjust (output_rvec, input_rvec, input_mode, - constraints, clobber_rvec, clobbered_regs); + constraints, clobber_rvec, clobbered_regs, + locus); /* Do not allow the hook to change the output and input count, lest it mess up the operand numbering. */ diff --git a/gcc/config/arm/aarch-common-protos.h b/gcc/config/arm/aarch-common-protos.h index b6171e8668d..6be5fb1e083 100644 --- a/gcc/config/arm/aarch-common-protos.h +++ b/gcc/config/arm/aarch-common-protos.h @@ -147,6 +147,7 @@ struct cpu_cost_table rtx_insn *arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, vec & /*input_modes*/, vec &constraints, - vec &clobbers, HARD_REG_SET &clobbered_regs); + vec &clobbers, HARD_REG_SET &clobbered_regs, + location_t loc); #endif /* GCC_AARCH_COMMON_PROTOS_H */ diff --git a/gcc/config/arm/aarch-common.c b/gcc/config/arm/aarch-common.c index 0dbdc56f542..67343fe4025 100644 --- a/gcc/config/arm/aarch-common.c +++ b/gcc/config/arm/aarch-common.c @@ -534,7 +534,7 @@ rtx_insn * arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, vec & /*input_modes*/, vec &constraints, vec & /*clobbers*/, - HARD_REG_SET & /*clobbered_regs*/) + HARD_REG_SET & /*clobbered_regs*/, location_t loc) { bool saw_asm_flag = false; @@ -547,7 +547,7 @@ arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, con += 4; if (strchr (con, ',') != NULL) { - error ("alternatives not allowed in % flag output"); + error_at (loc, "alternatives not allowed in % flag output"); continue; } @@ -608,7 +608,7 @@ arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, mode = CC_Vmode, code = NE; break; default: - error ("unknown % flag output %qs", constraints[i]); + error_at (loc, "unknown % flag output %qs", constraints[i]); continue; } @@ -618,7 +618,7 @@ arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, machine_mode dest_mode = GET_MODE (dest); if (!SCALAR_INT_MODE_P (dest_mode)) { - error ("invalid type for % flag output"); + error_at (loc, "invalid type for % flag output"); continue; } diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index de37c903450..6d781e23ee9 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -333,7 +333,7 @@ static HOST_WIDE_INT arm_constant_alignment (const_tree, HOST_WIDE_INT); static rtx_insn *thumb1_md_asm_adjust (vec &, vec &, vec &, vec &, vec &, - HARD_REG_SET &); + HARD_REG_SET &, location_t); /* Table of machine attributes. */ static const struct attribute_spec arm_attribute_table[] = @@ -34105,7 +34105,7 @@ rtx_insn * thumb1_md_asm_adjust (vec &outputs, vec & /*inputs*/, vec & /*input_modes*/, vec &constraints, vec & /*clobbers*/, - HARD_REG_SET & /*clobbered_regs*/) + HARD_REG_SET & /*clobbered_regs*/, location_t /*loc*/) { for (unsigned i = 0, n = outputs.length (); i < n; ++i) if (startswith (constraints[i], "=@cc")) diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index c95c436180c..200701a583c 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -14498,7 +14498,8 @@ static rtx_insn * avr_md_asm_adjust (vec &/*outputs*/, vec &/*inputs*/, vec & /*input_modes*/, vec &/*constraints*/, - vec &clobbers, HARD_REG_SET &clobbered_regs) + vec &clobbers, HARD_REG_SET &clobbered_regs, + location_t /*loc*/) { clobbers.safe_push (cc_reg_rtx); SET_HARD_REG_BIT (clobbered_regs, REG_CC); diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index d9213d7ffb6..f458ea0c53e 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -151,7 +151,7 @@ static void cris_function_arg_advance (cumulative_args_t, const function_arg_info &); static rtx_insn *cris_md_asm_adjust (vec &, vec &, vec &, vec &, - vec &, HARD_REG_SET &); + vec &, HARD_REG_SET &, location_t); static void cris_option_override (void); @@ -3507,7 +3507,7 @@ static rtx_insn * cris_md_asm_adjust (vec &outputs, vec &inputs, vec & /*input_modes*/, vec &constraints, vec &clobbers, - HARD_REG_SET &clobbered_regs) + HARD_REG_SET &clobbered_regs, location_t /*loc*/) { /* For the time being, all asms clobber condition codes. Revisit when there's a reasonable use for inputs/outputs diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index cff26909292..530d3572965 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -21596,7 +21596,7 @@ static rtx_insn * ix86_md_asm_adjust (vec &outputs, vec & /*inputs*/, vec & /*input_modes*/, vec &constraints, vec &clobbers, - HARD_REG_SET &clobbered_regs) + HARD_REG_SET &clobbered_regs, location_t loc) { bool saw_asm_flag = false; @@ -21609,7 +21609,7 @@ ix86_md_asm_adjust (vec &outputs, vec & /*inputs*/, con += 4; if (strchr (con, ',') != NULL) { - error ("alternatives not allowed in % flag output"); + error_at (loc, "alternatives not allowed in % flag output"); continue; } @@ -21673,7 +21673,7 @@ ix86_md_asm_adjust (vec &outputs, vec & /*inputs*/, } if (code == UNKNOWN) { - error ("unknown % flag output %qs", constraints[i]); + error_at (loc, "unknown % flag output %qs", constraints[i]); continue; } if (invert) @@ -21702,7 +21702,7 @@ ix86_md_asm_adjust (vec &outputs, vec & /*inputs*/, machine_mode dest_mode = GET_MODE (dest); if (!SCALAR_INT_MODE_P (dest_mode)) { - error ("invalid type for % flag output"); + error_at (loc, "invalid type for % flag output"); continue; } diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c index c1c2e6e3b5c..6f842a3ad32 100644 --- a/gcc/config/mn10300/mn10300.c +++ b/gcc/config/mn10300/mn10300.c @@ -2850,7 +2850,7 @@ static rtx_insn * mn10300_md_asm_adjust (vec & /*outputs*/, vec & /*inputs*/, vec & /*input_modes*/, vec & /*constraints*/, vec &clobbers, - HARD_REG_SET &clobbered_regs) + HARD_REG_SET &clobbered_regs, location_t /*loc*/) { clobbers.safe_push (gen_rtx_REG (CCmode, CC_REG)); SET_HARD_REG_BIT (clobbered_regs, CC_REG); diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c index 7217d7879b6..2c9cfcf322a 100644 --- a/gcc/config/nds32/nds32.c +++ b/gcc/config/nds32/nds32.c @@ -4199,7 +4199,8 @@ nds32_md_asm_adjust (vec &outputs ATTRIBUTE_UNUSED, vec &inputs ATTRIBUTE_UNUSED, vec &input_modes ATTRIBUTE_UNUSED, vec &constraints ATTRIBUTE_UNUSED, - vec &clobbers, HARD_REG_SET &clobbered_regs) + vec &clobbers, HARD_REG_SET &clobbered_regs, + location_t /*loc*/) { if (!flag_inline_asm_r15) { diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index 4cab3aee598..ced653116a4 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -156,7 +156,7 @@ static int pdp11_addr_cost (rtx, machine_mode, addr_space_t, bool); static int pdp11_insn_cost (rtx_insn *insn, bool speed); static rtx_insn *pdp11_md_asm_adjust (vec &, vec &, vec &, vec &, - vec &, HARD_REG_SET &); + vec &, HARD_REG_SET &, location_t); static bool pdp11_return_in_memory (const_tree, const_tree); static rtx pdp11_function_value (const_tree, const_tree, bool); static rtx pdp11_libcall_value (machine_mode, const_rtx); @@ -2139,7 +2139,7 @@ static rtx_insn * pdp11_md_asm_adjust (vec & /*outputs*/, vec & /*inputs*/, vec & /*input_modes*/, vec & /*constraints*/, vec &clobbers, - HARD_REG_SET &clobbered_regs) + HARD_REG_SET &clobbered_regs, location_t /*loc*/) { clobbers.safe_push (gen_rtx_REG (CCmode, CC_REGNUM)); SET_HARD_REG_BIT (clobbered_regs, CC_REGNUM); diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index de11de5e079..d14c51db193 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -3444,7 +3444,7 @@ static rtx_insn * rs6000_md_asm_adjust (vec & /*outputs*/, vec & /*inputs*/, vec & /*input_modes*/, vec & /*constraints*/, vec &clobbers, - HARD_REG_SET &clobbered_regs) + HARD_REG_SET &clobbered_regs, location_t /*loc*/) { clobbers.safe_push (gen_rtx_REG (SImode, CA_REGNO)); SET_HARD_REG_BIT (clobbered_regs, CA_REGNO); diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 590dd8f35bc..800e0abc016 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -16771,7 +16771,7 @@ static rtx_insn * s390_md_asm_adjust (vec &outputs, vec &inputs, vec &input_modes, vec &constraints, vec & /*clobbers*/, - HARD_REG_SET & /*clobbered_regs*/) + HARD_REG_SET & /*clobbered_regs*/, location_t /*loc*/) { if (!TARGET_VXE) /* Long doubles are stored in FPR pairs - nothing to do. */ diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c index 3aacd1e5986..e26ab3b2e8e 100644 --- a/gcc/config/vax/vax.c +++ b/gcc/config/vax/vax.c @@ -57,7 +57,7 @@ static bool vax_rtx_costs (rtx, machine_mode, int, int, int *, bool); static machine_mode vax_cc_modes_compatible (machine_mode, machine_mode); static rtx_insn *vax_md_asm_adjust (vec &, vec &, vec &, vec &, - vec &, HARD_REG_SET &); + vec &, HARD_REG_SET &, location_t); static rtx vax_function_arg (cumulative_args_t, const function_arg_info &); static void vax_function_arg_advance (cumulative_args_t, const function_arg_info &); @@ -1181,7 +1181,8 @@ vax_md_asm_adjust (vec &outputs ATTRIBUTE_UNUSED, vec &inputs ATTRIBUTE_UNUSED, vec &input_modes ATTRIBUTE_UNUSED, vec &constraints ATTRIBUTE_UNUSED, - vec &clobbers, HARD_REG_SET &clobbered_regs) + vec &clobbers, HARD_REG_SET &clobbered_regs, + location_t /*loc*/) { clobbers.safe_push (gen_rtx_REG (CCmode, VAX_PSL_REGNUM)); SET_HARD_REG_BIT (clobbered_regs, VAX_PSL_REGNUM); diff --git a/gcc/config/visium/visium.c b/gcc/config/visium/visium.c index 7eb22485297..58e5355e712 100644 --- a/gcc/config/visium/visium.c +++ b/gcc/config/visium/visium.c @@ -190,7 +190,7 @@ static tree visium_build_builtin_va_list (void); static rtx_insn *visium_md_asm_adjust (vec &, vec &, vec &, vec &, vec &, - HARD_REG_SET &); + HARD_REG_SET &, location_t); static bool visium_legitimate_constant_p (machine_mode, rtx); @@ -795,7 +795,7 @@ static rtx_insn * visium_md_asm_adjust (vec & /*outputs*/, vec & /*inputs*/, vec & /*input_modes*/, vec & /*constraints*/, vec &clobbers, - HARD_REG_SET &clobbered_regs) + HARD_REG_SET &clobbered_regs, location_t /*loc*/) { clobbers.safe_push (gen_rtx_REG (CCmode, FLAGS_REGNUM)); SET_HARD_REG_BIT (clobbered_regs, FLAGS_REGNUM); diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 2a41ae5fba1..3ad39443eba 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -11708,11 +11708,12 @@ from shared libraries (DLLs). You need not define this macro if it would always evaluate to zero. @end defmac -@deftypefn {Target Hook} {rtx_insn *} TARGET_MD_ASM_ADJUST (vec& @var{outputs}, vec& @var{inputs}, vec& @var{input_modes}, vec& @var{constraints}, vec& @var{clobbers}, HARD_REG_SET& @var{clobbered_regs}) +@deftypefn {Target Hook} {rtx_insn *} TARGET_MD_ASM_ADJUST (vec& @var{outputs}, vec& @var{inputs}, vec& @var{input_modes}, vec& @var{constraints}, vec& @var{clobbers}, HARD_REG_SET& @var{clobbered_regs}, location_t @var{loc}) This target hook may add @dfn{clobbers} to @var{clobbers} and @var{clobbered_regs} for any hard regs the port wishes to automatically clobber for an asm. The @var{outputs} and @var{inputs} may be inspected -to avoid clobbering a register that is already used by the asm. +to avoid clobbering a register that is already used by the asm. @var{loc} +is the source location of the asm. It may modify the @var{outputs}, @var{inputs}, @var{input_modes}, and @var{constraints} as necessary for other pre-processing. In this case the diff --git a/gcc/target.def b/gcc/target.def index c009671c583..2e40448e6c5 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4226,7 +4226,8 @@ DEFHOOK "This target hook may add @dfn{clobbers} to @var{clobbers} and\n\ @var{clobbered_regs} for any hard regs the port wishes to automatically\n\ clobber for an asm. The @var{outputs} and @var{inputs} may be inspected\n\ -to avoid clobbering a register that is already used by the asm.\n\ +to avoid clobbering a register that is already used by the asm. @var{loc}\n\ +is the source location of the asm.\n\ \n\ It may modify the @var{outputs}, @var{inputs}, @var{input_modes}, and\n\ @var{constraints} as necessary for other pre-processing. In this case the\n\ @@ -4236,7 +4237,7 @@ to @var{input_modes}.", rtx_insn *, (vec& outputs, vec& inputs, vec& input_modes, vec& constraints, vec& clobbers, - HARD_REG_SET& clobbered_regs), + HARD_REG_SET& clobbered_regs, location_t loc), NULL) /* This target hook allows the backend to specify a calling convention