From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2049) id 90C763856DFF; Thu, 5 May 2022 12:07:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 90C763856DFF Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Matthew Malcomson To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] Add build_addr_expr_loc X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: b781c384f8ffda4751d32376b50d7dd30542a167 X-Git-Newrev: 9da7c6e34a60bdf9846b1d7af4b50babffa97768 Message-Id: <20220505120757.90C763856DFF@sourceware.org> Date: Thu, 5 May 2022 12:07:57 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2022 12:07:57 -0000 https://gcc.gnu.org/g:9da7c6e34a60bdf9846b1d7af4b50babffa97768 commit 9da7c6e34a60bdf9846b1d7af4b50babffa97768 Author: Richard Sandiford Date: Mon Apr 11 17:35:39 2022 +0100 Add build_addr_expr_loc Mechanically replace: build1_loc (loc, ADDR_EXPR, type, op) with: build_addr_expr_loc (loc, type, op) similarly to the previous build_addr_expr change. Diff: --- gcc/fold-const.c | 2 +- gcc/gimple-fold.c | 17 +++++++++-------- gcc/gimple.h | 5 +++-- gcc/tree-ssa-forwprop.c | 30 ++++++++++++++++-------------- gcc/tree.h | 11 ++++++++++- 5 files changed, 39 insertions(+), 26 deletions(-) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index af8a42e8836..5e76cd33a7b 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8749,7 +8749,7 @@ build_fold_addr_expr_with_type_loc (location_t loc, tree t, tree ptrtype) t = fold_convert_loc (loc, ptrtype, t); } else - t = build1_loc (loc, ADDR_EXPR, ptrtype, t); + t = build_addr_expr_loc (loc, ptrtype, t); return t; } diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index e63371d65c6..5a57fcd97f4 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -218,12 +218,13 @@ canonicalize_constructor_val (tree cval, tree from_decl) { tree ptr = TREE_OPERAND (cval, 0); if (is_gimple_min_invariant (ptr)) - cval = build1_loc (EXPR_LOCATION (cval), - ADDR_EXPR, TREE_TYPE (ptr), - fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (ptr)), - ptr, - fold_convert_for_mem_ref (ptr_type_node, - TREE_OPERAND (cval, 1)))); + cval = build_addr_expr_loc + (EXPR_LOCATION (cval), + TREE_TYPE (ptr), + fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (ptr)), ptr, + fold_convert_for_mem_ref + (ptr_type_node, + TREE_OPERAND (cval, 1)))); } if (ADDR_EXPR_P (cval)) { @@ -6506,8 +6507,8 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree), && TREE_CODE (op1) == INTEGER_CST) { tree off = fold_convert_for_mem_ref (ptr_type_node, op1); - return build1_loc - (loc, ADDR_EXPR, TREE_TYPE (op0), + return build_addr_expr_loc + (loc, TREE_TYPE (op0), fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (op0)), unshare_expr (op0), off)); diff --git a/gcc/gimple.h b/gcc/gimple.h index 6f7c7ff6a5f..c40a22e6d05 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -3135,8 +3135,9 @@ static inline void gimple_call_set_fndecl (gcall *gs, tree decl) { gcc_gimple_checking_assert (!gimple_call_internal_p (gs)); - gs->op[1] = build1_loc (gimple_location (gs), ADDR_EXPR, - build_pointer_type (TREE_TYPE (decl)), decl); + gs->op[1] = build_addr_expr_loc (gimple_location (gs), + build_pointer_type (TREE_TYPE (decl)), + decl); } static inline void diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 50acd8af8b7..e92bb397f3c 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -945,13 +945,14 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, /* Optimize &x[C1] p+ C2 to &x p+ C3 with C3 = C1 * element_size + C2. */ if (TREE_CODE (rhs2) == INTEGER_CST) { - tree new_rhs = build1_loc (gimple_location (use_stmt), - ADDR_EXPR, TREE_TYPE (def_rhs), - fold_build2 (MEM_REF, - TREE_TYPE (TREE_TYPE (def_rhs)), - unshare_expr (def_rhs), - fold_convert (ptr_type_node, - rhs2))); + tree new_rhs = build_addr_expr_loc + (gimple_location (use_stmt), + TREE_TYPE (def_rhs), + fold_build2 (MEM_REF, + TREE_TYPE (TREE_TYPE (def_rhs)), + unshare_expr (def_rhs), + fold_convert (ptr_type_node, + rhs2))); gimple_assign_set_rhs_from_tree (use_stmt_gsi, new_rhs); use_stmt = gsi_stmt (*use_stmt_gsi); update_stmt (use_stmt); @@ -2805,13 +2806,14 @@ pass_forwprop::execute (function *fun) instead of building new trees here. */ && forward_propagate_addr_expr (lhs, - build1_loc (gimple_location (stmt), - ADDR_EXPR, TREE_TYPE (rhs), - fold_build2 (MEM_REF, - TREE_TYPE (TREE_TYPE (rhs)), - rhs, - fold_convert_for_mem_ref - (ptr_type_node, off))), + build_addr_expr_loc + (gimple_location (stmt), + TREE_TYPE (rhs), + fold_build2 (MEM_REF, + TREE_TYPE (TREE_TYPE (rhs)), + rhs, + fold_convert_for_mem_ref + (ptr_type_node, off))), true)) { fwprop_invalidate_lattice (gimple_get_lhs (stmt)); diff --git a/gcc/tree.h b/gcc/tree.h index 4f4af514819..89bda180a87 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4434,7 +4434,7 @@ extern tree build5 (enum tree_code, tree, tree, tree, tree, tree, tree CXX_MEM_STAT_INFO); extern tree build_addr_expr (tree, tree CXX_MEM_STAT_INFO); -/* _loc versions of build[1-5]. */ +/* _loc versions of build[1-5] and build_addr_expr. */ static inline tree build1_loc (location_t loc, enum tree_code code, tree type, @@ -4487,6 +4487,15 @@ build5_loc (location_t loc, enum tree_code code, tree type, tree arg0, return t; } +static inline tree +build_addr_expr_loc (location_t loc, tree type, tree op CXX_MEM_STAT_INFO) +{ + tree t = build_addr_expr (type, op PASS_MEM_STAT); + if (CAN_HAVE_LOCATION_P (t)) + SET_EXPR_LOCATION (t, loc); + return t; +} + /* Constructs double_int from tree CST. */ extern tree double_int_to_tree (tree, double_int);