public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Add build_addr_expr
@ 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:b781c384f8ffda4751d32376b50d7dd30542a167
commit b781c384f8ffda4751d32376b50d7dd30542a167
Author: Richard Sandiford <richard.sandiford@arm.com>
Date: Thu Apr 14 15:38:18 2022 +0100
Add build_addr_expr
Mechanically replace:
build1 (ADDR_EXPR, type, op)
with:
build_addr_expr (type, op)
Various other codes already have their own routines, so this
is following existing practice to some extent.
For the benefit of future patches, build_addr_expr internally uses
a new routine:
addr_expr_code (type)
that returns the appropriate tree code for producing a pointer of
the given type.
Diff:
---
gcc/ada/gcc-interface/utils2.c | 24 +++++++--------
gcc/analyzer/region-model.cc | 12 +++-----
gcc/asan.c | 2 +-
gcc/brig/brigfrontend/brig-branch-inst-handler.cc | 2 +-
gcc/brig/brigfrontend/brig-code-entry-handler.cc | 6 ++--
gcc/brig/brigfrontend/brig-function.cc | 2 +-
gcc/brig/brigfrontend/brig-to-generic.cc | 2 +-
gcc/builtins.c | 13 ++++----
gcc/c-family/c-common.c | 8 ++---
gcc/c/c-typeck.c | 4 +--
gcc/c/gimple-parser.c | 2 +-
gcc/config/aarch64/aarch64.c | 2 +-
gcc/config/darwin.c | 8 ++---
gcc/config/i386/i386.c | 4 +--
gcc/config/rs6000/rs6000.c | 7 +++--
gcc/config/sh/sh.c | 8 ++---
gcc/coverage.c | 12 ++++----
gcc/cp/call.c | 4 +--
gcc/cp/class.c | 2 +-
gcc/cp/coroutines.cc | 4 +--
gcc/cp/decl2.c | 7 ++---
gcc/cp/except.c | 2 +-
gcc/cp/init.c | 2 +-
gcc/cp/semantics.c | 2 +-
gcc/cp/typeck.c | 4 +--
gcc/cp/vtable-class-hierarchy.c | 4 +--
gcc/doc/match-and-simplify.texi | 8 ++---
gcc/fold-const.c | 2 +-
gcc/gimple-ssa-warn-restrict.c | 4 +--
gcc/gimple-streamer-out.c | 2 +-
gcc/gimplify.c | 4 +--
gcc/ipa-cp.c | 7 +++--
gcc/ipa-prop.c | 2 +-
gcc/jit/jit-playback.c | 8 ++---
gcc/lto-streamer-out.c | 2 +-
gcc/objc/objc-act.c | 2 +-
gcc/objc/objc-gnu-runtime-abi-01.c | 2 +-
gcc/omp-low.c | 2 +-
gcc/sanopt.c | 2 +-
gcc/tree-inline.c | 2 +-
gcc/tree-profile.c | 4 +--
gcc/tree-ssa-dom.c | 9 +++---
gcc/tree-ssa-forwprop.c | 2 +-
gcc/tree-ssa-loop-im.c | 4 +--
gcc/tree-ssa-loop-ivopts.c | 3 +-
gcc/tree-ssa-sccvn.c | 2 +-
gcc/tree-vect-data-refs.c | 6 ++--
gcc/tree.c | 37 ++++++++++++++++++++---
gcc/tree.h | 2 ++
gcc/ubsan.c | 8 ++---
gcc/varasm.c | 2 +-
gcc/vtable-verify.c | 16 +++++-----
52 files changed, 158 insertions(+), 135 deletions(-)
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index 6df4f6c5cc8..a189b3c5f3a 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -1769,7 +1769,7 @@ build_call_n_expr (tree fndecl, int n, ...)
{
va_list ap;
tree fntype = TREE_TYPE (fndecl);
- tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
+ tree fn = build_addr_expr (build_pointer_type (fntype), fndecl);
va_start (ap, n);
fn = build_call_valist (TREE_TYPE (fntype), fn, n, ap);
@@ -1867,9 +1867,8 @@ build_call_raise (int msg, Node_Id gnat_node, char kind)
return
build_call_n_expr (fndecl, 2,
- build1 (ADDR_EXPR,
- build_pointer_type (char_type_node),
- filename),
+ build_addr_expr (build_pointer_type (char_type_node),
+ filename),
line);
}
@@ -1891,9 +1890,8 @@ build_call_raise_column (int msg, Node_Id gnat_node, char kind)
return
build_call_n_expr (fndecl, 3,
- build1 (ADDR_EXPR,
- build_pointer_type (char_type_node),
- filename),
+ build_addr_expr (build_pointer_type (char_type_node),
+ filename),
line, col);
}
@@ -1916,9 +1914,8 @@ build_call_raise_range (int msg, Node_Id gnat_node, char kind,
return
build_call_n_expr (fndecl, 6,
- build1 (ADDR_EXPR,
- build_pointer_type (char_type_node),
- filename),
+ build_addr_expr (build_pointer_type (char_type_node),
+ filename),
line, col,
convert (integer_type_node, index),
convert (integer_type_node, first),
@@ -2776,9 +2773,10 @@ gnat_rewrite_reference (tree ref, rewrite_fn func, void *data, tree *init)
if (TREE_CODE (t) == NOP_EXPR)
t = TREE_OPERAND (t, 0);
if (ADDR_EXPR_P (t))
- t = build1 (ADDR_EXPR, TREE_TYPE (t),
- gnat_rewrite_reference (TREE_OPERAND (t, 0), func, data,
- init));
+ t = build_addr_expr
+ (TREE_TYPE (t),
+ gnat_rewrite_reference (TREE_OPERAND (t, 0), func, data,
+ init));
else
t = func (t, data);
t = fold_convert (TREE_TYPE (CALL_EXPR_ARG (ref, 0)), t);
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index e02fe0c4dec..65ef720a529 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -1880,9 +1880,7 @@ region_model::get_representative_path_var (const svalue *sval,
{
const region *reg = ptr_sval->get_pointee ();
if (path_var pv = get_representative_path_var (reg, visited))
- return path_var (build1 (ADDR_EXPR,
- sval->get_type (),
- pv.m_tree),
+ return path_var (build_addr_expr (sval->get_type (), pv.m_tree),
pv.m_stack_depth);
}
@@ -3761,8 +3759,8 @@ test_state_merging ()
tree z = build_global_decl ("z", integer_type_node);
tree p = build_global_decl ("p", ptr_type_node);
- tree addr_of_y = build1 (ADDR_EXPR, ptr_type_node, y);
- tree addr_of_z = build1 (ADDR_EXPR, ptr_type_node, z);
+ tree addr_of_y = build_addr_expr (ptr_type_node, y);
+ tree addr_of_z = build_addr_expr (ptr_type_node, z);
auto_vec <tree> param_types;
tree test_fndecl = make_fndecl (integer_type_node, "test_fn", param_types);
@@ -3772,7 +3770,7 @@ test_state_merging ()
tree a = build_decl (UNKNOWN_LOCATION, PARM_DECL,
get_identifier ("a"),
integer_type_node);
- tree addr_of_a = build1 (ADDR_EXPR, ptr_type_node, a);
+ tree addr_of_a = build_addr_expr (ptr_type_node, a);
/* Param "q", a pointer. */
tree q = build_decl (UNKNOWN_LOCATION, PARM_DECL,
@@ -4485,7 +4483,7 @@ test_mem_ref ()
tree p = build_global_decl ("p", int_star);
tree int_17 = build_int_cst (integer_type_node, 17);
- tree addr_of_x = build1 (ADDR_EXPR, int_star, x);
+ tree addr_of_x = build_addr_expr (int_star, x);
tree offset_0 = build_int_cst (integer_type_node, 0);
tree star_p = build2 (MEM_REF, integer_type_node, p, offset_0);
diff --git a/gcc/asan.c b/gcc/asan.c
index e1aabb664de..206aec77c51 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1159,7 +1159,7 @@ asan_pp_string (pretty_printer *pp)
build_index_type (size_int (len)));
TREE_READONLY (ret) = 1;
TREE_STATIC (ret) = 1;
- return build1 (ADDR_EXPR, shadow_ptr_types[0], ret);
+ return build_addr_expr (shadow_ptr_types[0], ret);
}
/* Clear shadow memory at SHADOW_MEM, LEN bytes. Can't call a library call here
diff --git a/gcc/brig/brigfrontend/brig-branch-inst-handler.cc b/gcc/brig/brigfrontend/brig-branch-inst-handler.cc
index e438fcab27e..11520ad632c 100644
--- a/gcc/brig/brigfrontend/brig-branch-inst-handler.cc
+++ b/gcc/brig/brigfrontend/brig-branch-inst-handler.cc
@@ -93,7 +93,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base)
tree element_zero
= build4 (ARRAY_REF, etype, var, integer_zero_node,
NULL_TREE, NULL_TREE);
- var = build1 (ADDR_EXPR, ptype, element_zero);
+ var = build_addr_expr (ptype, element_zero);
}
gcc_assert (var != NULL_TREE);
diff --git a/gcc/brig/brigfrontend/brig-code-entry-handler.cc b/gcc/brig/brigfrontend/brig-code-entry-handler.cc
index ce413069b42..d5bf8300dfe 100644
--- a/gcc/brig/brigfrontend/brig-code-entry-handler.cc
+++ b/gcc/brig/brigfrontend/brig-code-entry-handler.cc
@@ -356,11 +356,11 @@ brig_code_entry_handler::build_address_operand
= build4 (ARRAY_REF, TREE_TYPE (TREE_TYPE (arg_var_decl)),
arg_var_decl, integer_zero_node, NULL_TREE,
NULL_TREE);
- symbol_base = build1 (ADDR_EXPR, ptype, element_zero);
+ symbol_base = build_addr_expr (ptype, element_zero);
}
}
else
- symbol_base = build1 (ADDR_EXPR, ptype, arg_var_decl);
+ symbol_base = build_addr_expr (ptype, arg_var_decl);
}
else
{
@@ -381,7 +381,7 @@ brig_code_entry_handler::build_address_operand
gcc_assert (global_var_decl != NULL_TREE);
tree ptype = build_pointer_type (instr_type);
- symbol_base = build1 (ADDR_EXPR, ptype, global_var_decl);
+ symbol_base = build_addr_expr (ptype, global_var_decl);
}
}
}
diff --git a/gcc/brig/brigfrontend/brig-function.cc b/gcc/brig/brigfrontend/brig-function.cc
index 5332d9a99ca..6d265b803d9 100644
--- a/gcc/brig/brigfrontend/brig-function.cc
+++ b/gcc/brig/brigfrontend/brig-function.cc
@@ -712,7 +712,7 @@ brig_function::emit_launcher_and_metadata ()
else
push_cfun (DECL_STRUCT_FUNCTION (launcher));
- tree kernel_func_ptr = build1 (ADDR_EXPR, ptr_type_node, m_func_decl);
+ tree kernel_func_ptr = build_addr_expr (ptr_type_node, m_func_decl);
tree phsail_launch_kernel_call;
diff --git a/gcc/brig/brigfrontend/brig-to-generic.cc b/gcc/brig/brigfrontend/brig-to-generic.cc
index ccbec59e2e7..c48061b319a 100644
--- a/gcc/brig/brigfrontend/brig-to-generic.cc
+++ b/gcc/brig/brigfrontend/brig-to-generic.cc
@@ -485,7 +485,7 @@ brig_to_generic::add_global_variable (const std::string &name, tree var_decl)
return;
tree ptype = build_pointer_type (TREE_TYPE (var_decl));
- tree var_addr = build1 (ADDR_EXPR, ptype, var_decl);
+ tree var_addr = build_addr_expr (ptype, var_decl);
DECL_INITIAL (host_def_var) = var_addr;
TREE_PUBLIC (host_def_var) = 1;
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 996dee6d6fe..29c96f05e5f 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -2634,7 +2634,7 @@ expand_builtin_cexpi (tree exp, rtx target)
top2 = make_tree (build_pointer_type (TREE_TYPE (arg)), op2a);
/* Make sure not to fold the sincos call again. */
- call = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
+ call = build_addr_expr (build_pointer_type (TREE_TYPE (fn)), fn);
expand_normal (build_call_nary (TREE_TYPE (TREE_TYPE (fn)),
call, 3, arg, top1, top2));
}
@@ -2675,7 +2675,7 @@ expand_builtin_cexpi (tree exp, rtx target)
build_real (type, dconst0), arg);
/* Make sure not to fold the cexp call again. */
- call = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
+ call = build_addr_expr (build_pointer_type (TREE_TYPE (fn)), fn);
return expand_expr (build_call_nary (ctype, call, 1, narg),
target, VOIDmode, EXPAND_NORMAL);
}
@@ -2697,7 +2697,7 @@ build_call_nofold_loc (location_t loc, tree fndecl, int n, ...)
{
va_list ap;
tree fntype = TREE_TYPE (fndecl);
- tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
+ tree fn = build_addr_expr (build_pointer_type (fntype), fndecl);
va_start (ap, n);
fn = build_call_valist (TREE_TYPE (fntype), fn, n, ap);
@@ -7027,8 +7027,8 @@ expand_ifn_atomic_compare_exchange_into_call (gcall *call, machine_mode mode)
if (expd != x)
emit_move_insn (x, expd);
tree v = make_tree (TREE_TYPE (expected), x);
- vec->quick_push (build1 (ADDR_EXPR,
- build_pointer_type (TREE_TYPE (expected)), v));
+ vec->quick_push (build_addr_expr
+ (build_pointer_type (TREE_TYPE (expected)), v));
vec->quick_push (gimple_call_arg (call, 2));
/* Skip the boolean weak parameter. */
for (z = 4; z < 6; z++)
@@ -7040,8 +7040,7 @@ expand_ifn_atomic_compare_exchange_into_call (gcall *call, machine_mode mode)
= (built_in_function) ((int) BUILT_IN_ATOMIC_COMPARE_EXCHANGE_1
+ bytes_log2);
tree fndecl = builtin_decl_explicit (fncode);
- tree fn = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fndecl)),
- fndecl);
+ tree fn = build_addr_expr (build_pointer_type (TREE_TYPE (fndecl)), fndecl);
tree exp = build_call_vec (boolean_type_node, fn, vec);
tree lhs = gimple_call_lhs (call);
rtx boolret = expand_call (exp, NULL_RTX, lhs == NULL_TREE);
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 9571980ec33..428daf4b08f 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -4670,7 +4670,7 @@ build_va_arg (location_t loc, tree expr, tree type)
/* Take the address, to get '&ap'. Note that &ap is not a va_list
type. */
mark_addressable (expr);
- expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (expr)), expr);
+ expr = build_addr_expr (build_pointer_type (TREE_TYPE (expr)), expr);
return build_va_arg_1 (loc, type, expr);
}
@@ -4732,8 +4732,8 @@ build_va_arg (location_t loc, tree expr, tree type)
/* Take the address, to get '&ap'. Make sure it's a pointer to array
elem type. */
mark_addressable (expr);
- expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (canon_va_type)),
- expr);
+ expr = build_addr_expr (build_pointer_type (TREE_TYPE (canon_va_type)),
+ expr);
/* Verify that &ap is still recognized as having va_list type. */
tree canon_expr_type
@@ -5171,7 +5171,7 @@ finish_label_address_expr (tree label, location_t loc)
else
{
TREE_USED (label) = 1;
- result = build1 (ADDR_EXPR, ptr_type_node, label);
+ result = build_addr_expr (ptr_type_node, label);
/* The current function is not necessarily uninlinable.
Computed gotos are incompatible with inlining, but the value
here could be used only in a diagnostic, for example. */
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 3b33cc98e72..883ff00eb15 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -4910,7 +4910,7 @@ build_unary_op (location_t location, enum tree_code code, tree xarg,
goto return_build_unary_op;
}
- val = build1 (ADDR_EXPR, argtype, arg);
+ val = build_addr_expr (argtype, arg);
ret = val;
goto return_build_unary_op;
@@ -6945,7 +6945,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
}
if (!c_mark_addressable (rhs))
return error_mark_node;
- rhs = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (rhs)), rhs);
+ rhs = build_addr_expr (build_pointer_type (TREE_TYPE (rhs)), rhs);
SET_EXPR_LOCATION (rhs, location);
rhs = convert_for_assignment (location, expr_loc,
diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c
index 57d041a6109..f9c1530c89f 100644
--- a/gcc/c/gimple-parser.c
+++ b/gcc/c/gimple-parser.c
@@ -1625,7 +1625,7 @@ c_parser_gimple_postfix_expression (gimple_parser &parser)
return expr;
}
if (addr_p)
- val = build1 (ADDR_EXPR, type, val);
+ val = build_addr_expr (type, val);
if (neg_p)
{
val = const_unop (NEGATE_EXPR, TREE_TYPE (val), val);
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index c42eca5c0e9..9488204124e 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -17717,7 +17717,7 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
/* *(field_ptr_t)&ha = *((field_ptr_t)vr_saved_area */
TREE_ADDRESSABLE (tmp_ha) = 1;
- tmp_ha = build1 (ADDR_EXPR, field_ptr_t, tmp_ha);
+ tmp_ha = build_addr_expr (field_ptr_t, tmp_ha);
addr = t;
t = fold_convert (field_ptr_t, addr);
t = build2 (MODIFY_EXPR, field_t,
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index db8cec27b63..fe7a1f56745 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3635,8 +3635,8 @@ darwin_build_constant_cfstring (tree str)
/* isa *. */
field = TYPE_FIELDS (ccfstring_type_node);
CONSTRUCTOR_APPEND_ELT(v, NULL_TREE,
- build1 (ADDR_EXPR, TREE_TYPE (field),
- cfstring_class_reference));
+ build_addr_expr (TREE_TYPE (field),
+ cfstring_class_reference));
/* flags */
field = DECL_CHAIN (field);
CONSTRUCTOR_APPEND_ELT(v, NULL_TREE,
@@ -3644,7 +3644,7 @@ darwin_build_constant_cfstring (tree str)
/* string *. */
field = DECL_CHAIN (field);
CONSTRUCTOR_APPEND_ELT(v, NULL_TREE,
- build1 (ADDR_EXPR, TREE_TYPE (field), str));
+ build_addr_expr (TREE_TYPE (field), str));
/* length */
field = DECL_CHAIN (field);
CONSTRUCTOR_APPEND_ELT(v, NULL_TREE,
@@ -3673,7 +3673,7 @@ darwin_build_constant_cfstring (tree str)
desc->constructor = var;
}
- addr = build1 (ADDR_EXPR, pccfstring_type_node, desc->constructor);
+ addr = build_addr_expr (pccfstring_type_node, desc->constructor);
TREE_CONSTANT (addr) = 1;
return addr;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 37e77ea9fdd..e07de05fd64 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4439,7 +4439,7 @@ ix86_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p,
tree temp = create_tmp_var (type, "va_arg_tmp");
/* addr = &temp; */
- t = build1 (ADDR_EXPR, build_pointer_type (type), temp);
+ t = build_addr_expr (build_pointer_type (type), temp);
gimplify_assign (addr, t, pre_p);
for (i = 0; i < XVECLEN (container, 0); i++)
@@ -22309,7 +22309,7 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update)
tree fenv_var = create_tmp_var_raw (fenv_type);
TREE_ADDRESSABLE (fenv_var) = 1;
tree fenv_ptr = build_pointer_type (fenv_type);
- tree fenv_addr = build1 (ADDR_EXPR, fenv_ptr, fenv_var);
+ tree fenv_addr = build_addr_expr (fenv_ptr, fenv_var);
fenv_addr = fold_convert (ptr_type_node, fenv_addr);
tree fnstenv = get_ix86_builtin (IX86_BUILTIN_FNSTENV);
tree fldenv = get_ix86_builtin (IX86_BUILTIN_FLDENV);
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 1c1caa90ede..d1a11ce8383 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -26420,9 +26420,10 @@ rs6000_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update)
tree fenv_var = create_tmp_var_raw (double_type_node);
TREE_ADDRESSABLE (fenv_var) = 1;
- tree fenv_addr = build1 (ADDR_EXPR, double_ptr_type_node,
- build4 (TARGET_EXPR, double_type_node, fenv_var,
- void_node, NULL_TREE, NULL_TREE));
+ tree fenv_addr = build_addr_expr
+ (double_ptr_type_node,
+ build4 (TARGET_EXPR, double_type_node, fenv_var,
+ void_node, NULL_TREE, NULL_TREE));
*hold = build_call_expr (atomic_hold_decl, 1, fenv_addr);
*clear = build_call_expr (atomic_clear_decl, 0);
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 84c0ea025b4..bf6a32de71c 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -7740,7 +7740,7 @@ sh_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
tree cmp;
bool is_double = size == 8 && TREE_CODE (eff_type) == REAL_TYPE;
- tmp = build1 (ADDR_EXPR, pptr_type_node, unshare_expr (next_fp));
+ tmp = build_addr_expr (pptr_type_node, unshare_expr (next_fp));
gimplify_assign (unshare_expr (addr), tmp, pre_p);
gimplify_assign (unshare_expr (next_fp_tmp), valist, pre_p);
@@ -7795,7 +7795,7 @@ sh_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
tmp = build1 (LABEL_EXPR, void_type_node, unshare_expr (lab_false));
gimplify_and_add (tmp, pre_p);
- tmp = build1 (ADDR_EXPR, pptr_type_node, unshare_expr (next_stack));
+ tmp = build_addr_expr (pptr_type_node, unshare_expr (next_stack));
gimplify_assign (unshare_expr (addr), tmp, pre_p);
gimplify_assign (unshare_expr (next_fp_tmp),
unshare_expr (valist), pre_p);
@@ -7815,7 +7815,7 @@ sh_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
NULL_TREE);
gimplify_and_add (tmp, pre_p);
- tmp = build1 (ADDR_EXPR, pptr_type_node, unshare_expr (next_o));
+ tmp = build_addr_expr (pptr_type_node, unshare_expr (next_o));
gimplify_assign (unshare_expr (addr), tmp, pre_p);
tmp = build1 (GOTO_EXPR, void_type_node, unshare_expr (lab_over));
@@ -7828,7 +7828,7 @@ sh_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
gimplify_assign (unshare_expr (next_o),
unshare_expr (next_o_limit), pre_p);
- tmp = build1 (ADDR_EXPR, pptr_type_node, unshare_expr (next_stack));
+ tmp = build_addr_expr (pptr_type_node, unshare_expr (next_stack));
gimplify_assign (unshare_expr (addr), tmp, pre_p);
}
diff --git a/gcc/coverage.c b/gcc/coverage.c
index f353c9c5022..37f7273e00b 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -845,7 +845,7 @@ build_fn_info (const struct coverage_data *data, tree type, tree key)
/* key */
CONSTRUCTOR_APPEND_ELT (v1, fields,
- build1 (ADDR_EXPR, TREE_TYPE (fields), key));
+ build_addr_expr (TREE_TYPE (fields), key));
fields = DECL_CHAIN (fields);
/* ident */
@@ -999,8 +999,8 @@ build_info (tree info_type, tree fn_ary)
TREE_TYPE (filename_string) = build_array_type
(char_type_node, build_index_type (size_int (da_file_name_len)));
CONSTRUCTOR_APPEND_ELT (v1, info_fields,
- build1 (ADDR_EXPR, TREE_TYPE (info_fields),
- filename_string));
+ build_addr_expr (TREE_TYPE (info_fields),
+ filename_string));
info_fields = DECL_CHAIN (info_fields);
/* merge fn array -- NULL slots indicate unmeasured counters */
@@ -1021,7 +1021,7 @@ build_info (tree info_type, tree fn_ary)
TREE_NOTHROW (merge_fn) = 1;
/* Initialize assembler name so we can stream out. */
DECL_ASSEMBLER_NAME (merge_fn);
- ptr = build1 (ADDR_EXPR, merge_fn_type, merge_fn);
+ ptr = build_addr_expr (merge_fn_type, merge_fn);
}
CONSTRUCTOR_APPEND_ELT (v2, NULL, ptr);
}
@@ -1038,7 +1038,7 @@ build_info (tree info_type, tree fn_ary)
/* functions */
CONSTRUCTOR_APPEND_ELT (v1, info_fields,
- build1 (ADDR_EXPR, TREE_TYPE (info_fields), fn_ary));
+ build_addr_expr (TREE_TYPE (info_fields), fn_ary));
info_fields = DECL_CHAIN (info_fields);
gcc_assert (!info_fields);
@@ -1171,7 +1171,7 @@ coverage_obj_fn (vec<constructor_elt, va_gc> *ctor, tree fn,
varpool_node::finalize_decl (var);
CONSTRUCTOR_APPEND_ELT (ctor, NULL,
- build1 (ADDR_EXPR, gcov_fn_info_ptr_type, var));
+ build_addr_expr (gcov_fn_info_ptr_type, var));
return ctor;
}
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 90e72c827d3..8e4bb0d6414 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8004,7 +8004,7 @@ convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain)
"passing objects of non-trivially-copyable "
"type %q#T through %<...%> is conditionally supported",
arg_type);
- return build1 (ADDR_EXPR, build_reference_type (arg_type), arg);
+ return build_addr_expr (build_reference_type (arg_type), arg);
}
/* Build up a real lvalue-to-rvalue conversion in case the
copy constructor is trivial but not callable. */
@@ -8211,7 +8211,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain)
;
/* Pass classes with copy ctors by invisible reference. */
else if (TREE_ADDRESSABLE (type))
- val = build1 (ADDR_EXPR, build_reference_type (type), val);
+ val = build_addr_expr (build_reference_type (type), val);
else if (targetm.calls.promote_prototypes (NULL_TREE)
&& INTEGRAL_TYPE_P (type)
&& COMPLETE_TYPE_P (type)
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 4658e248119..07881cecd0c 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -9650,7 +9650,7 @@ dfs_accumulate_vtbl_inits (tree binfo,
&non_fn_entries, l);
/* Figure out the position to which the VPTR should point. */
- vtbl = build1 (ADDR_EXPR, vtbl_ptr_type_node, orig_vtbl);
+ vtbl = build_addr_expr (vtbl_ptr_type_node, orig_vtbl);
index = size_binop (MULT_EXPR,
TYPE_SIZE_UNIT (vtable_entry_type),
size_int (non_fn_entries + n_inits));
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 3e5e55118ce..e89a71de1a1 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -4391,7 +4391,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
/* Put the resumer and destroyer functions in. */
- tree actor_addr = build1 (ADDR_EXPR, act_des_fn_ptr, actor);
+ tree actor_addr = build_addr_expr (act_des_fn_ptr, actor);
tree resume_m
= lookup_member (coro_frame_type, resume_name,
/*protect=*/1, /*want_type=*/0, tf_warning_or_error);
@@ -4401,7 +4401,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
r = coro_build_cvt_void_expr_stmt (r, fn_start);
add_stmt (r);
- tree destroy_addr = build1 (ADDR_EXPR, act_des_fn_ptr, destroy);
+ tree destroy_addr = build_addr_expr (act_des_fn_ptr, destroy);
tree destroy_m
= lookup_member (coro_frame_type, destroy_name,
/*protect=*/1, /*want_type=*/0, tf_warning_or_error);
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b348d5dbb95..2d68a213b6c 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3333,7 +3333,7 @@ build_atomic_load_byte (tree src, HOST_WIDE_INT model)
fncode = BUILT_IN_ATOMIC_LOAD_N + exact_log2 (size) + 1;
t = builtin_decl_implicit ((enum built_in_function) fncode);
- addr = build1 (ADDR_EXPR, ptr_type, src);
+ addr = build_addr_expr (ptr_type, src);
val = build_call_expr (t, 2, addr, mem_model);
return val;
}
@@ -3348,9 +3348,8 @@ get_guard_bits (tree guard)
{
/* We only set the first byte of the guard, in order to leave room
for a mutex in the high-order bits. */
- guard = build1 (ADDR_EXPR,
- build_pointer_type (TREE_TYPE (guard)),
- guard);
+ guard = build_addr_expr (build_pointer_type (TREE_TYPE (guard)),
+ guard);
guard = build1 (NOP_EXPR,
build_pointer_type (char_type_node),
guard);
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 4a7abd72148..65139dabc8f 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -765,7 +765,7 @@ build_throw (location_t loc, tree exp)
{
cxx_mark_addressable (dtor_fn);
/* Pretend it's a normal function. */
- cleanup = build1 (ADDR_EXPR, cleanup_type, dtor_fn);
+ cleanup = build_addr_expr (cleanup_type, dtor_fn);
}
}
if (cleanup == NULL_TREE)
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 615b1f23b07..9ba7bf7c428 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1405,7 +1405,7 @@ build_vtbl_address (tree binfo)
/* Now compute the address to use when initializing the vptr. */
vtbl = unshare_expr (BINFO_VTABLE (binfo_for));
if (VAR_P (vtbl))
- vtbl = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (vtbl)), vtbl);
+ vtbl = build_addr_expr (build_pointer_type (TREE_TYPE (vtbl)), vtbl);
return vtbl;
}
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 69cf1aa4125..0e18aa20808 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -4368,7 +4368,7 @@ simplify_aggr_init_expr (tree *tp)
slot. */
cxx_mark_addressable (slot);
CALL_EXPR_ARG (call_expr, 0) =
- build1 (ADDR_EXPR, build_pointer_type (type), slot);
+ build_addr_expr (build_pointer_type (type), slot);
}
else if (style == arg)
{
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 0cba1f71aaa..ff4ee7dbfa1 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6347,7 +6347,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
address of a function is a no-op, so just return the
argument. */
if (type_unknown_p (arg))
- return build1 (ADDR_EXPR, unknown_type_node, arg);
+ return build_addr_expr (unknown_type_node, arg);
if (TREE_CODE (arg) == OFFSET_REF)
/* We want a pointer to member; bypass all the code for actually taking
@@ -6988,7 +6988,7 @@ unary_complex_lvalue (enum tree_code code, tree arg)
targ = arg;
else
targ = build_cplus_new (TREE_TYPE (arg), arg, tf_warning_or_error);
- return build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg)), targ);
+ return build_addr_expr (build_pointer_type (TREE_TYPE (arg)), targ);
}
if (TREE_CODE (arg) == SAVE_EXPR && INDIRECT_REF_P (targ))
diff --git a/gcc/cp/vtable-class-hierarchy.c b/gcc/cp/vtable-class-hierarchy.c
index ddf5d4df7a9..6ca83a88af3 100644
--- a/gcc/cp/vtable-class-hierarchy.c
+++ b/gcc/cp/vtable-class-hierarchy.c
@@ -801,7 +801,7 @@ insert_call_to_register_set (tree class_name,
relayout_decl (array_arg);
varpool_node::finalize_decl (array_arg);
- arg3 = build1 (ADDR_EXPR, TYPE_POINTER_TO (TREE_TYPE (array_arg)), array_arg);
+ arg3 = build_addr_expr (TYPE_POINTER_TO (TREE_TYPE (array_arg)), array_arg);
TREE_TYPE (arg3) = build_pointer_type (TREE_TYPE (array_arg));
@@ -923,7 +923,7 @@ register_all_pairs (tree body)
str1 = build_string_from_id (DECL_NAME (base_ptr_var_decl));
new_type = build_pointer_type (TREE_TYPE (base_ptr_var_decl));
- arg1 = build1 (ADDR_EXPR, new_type, base_ptr_var_decl);
+ arg1 = build_addr_expr (new_type, base_ptr_var_decl);
/* We need a fresh vector for each iteration. */
if (vtbl_ptr_array)
diff --git a/gcc/doc/match-and-simplify.texi b/gcc/doc/match-and-simplify.texi
index 8752bd2afe1..0f13f58eaa1 100644
--- a/gcc/doc/match-and-simplify.texi
+++ b/gcc/doc/match-and-simplify.texi
@@ -210,10 +210,10 @@ Captures can also be used for capturing results of sub-expressions.
off += tree_to_uhwi (@@1);
/* Now with that we should be able to simply write
(addr (mem_ref (addr @@base) (plus @@off @@1))) */
- build1 (ADDR_EXPR, type,
- build2 (MEM_REF, TREE_TYPE (TREE_TYPE (@@2)),
- build_fold_addr_expr (base),
- build_int_cst (ptr_type_node, off)));
+ build_addr_expr (type,
+ build2 (MEM_REF, TREE_TYPE (TREE_TYPE (@@2)),
+ build_fold_addr_expr (base),
+ build_int_cst (ptr_type_node, off)));
@})
#endif
@end smallexample
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index dfcb6d09a4f..af8a42e8836 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -10492,7 +10492,7 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type,
if (!base)
return NULL_TREE;
return fold_build2 (MEM_REF, type,
- build1 (ADDR_EXPR, TREE_TYPE (arg0), base),
+ build_addr_expr (TREE_TYPE (arg0), base),
maybe_cap_int_const_binop (PLUS_EXPR, arg1, size_int (coffset)));
}
diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c
index 6c1534e01df..370185845d3 100644
--- a/gcc/gimple-ssa-warn-restrict.c
+++ b/gcc/gimple-ssa-warn-restrict.c
@@ -758,7 +758,7 @@ builtin_access::builtin_access (gimple *call, builtin_memref &dst,
{
addr = dst.base;
if (!POINTER_TYPE_P (TREE_TYPE (addr)))
- addr = build1 (ADDR_EXPR, (TREE_TYPE (addr)), addr);
+ addr = build_addr_expr (TREE_TYPE (addr), addr);
if (tree dstsize = compute_objsize (addr, ostype))
dst.basesize = wi::to_offset (dstsize);
@@ -772,7 +772,7 @@ builtin_access::builtin_access (gimple *call, builtin_memref &dst,
{
addr = src.base;
if (!POINTER_TYPE_P (TREE_TYPE (addr)))
- addr = build1 (ADDR_EXPR, (TREE_TYPE (addr)), addr);
+ addr = build_addr_expr (TREE_TYPE (addr), addr);
if (tree srcsize = compute_objsize (addr, ostype))
src.basesize = wi::to_offset (srcsize);
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index 822bdbc321f..2c92d4dc3bc 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -153,7 +153,7 @@ output_gimple_stmt (struct output_block *ob, struct function *fn, gimple *stmt)
bool volatilep = TREE_THIS_VOLATILE (*basep);
tree ptrtype = build_pointer_type (TREE_TYPE (*basep));
*basep = build2 (MEM_REF, TREE_TYPE (*basep),
- build1 (ADDR_EXPR, ptrtype, *basep),
+ build_addr_expr (ptrtype, *basep),
build_int_cst (ptrtype, 0));
TREE_THIS_VOLATILE (*basep) = volatilep;
}
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index f7725dee1ee..17c8eaa42e3 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2741,7 +2741,7 @@ canonicalize_addr_expr (tree *expr_p)
*expr_p = build4 (ARRAY_REF, ddatype, TREE_OPERAND (addr_expr, 0),
TYPE_MIN_VALUE (TYPE_DOMAIN (datype)),
NULL_TREE, NULL_TREE);
- *expr_p = build1 (ADDR_EXPR, pddatype, *expr_p);
+ *expr_p = build_addr_expr (pddatype, *expr_p);
/* We can have stripped a required restrict qualifier above. */
if (!useless_type_conversion_p (TREE_TYPE (expr), TREE_TYPE (*expr_p)))
@@ -3400,7 +3400,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
{
tree variant = omp_resolve_declare_variant (fndecl);
if (variant != fndecl)
- CALL_EXPR_FN (*expr_p) = build1 (ADDR_EXPR, fnptrtype, variant);
+ CALL_EXPR_FN (*expr_p) = build_addr_expr (fnptrtype, variant);
}
/* There is a sequence point before the call, so any side effects in
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 176db54ee28..d37c961967c 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -1360,9 +1360,10 @@ ipa_get_jf_ancestor_result (struct ipa_jump_func *jfunc, tree input)
if (known_eq (off, 0))
return input;
poly_int64 byte_offset = exact_div (off, BITS_PER_UNIT);
- return build1 (ADDR_EXPR, TREE_TYPE (input),
- fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (input)), input,
- build_int_cst (ptr_type_node, byte_offset)));
+ return build_addr_expr
+ (TREE_TYPE (input),
+ fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (input)), input,
+ build_int_cst (ptr_type_node, byte_offset)));
}
else
return NULL_TREE;
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index b33c0c5c695..01436329b9c 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -4625,7 +4625,7 @@ ipa_read_jump_function (class lto_input_block *ib,
{
tree t = stream_read_tree (ib, data_in);
if (flag && prevails)
- t = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (t)), t);
+ t = build_addr_expr (build_pointer_type (TREE_TYPE (t)), t);
ipa_set_jf_constant (jump_func, t, cs);
}
break;
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index 3a4f6865c96..bae21110cfb 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -685,7 +685,7 @@ new_string_literal (const char *value)
/* Convert to (const char*), loosely based on
c/c-typeck.c: array_to_pointer_conversion,
by taking address of start of string. */
- tree t_addr = build1 (ADDR_EXPR, m_const_char_ptr, t_str);
+ tree t_addr = build_addr_expr (m_const_char_ptr, t_str);
return new rvalue (this, t_addr);
}
@@ -983,7 +983,7 @@ new_call (location *loc,
tree fntype = TREE_TYPE (fndecl);
- tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
+ tree fn = build_addr_expr (build_pointer_type (fntype), fndecl);
return build_call (loc, fn, args, require_tail_call);
}
@@ -1320,7 +1320,7 @@ get_address (location *loc)
tree t_lvalue = as_tree ();
tree t_thistype = TREE_TYPE (t_lvalue);
tree t_ptrtype = build_pointer_type (t_thistype);
- tree ptr = build1 (ADDR_EXPR, t_ptrtype, t_lvalue);
+ tree ptr = build_addr_expr (t_ptrtype, t_lvalue);
if (loc)
get_context ()->set_tree_location (ptr, loc);
if (mark_addressable (loc))
@@ -1454,7 +1454,7 @@ playback::function::get_address (location *loc)
{
tree t_fndecl = as_fndecl ();
tree t_fntype = TREE_TYPE (t_fndecl);
- tree t_fnptr = build1 (ADDR_EXPR, build_pointer_type (t_fntype), t_fndecl);
+ tree t_fnptr = build_addr_expr (build_pointer_type (t_fntype), t_fndecl);
if (loc)
m_ctxt->set_tree_location (t_fnptr, loc);
return new rvalue (m_ctxt, t_fnptr);
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index ded9ae1e248..8768f46d73e 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -2552,7 +2552,7 @@ wrap_refs (tree *tp, int *ws, void *)
tree decl = TREE_OPERAND (t, 0);
tree ptrtype = build_pointer_type (TREE_TYPE (decl));
TREE_OPERAND (t, 0) = build2 (MEM_REF, TREE_TYPE (decl),
- build1 (ADDR_EXPR, ptrtype, decl),
+ build_addr_expr (ptrtype, decl),
build_int_cst (ptrtype, 0));
TREE_THIS_VOLATILE (TREE_OPERAND (t, 0)) = TREE_THIS_VOLATILE (decl);
*ws = 0;
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 27842c3ca03..e3e1831fe61 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -3115,7 +3115,7 @@ my_build_string_pointer (int len, const char *str)
{
tree string = my_build_string (len, str);
tree ptrtype = build_pointer_type (TREE_TYPE (TREE_TYPE (string)));
- return build1 (ADDR_EXPR, ptrtype, string);
+ return build_addr_expr (ptrtype, string);
}
hashval_t
diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c
index d5862435c29..7adf7e6b40f 100644
--- a/gcc/objc/objc-gnu-runtime-abi-01.c
+++ b/gcc/objc/objc-gnu-runtime-abi-01.c
@@ -1772,7 +1772,7 @@ handle_class_ref (tree chain)
/* Make a decl for the address. */
sprintf (string, "__objc_class_ref_%s", name);
- exp = build1 (ADDR_EXPR, string_type_node, decl);
+ exp = build_addr_expr (string_type_node, decl);
decl = build_decl (input_location,
VAR_DECL, get_identifier (string), string_type_node);
TREE_STATIC (decl) = 1;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 29cc8fa5128..2d07e19313e 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -4149,7 +4149,7 @@ lower_rec_simd_input_clauses (tree new_var, omp_context *ctx,
TREE_ADDRESSABLE (ivar) = 1;
DECL_ATTRIBUTES (ivar) = tree_cons (get_identifier ("omp simt private"),
NULL, DECL_ATTRIBUTES (ivar));
- sctx->simt_eargs.safe_push (build1 (ADDR_EXPR, ptype, ivar));
+ sctx->simt_eargs.safe_push (build_addr_expr (ptype, ivar));
tree clobber = build_clobber (type);
gimple *g = gimple_build_assign (ivar, clobber);
gimple_seq_add_stmt (&sctx->simt_dlist, g);
diff --git a/gcc/sanopt.c b/gcc/sanopt.c
index d23864ac758..c62ac2b2f1e 100644
--- a/gcc/sanopt.c
+++ b/gcc/sanopt.c
@@ -544,7 +544,7 @@ maybe_optimize_ubsan_ptr_ifn (sanopt_ctx *ctx, gimple *stmt)
bool sign_expr_offset = !wi::neg_p (expr_offset);
tree base_addr
- = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (base)), base);
+ = build_addr_expr (build_pointer_type (TREE_TYPE (base)), base);
bool add = false;
if (sign_cur_offset == sign_expr_offset)
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index ab0f9b3ba44..89f3f6a05fe 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -5113,7 +5113,7 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id,
for (tree *pvar = vars->begin (); pvar != vars->end (); pvar++)
{
tree ptrtype = build_pointer_type (TREE_TYPE (*pvar));
- newargs.quick_push (build1 (ADDR_EXPR, ptrtype, *pvar));
+ newargs.quick_push (build_addr_expr (ptrtype, *pvar));
}
gcall *g = gimple_build_call_internal_vec (IFN_GOMP_SIMT_ENTER, newargs);
gimple_call_set_lhs (g, gimple_call_lhs (simtenter_stmt));
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index eb0cd3dacd5..f7edf9a5998 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -526,8 +526,8 @@ gimple_gen_time_profiler (unsigned tag)
{
tree ptr = make_temp_ssa_name (build_pointer_type (type), NULL,
"time_profiler_counter_ptr");
- tree addr = build1 (ADDR_EXPR, TREE_TYPE (ptr),
- tree_time_profiler_counter);
+ tree addr = build_addr_expr (TREE_TYPE (ptr),
+ tree_time_profiler_counter);
gassign *assign = gimple_build_assign (ptr, NOP_EXPR, addr);
gsi_insert_before (&gsi, assign, GSI_NEW_STMT);
tree f = builtin_decl_explicit (LONG_LONG_TYPE_SIZE > 32
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 3a75e5af7e9..eb2741cdb9f 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1724,10 +1724,11 @@ record_equivalences_from_stmt (gimple *stmt, int may_optimize_p,
tree op0 = gimple_assign_rhs1 (stmt);
tree op1 = gimple_assign_rhs2 (stmt);
tree new_rhs
- = build1 (ADDR_EXPR, TREE_TYPE (op0),
- fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (op0)),
- unshare_expr (op0),
- fold_convert_for_mem_ref (ptr_type_node, op1)));
+ = build_addr_expr
+ (TREE_TYPE (op0),
+ fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (op0)),
+ unshare_expr (op0),
+ fold_convert_for_mem_ref (ptr_type_node, op1)));
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "==== ASGN ");
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 8ad9a4f00ce..50acd8af8b7 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -735,7 +735,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
if (TREE_CODE (new_def_rhs) == MEM_REF
&& !is_gimple_mem_ref_addr (TREE_OPERAND (new_def_rhs, 0)))
return false;
- new_def_rhs = build1 (ADDR_EXPR, TREE_TYPE (rhs), new_def_rhs);
+ new_def_rhs = build_addr_expr (TREE_TYPE (rhs), new_def_rhs);
/* Recurse. If we could propagate into all uses of lhs do not
bother to replace into the current use but just pretend we did. */
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index f87c287d742..8ddbb6e34af 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -1532,8 +1532,8 @@ gather_mem_refs_stmt (class loop *loop, gimple *stmt)
tree ref_alias_type = reference_alias_ptr_type (*mem);
unsigned int ref_align = get_object_alignment (*mem);
tree ref_type = TREE_TYPE (*mem);
- tree tmp = build1 (ADDR_EXPR, ptr_type_node,
- unshare_expr (mem_base));
+ tree tmp = build_addr_expr (ptr_type_node,
+ unshare_expr (mem_base));
if (TYPE_ALIGN (ref_type) != ref_align)
ref_type = build_aligned_type (ref_type, ref_align);
(*slot)->mem.ref
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 2eb92337510..0148a1fdee7 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -4319,8 +4319,7 @@ force_expr_to_var_cost (tree expr, bool speed)
x = produce_memory_decl_rtl (var, NULL);
SET_DECL_RTL (var, x);
- addr = build1 (ADDR_EXPR, type, var);
-
+ addr = build_addr_expr (type, var);
for (i = 0; i < 2; i++)
{
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 0a768fcd901..911de2c151b 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -923,7 +923,7 @@ copy_reference_ops_from_ref (tree ref, vec<vn_reference_op_s> *result)
temp.off = 0;
result->safe_push (temp);
temp.opcode = ADDR_EXPR;
- temp.op0 = build1 (ADDR_EXPR, TREE_TYPE (temp.op0), ref);
+ temp.op0 = build_addr_expr (TREE_TYPE (temp.op0), ref);
temp.type = TREE_TYPE (temp.op0);
temp.off = -1;
break;
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 88c5faed20d..9a42f5ace1a 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4608,9 +4608,9 @@ vect_create_addr_base_for_vector_ref (vec_info *vinfo, stmt_vec_info stmt_info,
addr_base = fold_build_pointer_plus (data_ref_base, base_offset);
else
{
- addr_base = build1 (ADDR_EXPR,
- build_pointer_type (TREE_TYPE (DR_REF (dr))),
- unshare_expr (DR_REF (dr)));
+ addr_base = build_addr_expr
+ (build_pointer_type (TREE_TYPE (DR_REF (dr))),
+ unshare_expr (DR_REF (dr)));
}
vect_ptr_type = build_pointer_type (STMT_VINFO_VECTYPE (stmt_info));
diff --git a/gcc/tree.c b/gcc/tree.c
index 61b60083eec..40cad1e6c86 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5004,6 +5004,15 @@ build5 (enum tree_code code, tree tt, tree arg0, tree arg1,
return t;
}
+/* Build a tree that takes the address of OP, producing a pointer or
+ reference of type TYPE. */
+
+tree
+build_addr_expr (tree type, tree op CXX_MEM_STAT_INFO)
+{
+ return build1 (addr_expr_code (type), type, op PASS_MEM_STAT);
+}
+
/* Build a simple MEM_REF tree with the sematics of a plain INDIRECT_REF
on the pointer PTR. */
@@ -5057,7 +5066,7 @@ build_invariant_address (tree type, tree base, poly_int64 offset)
tree ref = fold_build2 (MEM_REF, TREE_TYPE (type),
build_fold_addr_expr (base),
build_int_cst (ptr_type_node, offset));
- tree addr = build1 (ADDR_EXPR, type, ref);
+ tree addr = build_addr_expr (type, ref);
recompute_tree_invariant_for_addr_expr (addr);
return addr;
}
@@ -11688,7 +11697,7 @@ tree
build_call_expr_loc_array (location_t loc, tree fndecl, int n, tree *argarray)
{
tree fntype = TREE_TYPE (fndecl);
- tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
+ tree fn = build_addr_expr (build_pointer_type (fntype), fndecl);
return fold_build_call_array_loc (loc, TREE_TYPE (fntype), fn, n, argarray);
}
@@ -11867,9 +11876,9 @@ build_string_literal (unsigned len, const char *str /* = NULL */,
TREE_STATIC (t) = 1;
type = build_pointer_type (eltype);
- t = build1 (ADDR_EXPR, type,
- build4 (ARRAY_REF, eltype,
- t, integer_zero_node, NULL_TREE, NULL_TREE));
+ t = build_addr_expr (type,
+ build4 (ARRAY_REF, eltype,
+ t, integer_zero_node, NULL_TREE, NULL_TREE));
return t;
}
@@ -14168,6 +14177,24 @@ valid_capability_code_p (tree_code tc)
}
}
+/* Return the *ADDR_EXPR code that should be used if the type of the
+ result is required to be RES_TYPE. */
+
+tree_code
+addr_expr_code (const_tree res_type)
+{
+ /* MORELLO TODO: We should be able to assert this, but further changes
+ are needed elsewhere first. */
+#if 0
+ gcc_assert (POINTER_TYPE_P (res_type));
+#else
+ if (!POINTER_TYPE_P (res_type))
+ res_type = ptr_type_node;
+ (void) res_type;
+#endif
+ return ADDR_EXPR;
+}
+
/* Return the machine mode of T. For vectors, returns the mode of the
inner type. The main use case is to feed the result to HONOR_NANS,
avoiding the BLKmode that a direct TYPE_MODE (T) might return. */
diff --git a/gcc/tree.h b/gcc/tree.h
index bcbf1cde876..4f4af514819 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2034,6 +2034,7 @@ extern tree fold_drop_capability (tree);
extern tree build_replace_address_value_loc (location_t, tree, tree);
extern tree build_cap_global_data_get_loc (location_t, tree);
extern bool valid_capability_code_p (tree_code);
+extern tree_code addr_expr_code (const_tree);
extern scalar_addr_mode pointer_address_mode (const_tree);
extern scalar_addr_mode unqualified_address_mode (const_tree);
@@ -4431,6 +4432,7 @@ extern tree build4 (enum tree_code, tree, tree, tree, tree,
tree CXX_MEM_STAT_INFO);
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]. */
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 4b6ce85e2e5..ce0b8542137 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -1480,8 +1480,7 @@ maybe_instrument_pointer_overflow (gimple_stmt_iterator *gsi, tree t)
tree base_addr = base;
if (decl_p)
- base_addr = build1 (ADDR_EXPR,
- build_pointer_type (TREE_TYPE (base)), base);
+ base_addr = build_addr_expr (build_pointer_type (TREE_TYPE (base)), base);
t = offset;
if (maybe_ne (bytepos, 0))
{
@@ -2114,7 +2113,7 @@ instrument_object_size (gimple_stmt_iterator *gsi, tree t, bool is_lhs)
base = TREE_OPERAND (inner, 0);
else
return;
- tree ptr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (t)), t);
+ tree ptr = build_addr_expr (build_pointer_type (TREE_TYPE (t)), t);
while (TREE_CODE (base) == SSA_NAME)
{
@@ -2143,8 +2142,7 @@ instrument_object_size (gimple_stmt_iterator *gsi, tree t, bool is_lhs)
tree base_addr = base;
gimple *bos_stmt = NULL;
if (decl_p)
- base_addr = build1 (ADDR_EXPR,
- build_pointer_type (TREE_TYPE (base)), base);
+ base_addr = build_addr_expr (build_pointer_type (TREE_TYPE (base)), base);
unsigned HOST_WIDE_INT size;
if (compute_builtin_object_size (base_addr, 0, &size))
sizet = build_int_cst (sizetype, size);
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 42799e9072e..48f91ed9e74 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -5124,7 +5124,7 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align,
convert the address to the final type and output it that
way. */
if (ADDR_EXPR_P (exp))
- exp = build1 (ADDR_EXPR, saved_type, TREE_OPERAND (exp, 0));
+ exp = build_addr_expr (saved_type, TREE_OPERAND (exp, 0));
/* Likewise for constant ints. */
else if (TREE_CODE (exp) == INTEGER_CST)
exp = fold_convert (saved_type, exp);
diff --git a/gcc/vtable-verify.c b/gcc/vtable-verify.c
index 48613229460..23235da2c7e 100644
--- a/gcc/vtable-verify.c
+++ b/gcc/vtable-verify.c
@@ -731,10 +731,10 @@ verify_bb_vtables (basic_block bb)
call_stmt = gimple_build_call
(verify_vtbl_ptr_fndecl, 4,
- build1 (ADDR_EXPR,
- TYPE_POINTER_TO
- (TREE_TYPE (vtbl_var_decl)),
- vtbl_var_decl),
+ build_addr_expr
+ (TYPE_POINTER_TO
+ (TREE_TYPE (vtbl_var_decl)),
+ vtbl_var_decl),
lhs,
build_string_literal
(len1 + 1,
@@ -747,10 +747,10 @@ verify_bb_vtables (basic_block bb)
else
call_stmt = gimple_build_call
(verify_vtbl_ptr_fndecl, 2,
- build1 (ADDR_EXPR,
- TYPE_POINTER_TO
- (TREE_TYPE (vtbl_var_decl)),
- vtbl_var_decl),
+ build_addr_expr
+ (TYPE_POINTER_TO
+ (TREE_TYPE (vtbl_var_decl)),
+ vtbl_var_decl),
lhs);
^ 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 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).