From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 31236383983A for ; Wed, 30 Jun 2021 19:09:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 31236383983A Received: by mail-ed1-x52c.google.com with SMTP id h2so4791290edt.3 for ; Wed, 30 Jun 2021 12:09:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:cc:from :message-id; bh=ELVQWsA7/zsNd2WI/XXDwOO9I9NgNrXXoOf9APND3Vg=; b=tgzCBnThpiS3h5fgBLl4kVT5czA0kcN4UL0xVD+PEex+GYJR3TjhcjVkZ44b2MJ4jV FrPwvFqYGWrj4pQmWsGP+RyRfh3QvGq+xi91lHES5RwtqS0QWMiK14ra65ynD57mTLJ2 lCGYuDgXANLD/CztQo55R3rLyLddQ3KYTlCyYcSO/TkYRL8XBeVi3EVfm6o/6oBXpuAP VPbJnjuTn/NJj0IZiVkIlYZY89Av3C9sagiQcGwAjb7BDNN99VgFUBsPsD8p2OuaHXdv oanfnVqNeX88Vaewxwkfb9yubXBlpyavXE3KKzS3WJM96s0u1hEB2B3zHCRrOTyLMwLq efFw== X-Gm-Message-State: AOAM530RASySCZtqcMFangGF7XvH15XPv9YI0rBTangqltRyuDv9hiGv ji5fJFGNHXmTBjaR/r0U5Qc= X-Google-Smtp-Source: ABdhPJzghV9ZNlPK3z2oN5ZBkhsPEnHp2S1/mDavxQP/OFPKh/7STdtMdoq57SL/OuULsmBO3YuGYQ== X-Received: by 2002:a05:6402:28b2:: with SMTP id eg50mr1368432edb.320.1625080177118; Wed, 30 Jun 2021 12:09:37 -0700 (PDT) Received: from [192.168.178.32] (dynamic-077-007-106-076.77.7.pool.telefonica.de. [77.7.106.76]) by smtp.gmail.com with ESMTPSA id g21sm1642450ejf.25.2021.06.30.12.09.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jun 2021 12:09:36 -0700 (PDT) Date: Wed, 30 Jun 2021 21:09:33 +0200 User-Agent: K-9 Mail for Android In-Reply-To: References: <20210630053529.26581-1-tbsaunde@tbsaunde.org> <20210630053529.26581-2-tbsaunde@tbsaunde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH 2/4] allow poisoning input_location in ranges it should not be used To: Trevor Saunders CC: GCC Patches From: Richard Biener Message-ID: <56A156E2-F617-45B0-88B5-E2F80F05DAA4@gmail.com> X-Spam-Status: No, score=-9.7 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Wed, 30 Jun 2021 19:09:42 -0000 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=2E 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=2E >> > >> > bootstrapped and regtested on x86_64-linux-gnu, ok? >>=20 >> I'm not sure about the general approach but I have comments about >> input_location=2E >>=20 >> IMHO a good first step would be to guard the input_location >declaration with sth >> like >>=20 >> #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=2E 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=2E Consider >the >below commit, that is untested, but perhaps I should have included in >this series as somewhat related=2E > >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=2E 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=2E > >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=2Egnu=2Eorg > >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=2E 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=2E So we force all callers who wish to >make a decl >to go through build_decl which already takes a location argument=2E 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=2E If make_node really uses input_location that's what should change (to UNON= OWN_LOCATION)=2E But yes, it might change behavior to the worse=2E=2E=2E= =20 Richard=2E=20 >--- > gcc/cfgexpand=2Ec | 8 +++--- > gcc/cp/cp-gimplify=2Ec | 5 ++-- > gcc/fortran/trans-decl=2Ec | 5 ++-- > gcc/fortran/trans-types=2Ec | 4 +-- > gcc/ipa-param-manipulation=2Ec | 8 +++--- > gcc/objc/objc-act=2Ec | 16 +++++------- > gcc/omp-simd-clone=2Ec | 4 +-- > gcc/stor-layout=2Ec | 2 +- > gcc/tree-inline=2Ec | 13 +++++----- > gcc/tree-into-ssa=2Ec | 4 +-- > gcc/tree-nested=2Ec | 24 ++++++++---------- > gcc/tree-ssa-ccp=2Ec | 4 +-- > gcc/tree-ssa-loop-ivopts=2Ec | 4 +-- > gcc/tree-ssa-phiopt=2Ec | 8 +++--- > gcc/tree-ssa-reassoc=2Ec | 4 +-- > gcc/tree-ssa=2Ec | 4 +-- > gcc/tree=2Ec | 49 ++++++++++++++++++------------------ > gcc/tree=2Eh | 9 ++++++- > gcc/varasm=2Ec | 12 ++++----- > 19 files changed, 93 insertions(+), 94 deletions(-) > >diff --git a/gcc/cfgexpand=2Ec b/gcc/cfgexpand=2Ec >index 3edd53c37dc=2E=2Efea8c837c80 100644 >--- a/gcc/cfgexpand=2Ec >+++ b/gcc/cfgexpand=2Ec >@@ -4342,10 +4342,10 @@ avoid_deep_ter_for_debug (gimple *stmt, int >depth) > tree &vexpr =3D deep_ter_debug_map->get_or_insert (use); > if (vexpr !=3D NULL) > continue; >- vexpr =3D make_node (DEBUG_EXPR_DECL); >+ vexpr =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ TREE_TYPE (use)); > gimple *def_temp =3D gimple_build_debug_bind (vexpr, use, g); > DECL_ARTIFICIAL (vexpr) =3D 1; >- TREE_TYPE (vexpr) =3D TREE_TYPE (use); > SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (use))); > gimple_stmt_iterator gsi =3D 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=2E */ > gimple *debugstmt; > tree value =3D gimple_assign_rhs_to_tree (def); >- tree vexpr =3D make_node (DEBUG_EXPR_DECL); > rtx val; > machine_mode mode; >=20 > set_curr_insn_location (gimple_location (def)); >=20 >+ tree vexpr =3D build_decl (input_location, DEBUG_EXPR_DECL, >+ nullptr, TREE_TYPE (value)); > DECL_ARTIFICIAL (vexpr) =3D 1; >- TREE_TYPE (vexpr) =3D TREE_TYPE (value); > if (DECL_P (value)) > mode =3D DECL_MODE (value); > else >diff --git a/gcc/cp/cp-gimplify=2Ec b/gcc/cp/cp-gimplify=2Ec >index 00b7772fe0d=2E=2Ed537e547169 100644 >--- a/gcc/cp/cp-gimplify=2Ec >+++ b/gcc/cp/cp-gimplify=2Ec >@@ -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=2E */; > else > { >- tree using_directive =3D make_node (IMPORTED_DECL); >- TREE_TYPE (using_directive) =3D void_type_node; >+ tree using_directive =3D build_decl (input_location, >+ IMPORTED_DECL, nullptr, >+ void_type_node); > DECL_CONTEXT (using_directive) =3D current_function_decl; >=20 > IMPORTED_DECL_ASSOCIATED_DECL (using_directive) =3D decl; >diff --git a/gcc/fortran/trans-decl=2Ec b/gcc/fortran/trans-decl=2Ec >index 479ba6fa6ce=2E=2Eb726c2f2bdc 100644 >--- a/gcc/fortran/trans-decl=2Ec >+++ b/gcc/fortran/trans-decl=2Ec >@@ -5262,10 +5262,9 @@ generate_namelist_decl (gfc_symbol * sym) > CONSTRUCTOR_APPEND_ELT (nml_decls, NULL_TREE, nml->sym->backend_decl); > } >=20 >- decl =3D make_node (NAMELIST_DECL); >- TREE_TYPE (decl) =3D void_type_node; >+ decl =3D build_decl (input_location, NAMELIST_DECL, get_identifier >(sym->name), >+ void_type_node); >NAMELIST_DECL_ASSOCIATED_DECL (decl) =3D build_constructor (NULL_TREE, >nml_decls); >- DECL_NAME (decl) =3D get_identifier (sym->name); > return decl; > } >=20 >diff --git a/gcc/fortran/trans-types=2Ec b/gcc/fortran/trans-types=2Ec >index 5582e404df9=2E=2E8b4d5c99665 100644 >--- a/gcc/fortran/trans-types=2Ec >+++ b/gcc/fortran/trans-types=2Ec >@@ -3417,9 +3417,9 @@ gfc_get_array_descr_info (const_tree type, struct >array_descr_info *info) > base_decl =3D GFC_TYPE_ARRAY_BASE_DECL (type, indirect); > if (!base_decl) > { >- base_decl =3D make_node (DEBUG_EXPR_DECL); >+ base_decl =3D build_decl (input_location, DEBUG_EXPR_DECL, >nullptr, >+ indirect ? build_pointer_type (ptype) : ptype); > DECL_ARTIFICIAL (base_decl) =3D 1; >- TREE_TYPE (base_decl) =3D indirect ? build_pointer_type (ptype) : >ptype; > SET_DECL_MODE (base_decl, TYPE_MODE (TREE_TYPE (base_decl))); > GFC_TYPE_ARRAY_BASE_DECL (type, indirect) =3D base_decl; > } >diff --git a/gcc/ipa-param-manipulation=2Ec >b/gcc/ipa-param-manipulation=2Ec >index f2d91476655=2E=2E242fa4dee1d 100644 >--- a/gcc/ipa-param-manipulation=2Ec >+++ b/gcc/ipa-param-manipulation=2Ec >@@ -834,9 +834,9 @@ ipa_param_adjustments::modify_call (gcall *stmt, > } > if (ddecl =3D=3D NULL) > { >- ddecl =3D make_node (DEBUG_EXPR_DECL); >+ ddecl =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ TREE_TYPE (origin)); > DECL_ARTIFICIAL (ddecl) =3D 1; >- TREE_TYPE (ddecl) =3D TREE_TYPE (origin); > SET_DECL_MODE (ddecl, DECL_MODE (origin)); >=20 > 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 =3D=3D NULL && gsip !=3D NULL) > { >- vexpr =3D make_node (DEBUG_EXPR_DECL); >+ vexpr =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ TREE_TYPE (name)); > def_temp =3D gimple_build_debug_source_bind (vexpr, decl, NULL); > DECL_ARTIFICIAL (vexpr) =3D 1; >- TREE_TYPE (vexpr) =3D 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=2Ec b/gcc/objc/objc-act=2Ec >index 8d106a4de26=2E=2E259ce520143 100644 >--- a/gcc/objc/objc-act=2Ec >+++ b/gcc/objc/objc-act=2Ec >@@ -1295,12 +1295,11 @@ objc_add_property_declaration (location_t >location, tree decl, > } >=20 > /* Create a PROPERTY_DECL node=2E */ >- tree property_decl =3D make_node (PROPERTY_DECL); >+ tree property_decl =3D build_decl (DECL_SOURCE_LOCATION (decl), >PROPERTY_DECL, >+ nullptr, TREE_TYPE (decl)); >=20 > /* Copy the basic information from the original decl=2E */ > tree p_type =3D TREE_TYPE (decl); >- TREE_TYPE (property_decl) =3D p_type; >- DECL_SOURCE_LOCATION (property_decl) =3D DECL_SOURCE_LOCATION (decl); > TREE_DEPRECATED (property_decl) =3D TREE_DEPRECATED (decl); >=20 > /* Add property-specific information=2E */ >@@ -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=2E */ >- property_decl =3D make_node (PROPERTY_DECL); >+ property_decl =3D build_decl (input_location, PROPERTY_DECL, >nullptr, >+ type); >=20 >- TREE_TYPE (property_decl) =3D type; >- DECL_SOURCE_LOCATION (property_decl) =3D input_location; > TREE_DEPRECATED (property_decl) =3D 0; > DECL_ARTIFICIAL (property_decl) =3D 1; >=20 >@@ -4889,9 +4887,8 @@ objc_build_keyword_decl (tree key_name, tree >arg_type, > /* If no type is specified, default to "id"=2E */ > arg_type =3D adjust_type_for_id_default (arg_type); >=20 >- keyword_decl =3D make_node (KEYWORD_DECL); >+ keyword_decl =3D build_decl (input_location, KEYWORD_DECL, nullptr, >arg_type); >=20 >- TREE_TYPE (keyword_decl) =3D arg_type; > KEYWORD_ARG_NAME (keyword_decl) =3D arg_name; > KEYWORD_KEY_NAME (keyword_decl) =3D key_name; > DECL_ATTRIBUTES (keyword_decl) =3D attributes; >@@ -4975,8 +4972,7 @@ build_method_decl (enum tree_code code, tree >ret_type, tree selector, > type of the method=2E 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)=2E */ >- method_decl =3D make_node (code); >- TREE_TYPE (method_decl) =3D ret_type; >+ method_decl =3D build_decl (input_location, code, nullptr, ret_type); >=20 > /* If we have a keyword selector, create an identifier_node that > represents the full selector name (`:' included)=2E=2E=2E */ >diff --git a/gcc/omp-simd-clone=2Ec b/gcc/omp-simd-clone=2Ec >index b772b7ff520=2E=2E03189f4c50f 100644 >--- a/gcc/omp-simd-clone=2Ec >+++ b/gcc/omp-simd-clone=2Ec >@@ -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 =3D make_node (DEBUG_EXPR_DECL); >+ tree vexpr =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ TREE_TYPE (repl)); > stmt =3D gimple_build_debug_source_bind (vexpr, repl, NULL); > DECL_ARTIFICIAL (vexpr) =3D 1; >- TREE_TYPE (vexpr) =3D TREE_TYPE (repl); > SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (repl))); > repl =3D vexpr; > } >diff --git a/gcc/stor-layout=2Ec b/gcc/stor-layout=2Ec >index 242452f2acf=2E=2E7811fc6c302 100644 >--- a/gcc/stor-layout=2Ec >+++ b/gcc/stor-layout=2Ec >@@ -2024,7 +2024,7 @@ finalize_type_size (tree type) > static tree > start_bitfield_representative (tree field) > { >- tree repr =3D make_node (FIELD_DECL); >+ tree repr =3D build_decl (input_location, FIELD_DECL, nullptr, >nullptr); > DECL_FIELD_OFFSET (repr) =3D 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=2Ec b/gcc/tree-inline=2Ec >index 9e041ca4d56=2E=2E0204ce20282 100644 >--- a/gcc/tree-inline=2Ec >+++ b/gcc/tree-inline=2Ec >@@ -193,7 +193,6 @@ remap_ssa_name (tree name, copy_body_data *id) > && id->entry_bb =3D=3D NULL > && single_succ_p (ENTRY_BLOCK_PTR_FOR_FN (cfun))) > { >- tree vexpr =3D make_node (DEBUG_EXPR_DECL); > gimple *def_temp; > gimple_stmt_iterator gsi; > tree val =3D SSA_NAME_VAR (name); >@@ -210,9 +209,11 @@ remap_ssa_name (tree name, copy_body_data *id) > n =3D id->decl_map->get (val); > if (n && TREE_CODE (*n) =3D=3D DEBUG_EXPR_DECL) > return *n; >+ >+ tree vexpr =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ TREE_TYPE (name)); > def_temp =3D gimple_build_debug_source_bind (vexpr, val, NULL); > DECL_ARTIFICIAL (vexpr) =3D 1; >- TREE_TYPE (vexpr) =3D TREE_TYPE (name); > SET_DECL_MODE (vexpr, DECL_MODE (SSA_NAME_VAR (name))); > gsi =3D 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 =3D decl_debug_args_insert (new_decl); > len =3D vec_safe_length (*debug_args); > } >- ddecl =3D make_node (DEBUG_EXPR_DECL); >+ ddecl =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ TREE_TYPE (parm)); > DECL_ARTIFICIAL (ddecl) =3D 1; >- TREE_TYPE (ddecl) =3D 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 =3D TREE_CHAIN (var); > if (var =3D=3D NULL_TREE) > break; >- vexpr =3D make_node (DEBUG_EXPR_DECL); > tree parm =3D (**debug_args)[i]; >+ vexpr =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ TREE_TYPE (parm)); > DECL_ARTIFICIAL (vexpr) =3D 1; >- TREE_TYPE (vexpr) =3D TREE_TYPE (parm); > SET_DECL_MODE (vexpr, DECL_MODE (parm)); > def_temp =3D gimple_build_debug_bind (var, vexpr, NULL); > gsi_insert_before (&cgsi, def_temp, GSI_NEW_STMT); >diff --git a/gcc/tree-into-ssa=2Ec b/gcc/tree-into-ssa=2Ec >index 8045e34df26=2E=2Ef9933305957 100644 >--- a/gcc/tree-into-ssa=2Ec >+++ b/gcc/tree-into-ssa=2Ec >@@ -1284,10 +1284,10 @@ rewrite_debug_stmt_uses (gimple *stmt) > if (def =3D=3D NULL_TREE) > { > gimple *def_temp; >- def =3D make_node (DEBUG_EXPR_DECL); >+ def =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ TREE_TYPE (var)); > def_temp =3D gimple_build_debug_source_bind (def, var, NULL); > DECL_ARTIFICIAL (def) =3D 1; >- TREE_TYPE (def) =3D TREE_TYPE (var); > SET_DECL_MODE (def, DECL_MODE (var)); > gsi =3D > gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun))); >diff --git a/gcc/tree-nested=2Ec b/gcc/tree-nested=2Ec >index 9edd922a303=2E=2E37e229477ec 100644 >--- a/gcc/tree-nested=2Ec >+++ b/gcc/tree-nested=2Ec >@@ -394,8 +394,8 @@ lookup_field_for_decl (struct nesting_info *info, >tree decl, > if (!*slot) > { > tree type =3D get_frame_type (info); >- tree field =3D make_node (FIELD_DECL); >- DECL_NAME (field) =3D DECL_NAME (decl); >+ tree field =3D build_decl (input_location, FIELD_DECL, DECL_NAME >(decl), >+ nullptr); >=20 > if (use_pointer_in_frame (decl)) > { >@@ -510,9 +510,8 @@ get_chain_field (struct nesting_info *info) > { > tree type =3D build_pointer_type (get_frame_type (info->outer)); >=20 >- field =3D make_node (FIELD_DECL); >- DECL_NAME (field) =3D get_identifier ("__chain"); >- TREE_TYPE (field) =3D type; >+ field =3D build_decl (input_location, FIELD_DECL, >+ get_identifier ("__chain"), type); > SET_DECL_ALIGN (field, TYPE_ALIGN (type)); > DECL_NONADDRESSABLE_P (field) =3D 1; >=20 >@@ -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 =3D make_node (FIELD_DECL); >- DECL_NAME (field) =3D DECL_NAME (decl); >- TREE_TYPE (field) =3D type; >+ tree field =3D build_decl (input_location, FIELD_DECL, DECL_NAME >(decl), type); > TREE_ADDRESSABLE (field) =3D 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 =3D build_array_type > (type, build_index_type (size_int (size))); >=20 >- field =3D make_node (FIELD_DECL); >- DECL_NAME (field) =3D get_identifier ("__nl_goto_buf"); >- TREE_TYPE (field) =3D type; >+ field =3D build_decl (input_location, FIELD_DECL, >+ get_identifier ("__nl_goto_buf"), type); > SET_DECL_ALIGN (field, TYPE_ALIGN (type)); > TREE_ADDRESSABLE (field) =3D 1; >=20 >@@ -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=2E 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=2E */ >- tree fb_decl =3D make_node (FIELD_DECL); >+ tree fb_decl =3D build_decl (input_location, FIELD_DECL, >+ get_identifier ("FRAME_BASE=2EPARENT"), >+ ptr_type_node); >=20 >- DECL_NAME (fb_decl) =3D get_identifier ("FRAME_BASE=2EPARENT"); >- TREE_TYPE (fb_decl) =3D ptr_type_node; > TREE_ADDRESSABLE (fb_decl) =3D 1; > DECL_CONTEXT (fb_decl) =3D root->frame_type; >TYPE_FIELDS (root->frame_type) =3D chainon (TYPE_FIELDS >(root->frame_type), >diff --git a/gcc/tree-ssa-ccp=2Ec b/gcc/tree-ssa-ccp=2Ec >index 42585412325=2E=2Edc6f412c02d 100644 >--- a/gcc/tree-ssa-ccp=2Ec >+++ b/gcc/tree-ssa-ccp=2Ec >@@ -3067,9 +3067,9 @@ optimize_atomic_bit_test_and >(gimple_stmt_iterator *gsip, > tree temp =3D NULL_TREE; > if (!throws || after || single_pred_p (e->dest)) > { >- temp =3D make_node (DEBUG_EXPR_DECL); >+ temp =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ TREE_TYPE (lhs)); > DECL_ARTIFICIAL (temp) =3D 1; >- TREE_TYPE (temp) =3D TREE_TYPE (lhs); > SET_DECL_MODE (temp, TYPE_MODE (TREE_TYPE (lhs))); > tree t =3D build2 (LSHIFT_EXPR, TREE_TYPE (lhs), new_lhs, bit); > g =3D gimple_build_debug_bind (temp, t, g); >diff --git a/gcc/tree-ssa-loop-ivopts=2Ec b/gcc/tree-ssa-loop-ivopts=2Ec >index 12a8a49a307=2E=2E953b3d0b2f1 100644 >--- a/gcc/tree-ssa-loop-ivopts=2Ec >+++ b/gcc/tree-ssa-loop-ivopts=2Ec >@@ -7677,9 +7677,9 @@ remove_unused_ivs (struct ivopts_data *data, >bitmap toremove) > comp =3D unshare_expr (comp); > if (count > 1) > { >- tree vexpr =3D make_node (DEBUG_EXPR_DECL); >+ tree vexpr =3D build_decl (input_location, DEBUG_EXPR_DECL, >+ nullptr, TREE_TYPE (comp)); > DECL_ARTIFICIAL (vexpr) =3D 1; >- TREE_TYPE (vexpr) =3D 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=2Ec b/gcc/tree-ssa-phiopt=2Ec >index 1777bff2f7c=2E=2E25589716a11 100644 >--- a/gcc/tree-ssa-phiopt=2Ec >+++ b/gcc/tree-ssa-phiopt=2Ec >@@ -2302,18 +2302,18 @@ spaceship_replacement (basic_block cond_bb, >basic_block middle_bb, > all floating point numbers should be comparable=2E */ > gimple_stmt_iterator gsi =3D gsi_after_labels (gimple_bb (phi)); > tree type =3D TREE_TYPE (phires); >- tree temp1 =3D make_node (DEBUG_EXPR_DECL); >+ tree temp1 =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ type); > DECL_ARTIFICIAL (temp1) =3D 1; >- TREE_TYPE (temp1) =3D type; > SET_DECL_MODE (temp1, TYPE_MODE (type)); > tree t =3D build2 (one_cmp, boolean_type_node, lhs1, rhs2); > t =3D build3 (COND_EXPR, type, t, build_one_cst (type), > build_int_cst (type, -1)); > gimple *g =3D gimple_build_debug_bind (temp1, t, phi); > gsi_insert_before (&gsi, g, GSI_SAME_STMT); >- tree temp2 =3D make_node (DEBUG_EXPR_DECL); >+ tree temp2 =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ type); > DECL_ARTIFICIAL (temp2) =3D 1; >- TREE_TYPE (temp2) =3D type; > SET_DECL_MODE (temp2, TYPE_MODE (type)); > t =3D build2 (EQ_EXPR, boolean_type_node, lhs1, rhs2); > t =3D build3 (COND_EXPR, type, t, build_zero_cst (type), temp1); >diff --git a/gcc/tree-ssa-reassoc=2Ec b/gcc/tree-ssa-reassoc=2Ec >index 2dd4435b981=2E=2E48f6117a731 100644 >--- a/gcc/tree-ssa-reassoc=2Ec >+++ b/gcc/tree-ssa-reassoc=2Ec >@@ -1214,14 +1214,14 @@ make_new_ssa_for_def (gimple *stmt, enum >tree_code opcode, tree op) > { > if (new_debug_lhs =3D=3D NULL_TREE) > { >- new_debug_lhs =3D make_node (DEBUG_EXPR_DECL); >+ new_debug_lhs =3D build_decl (input_location, DEBUG_EXPR_DECL, >+ nullptr, TREE_TYPE (lhs)); > gdebug *def_temp > =3D gimple_build_debug_bind (new_debug_lhs, > build2 (opcode, TREE_TYPE (lhs), > new_lhs, op), > stmt); > DECL_ARTIFICIAL (new_debug_lhs) =3D 1; >- TREE_TYPE (new_debug_lhs) =3D 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 =3D gsi_for_stmt (stmt); >diff --git a/gcc/tree-ssa=2Ec b/gcc/tree-ssa=2Ec >index 4cc400d3c2e=2E=2E83caadb37c8 100644 >--- a/gcc/tree-ssa=2Ec >+++ b/gcc/tree-ssa=2Ec >@@ -434,14 +434,14 @@ insert_debug_temp_for_var_def >(gimple_stmt_iterator *gsi, tree var) > else > { > gdebug *def_temp; >- tree vexpr =3D make_node (DEBUG_EXPR_DECL); >+ tree vexpr =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >+ TREE_TYPE (value)); >=20 > def_temp =3D gimple_build_debug_bind (vexpr, > unshare_expr (value), > def_stmt); >=20 > DECL_ARTIFICIAL (vexpr) =3D 1; >- TREE_TYPE (vexpr) =3D TREE_TYPE (value); > if (DECL_P (value)) > SET_DECL_MODE (vexpr, DECL_MODE (value)); > else >diff --git a/gcc/tree=2Ec b/gcc/tree=2Ec >index 1aa6e557a04=2E=2Ea90097a51c6 100644 >--- a/gcc/tree=2Ec >+++ b/gcc/tree=2Ec >@@ -1175,7 +1175,7 @@ allocate_decl_uid (void) > Achoo! I got a code in the node=2E */ >=20 > 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 =3D TREE_CODE_CLASS (code); >@@ -1194,27 +1194,7 @@ make_node (enum tree_code code MEM_STAT_DECL) > break; >=20 > case tcc_declaration: >- if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) >- { >- if (code =3D=3D 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) =3D input_location; >- if (TREE_CODE (t) =3D=3D DEBUG_EXPR_DECL) >- DECL_UID (t) =3D --next_debug_decl_uid; >- else >- { >- DECL_UID (t) =3D allocate_decl_uid (); >- SET_DECL_PT_UID (t, -1); >- } >- if (TREE_CODE (t) =3D=3D LABEL_DECL) >- LABEL_DECL_UID (t) =3D -1; >- >+ gcc_assert (caller =3D=3D BUILD_DECL_MKNODE_CALLER); > break; >=20 > 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 =3D make_node (code PASS_MEM_STAT); >+ tree t =3D make_node (code, BUILD_DECL_MKNODE_CALLER PASS_MEM_STAT); > DECL_SOURCE_LOCATION (t) =3D loc; >+ if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) >+ { >+ if (code =3D=3D 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) =3D=3D DEBUG_EXPR_DECL) >+ DECL_UID (t) =3D --next_debug_decl_uid; >+ else >+ { >+ DECL_UID (t) =3D allocate_decl_uid (); >+ SET_DECL_PT_UID (t, -1); >+ } >+ >+ if (TREE_CODE (t) =3D=3D LABEL_DECL) >+ LABEL_DECL_UID (t) =3D -1; >=20 > /* if (type =3D=3D error_mark_node) > type =3D integer_type_node; */ >diff --git a/gcc/tree=2Eh b/gcc/tree=2Eh >index 8bdf16d8b4a=2E=2E86dd32354f2 100644 >--- a/gcc/tree=2Eh >+++ b/gcc/tree=2Eh >@@ -4357,11 +4357,18 @@ extern size_t tree_code_size (enum tree_code); > /* Allocate and return a new UID from the DECL_UID namespace=2E */ > extern int allocate_decl_uid (void); >=20 >+/* expected callers of make_node=2E */ >+enum make_node_caller >+{ >+ UNKNOWN_MKNODE_CALLER, >+ BUILD_DECL_MKNODE_CALLER >+}; >+ > /* Lowest level primitive for allocating a node=2E > The TREE_CODE is the only argument=2E Contents are initialized > to zero except for a few of the common fields=2E */ >=20 >-extern tree make_node (enum tree_code CXX_MEM_STAT_INFO); >+extern tree make_node (enum tree_code, enum make_node_caller caller =3D >UNKNOWN_MKNODE_CALLER CXX_MEM_STAT_INFO); >=20 > /* Free tree node=2E */ >=20 >diff --git a/gcc/varasm=2Ec b/gcc/varasm=2Ec >index 53cf6dea3f3=2E=2Efa6799e48fb 100644 >--- a/gcc/varasm=2Ec >+++ b/gcc/varasm=2Ec >@@ -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 =3D make_node (DEBUG_EXPR_DECL), type; >+ tree type; > machine_mode mode =3D GET_MODE (exp); > rtx dval; >=20 >- DECL_ARTIFICIAL (ddecl) =3D 1; > if (REG_P (exp) && REG_EXPR (exp)) > type =3D TREE_TYPE (REG_EXPR (exp)); > else if (MEM_P (exp) && MEM_EXPR (exp)) > type =3D TREE_TYPE (MEM_EXPR (exp)); > else > type =3D NULL_TREE; >- if (type && TYPE_MODE (type) =3D=3D mode) >- TREE_TYPE (ddecl) =3D type; >- else >- TREE_TYPE (ddecl) =3D lang_hooks=2Etypes=2Etype_for_mode (mode, 1); >+ if (!type || TYPE_MODE (type) !=3D mode) >+ type =3D lang_hooks=2Etypes=2Etype_for_mode (mode, 1); >+ >+ tree ddecl =3D build_decl (input_location, DEBUG_EXPR_DECL, nullptr, >type); >+ DECL_ARTIFICIAL (ddecl) =3D 1; > SET_DECL_MODE (ddecl, mode); > dval =3D gen_rtx_DEBUG_EXPR (mode); > DEBUG_EXPR_TREE_DECL (dval) =3D ddecl;