public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Add build_addr_expr_loc
@ 2022-05-05 12:07 Matthew Malcomson
  0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-05-05 12:07 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9da7c6e34a60bdf9846b1d7af4b50babffa97768

commit 9da7c6e34a60bdf9846b1d7af4b50babffa97768
Author: Richard Sandiford <richard.sandiford@arm.com>
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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-05 12:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 12:07 [gcc(refs/vendors/ARM/heads/morello)] Add build_addr_expr_loc Matthew Malcomson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).