From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id 3C602385E83D for ; Thu, 1 Jul 2021 12:48:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3C602385E83D Received: by mail-ed1-x530.google.com with SMTP id i24so8264722edx.4 for ; Thu, 01 Jul 2021 05:48:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cSKpft+3lTHzTGqnjVRkjhKJAjGYO/R6xyKoO6mQFmU=; b=ggz8RQGASZtjFt8I0ju7r0vRdCmE4KLd/x0z05QgbjcXhxuv56sB1QER5OIop4yPbD VlwfkzSrwYMYpq+CKZ7X2B0DMrLU4j090YEc/ZOdfbm39yvC3hKl6FC/ry2PjIdIJHdW iNbU2MramdG0Qh/NRu+ehzS1pUCYZ4Vhd0hbktjnUM9Uehl2VxaW5rlSHg6HsDUaTPsE VS2uVgj3CstRTaLwzgXobuBXq1iG8oBtF99aNgxfLcgXXKXmxjWePaiyUltejQV2ghjt arIpzWtb00LCHr4x8e8icrKE+MzUN1YSAnCDbT5g0w8cMjq+KeVEZf24X14k790Q1lOR u21g== X-Gm-Message-State: AOAM531iL1/Bq9cvNTr59bENXSW5QHPq3dia/mExHk6XCMgKYK9REm9A VDxvBhLlcGrV3UQDMUbfTe8xZQk1Ip0firFJA98= X-Google-Smtp-Source: ABdhPJwBNDuCEC0t+UEYyDGoHiIVlOeduLh9AfjiRqhvfqLb4zsqWHmUWzwgwxQyapRBzcp4od0dVOSaAO5H5/UZG7k= X-Received: by 2002:aa7:c3d6:: with SMTP id l22mr54175774edr.245.1625143693297; Thu, 01 Jul 2021 05:48:13 -0700 (PDT) MIME-Version: 1.0 References: <20210630053529.26581-1-tbsaunde@tbsaunde.org> <20210630053529.26581-2-tbsaunde@tbsaunde.org> <56A156E2-F617-45B0-88B5-E2F80F05DAA4@gmail.com> In-Reply-To: From: Richard Biener Date: Thu, 1 Jul 2021 14:48:02 +0200 Message-ID: Subject: Re: [PATCH 2/4] allow poisoning input_location in ranges it should not be used To: Trevor Saunders Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: , X-List-Received-Date: Thu, 01 Jul 2021 12:48:17 -0000 On Thu, Jul 1, 2021 at 12:24 PM Trevor Saunders wrote: > > On Wed, Jun 30, 2021 at 09:09:33PM +0200, Richard Biener wrote: > > On June 30, 2021 2:33:30 PM GMT+02:00, Trevor Saunders wrote: > > >On Wed, Jun 30, 2021 at 11:00:37AM +0200, Richard Biener wrote: > > >> On Wed, Jun 30, 2021 at 7:37 AM Trevor Saunders > > > wrote: > > >> > > > >> > This makes it possible to assert if input_location is used during > > >the lifetime > > >> > of a scope. This will allow us to find places that currently use > > >it within a > > >> > function and its callees, or prevent adding uses within the > > >lifetime of a > > >> > function after all existing uses are removed. > > >> > > > >> > bootstrapped and regtested on x86_64-linux-gnu, ok? > > >> > > >> I'm not sure about the general approach but I have comments about > > >> input_location. > > >> > > >> IMHO a good first step would be to guard the input_location > > >declaration with sth > > >> like > > >> > > >> #ifndef GCC_NEED_INPUT_LOCATION > > >> extern location_t input_location; > > >> #endif > > > > > >I think that's another reasonable step, my one concern is that it can > > >be > > >useful to push the usage of input_location, or any other global from > > >the > > >bottom of the stack to a caller that can provide a better argument > > >eventually, but first just use the global. Doing this sort of > > >refactoring is harder if you need to add files with callers to the > > >whitelist, and kind of defeats the point of the whitelist. Consider > > >the > > >below commit, that is untested, but perhaps I should have included in > > >this series as somewhat related. > > > > > >As for this approach being limited to functions that's somewhat true, > > >but since it effects all functions called while its on the stack, it > > >would mean once enough infrastructure is fixed, we could add one the > > >execute method of a pass and nothing in the pass could touch > > >input_location. The limit also means that it doesn't get in the way of > > >the above sort of refactoring, but as it proceeds lower level functions > > >that now take explicit arguments can be called from contexts that ban > > >use of input_location. > > > > > >Trev > > > > > >From efd04d2df4163dd930f489d9fba1455bfb368114 Mon Sep 17 00:00:00 2001 > > >From: Trevor Saunders > > >Date: Sun, 27 Jun 2021 02:10:26 -0400 > > >Subject: [PATCH] force decls to be allocated through build_decl to > > >initialize > > > them > > >To: gcc-patches@gcc.gnu.org > > > > > >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. > > > > If make_node really uses input_location that's what should change (to UNONOWN_LOCATION). But yes, it might change behavior to the worse... > > make_node really does, when making a decl. My idea was to force using > build_decl rather than make_node when making a decl, that way make_node > could stop doing anything special for decls including setting the > location, implicitly leaving it as UNKNOWN_LOCATION since it clears the > object when allocating it. Then I used input_location as an argument to > build_decl wherever the location currently isn't set to something else, > so as not to make things worse. That way callers that know the right > location do not need to touch input_location, and it pushes the problem > to the places where we need to work on finding a better location, and > might be able to do so rather than deep in make_node. Does that seem > reasonable as an incremental step to using input_location less, even > without trying to block its use? I guess so - I was just worried that make_node is used for a reason in some places (when we build a VAR/PARM/RESULT_DECL that avoids calling layout_decl for example). Note build_decl still invokes make_node (and thus refers to input_location ...), but yes, if you catch all decl cases to go through build_decl then you can be confident in changing make_node ... Richard. > > Thanks > > Trev > > > > > Richard. > > > > >--- > > > gcc/cfgexpand.c | 8 +++--- > > > gcc/cp/cp-gimplify.c | 5 ++-- > > > 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.c | 49 ++++++++++++++++++------------------ > > > gcc/tree.h | 9 ++++++- > > > gcc/varasm.c | 12 ++++----- > > > 19 files changed, 93 insertions(+), 94 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/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/fortran/trans-decl.c b/gcc/fortran/trans-decl.c > > >index 479ba6fa6ce..b726c2f2bdc 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 5582e404df9..8b4d5c99665 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 f2d91476655..242fa4dee1d 100644 > > >--- a/gcc/ipa-param-manipulation.c > > >+++ b/gcc/ipa-param-manipulation.c > > >@@ -834,9 +834,9 @@ ipa_param_adjustments::modify_call (gcall *stmt, > > > } > > > 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); > > >@@ -1883,10 +1883,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 8d106a4de26..259ce520143 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; > > > > > >@@ -4889,9 +4887,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; > > >@@ -4975,8 +4972,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 9e041ca4d56..0204ce20282 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); > > >@@ -6494,9 +6495,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); > > >@@ -6525,10 +6526,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 42585412325..dc6f412c02d 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 1777bff2f7c..25589716a11 100644 > > >--- a/gcc/tree-ssa-phiopt.c > > >+++ b/gcc/tree-ssa-phiopt.c > > >@@ -2302,18 +2302,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.c b/gcc/tree.c > > >index 1aa6e557a04..a90097a51c6 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,27 +1194,7 @@ 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; > > >- if (TREE_CODE (t) == DEBUG_EXPR_DECL) > > >- DECL_UID (t) = --next_debug_decl_uid; > > >- else > > >- { > > >- DECL_UID (t) = allocate_decl_uid (); > > >- SET_DECL_PT_UID (t, -1); > > >- } > > >- if (TREE_CODE (t) == LABEL_DECL) > > >- LABEL_DECL_UID (t) = -1; > > >- > > >+ gcc_assert (caller == BUILD_DECL_MKNODE_CALLER); > > > break; > > > > > > case tcc_type: > > >@@ -5257,10 +5237,29 @@ tree > > > build_decl (location_t loc, enum tree_code code, tree name, > > > tree type MEM_STAT_DECL) > > > { > > >- tree t; > > >- > > >- t = make_node (code PASS_MEM_STAT); > > >+ tree t = make_node (code, BUILD_DECL_MKNODE_CALLER PASS_MEM_STAT); > > > DECL_SOURCE_LOCATION (t) = loc; > > >+ 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); > > >+ } > > >+ > > >+ if (TREE_CODE (t) == DEBUG_EXPR_DECL) > > >+ DECL_UID (t) = --next_debug_decl_uid; > > >+ else > > >+ { > > >+ DECL_UID (t) = allocate_decl_uid (); > > >+ SET_DECL_PT_UID (t, -1); > > >+ } > > >+ > > >+ 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..86dd32354f2 100644 > > >--- a/gcc/tree.h > > >+++ b/gcc/tree.h > > >@@ -4357,11 +4357,18 @@ 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 > > >+}; > > >+ > > > /* 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; > >