gimplify.c (mark_addressable): Export.

2009-03-27  Richard Guenther  <rguenther@suse.de>

	* gimplify.c (mark_addressable): Export.
	* tree-flow.h (mark_addressable): Declare.
	* tree-ssa-loop-manip.c (create_iv): Mark the base addressable.
	* tree-ssa.c (verify_phi_args): Verify that address taken
	variables have TREE_ADDRESSABLE set.

2009-03-27  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (build_fold_addr_expr_with_type_1): Rename back to ...
	(build_fold_addr_expr_with_type): ... this.  Remove in_fold handling.
	Do not mark decls TREE_ADDRESSABLE.
	(build_fold_addr_expr): Adjust.
	(fold_addr_expr): Remove.
	(fold_unary): Use build_fold_addr_expr.
	(fold_comparison): Likewise.
	(split_address_to_core_and_offset): Likewise.
	* coverage.c (tree_coverage_counter_addr): Mark the array decl
	TREE_ADDRESSABLE.
	* gimplify.c (mark_addressable): Do not exclude RESULT_DECLs.
	(gimplify_modify_expr_to_memcpy): Mark source and destination
	addressable.
	* omp-low.c (create_omp_child_function): Mark the object decl
	TREE_ADDRESSABLE.
	(lower_rec_input_clauses): Mark the var we take the address of
	TREE_ADDRESSABLE.
	(lower_omp_taskreg): Mark the sender decl TREE_ADDRESSABLE.

	fortran/
	* trans-array.c (gfc_conv_descriptor_data_addr): Use
	gfc_build_addr_expr instead of build_fold_addr_expr.
	(gfc_trans_allocate_array_storage, gfc_trans_array_constructor_value,
	gfc_trans_constant_array_constructor, gfc_conv_array_data,
	gfc_conv_expr_descriptor, gfc_conv_array_parameter): Likewise.
	* trans-expr.c (gfc_conv_missing_dummy, gfc_conv_variable,
	gfc_conv_function_val, gfc_conv_operator_assign,
	gfc_conv_subref_array_arg, gfc_conv_function_call,
	gfc_conv_expr_reference, gfc_trans_scalar_assign): Likewise.
	* trans-intrinsic.c (gfc_conv_intrinsic_exponent,
	gfc_conv_intrinsic_ctime, gfc_conv_intrinsic_fdate,
	gfc_conv_intrinsic_ttynam, gfc_conv_intrinsic_minmax_char,
	gfc_conv_intrinsic_fraction, gfc_conv_intrinsic_spacing,
	gfc_conv_intrinsic_rrspacing, gfc_conv_intrinsic_set_exponent,
	gfc_conv_intrinsic_array_transfer, gfc_conv_intrinsic_transfer,
	gfc_conv_intrinsic_si_kind, gfc_conv_intrinsic_trim): Likewise.
	* trans-io.c (gfc_trans_io_runtime_check, set_parameter_ref,
	gfc_convert_array_to_string, gfc_trans_open, gfc_trans_close,
	build_filepos, gfc_trans_inquire, gfc_trans_wait,
	nml_get_addr_expr, transfer_namelist_element, build_dt,
	gfc_trans_dt_end, transfer_array_component, transfer_expr,
	transfer_array_desc, gfc_trans_transfer): Likewise.
	* trans-stmt.c (gfc_trans_allocate, gfc_trans_deallocate): Likewise.
	* trans.c (gfc_build_addr_expr): Mark the base of the address
	TREE_ADDRESSABLE.

From-SVN: r145142
This commit is contained in:
Richard Guenther 2009-03-27 23:00:22 +00:00 committed by Richard Biener
parent 0387122d05
commit 628c189edb
14 changed files with 134 additions and 115 deletions

View File

@ -459,6 +459,8 @@ tree_coverage_counter_addr (unsigned counter, unsigned no)
gcc_assert (no < fn_n_ctrs[counter] - fn_b_ctrs[counter]);
no += prg_n_ctrs[counter] + fn_b_ctrs[counter];
TREE_ADDRESSABLE (tree_ctr_tables[counter]) = 1;
/* "no" here is an array index, scaled to bytes later. */
return build_fold_addr_expr (build4 (ARRAY_REF, gcov_type_node,
tree_ctr_tables[counter],

View File

@ -7937,11 +7937,10 @@ fold_view_convert_expr (tree type, tree expr)
}
/* Build an expression for the address of T. Folds away INDIRECT_REF
to avoid confusing the gimplify process. When IN_FOLD is true
avoid modifications of T. */
to avoid confusing the gimplify process. */
static tree
build_fold_addr_expr_with_type_1 (tree t, tree ptrtype, bool in_fold)
tree
build_fold_addr_expr_with_type (tree t, tree ptrtype)
{
/* The size of the object is not relevant when talking about its address. */
if (TREE_CODE (t) == WITH_SIZE_EXPR)
@ -7956,56 +7955,20 @@ build_fold_addr_expr_with_type_1 (tree t, tree ptrtype, bool in_fold)
if (TREE_TYPE (t) != ptrtype)
t = build1 (NOP_EXPR, ptrtype, t);
}
else if (!in_fold)
{
tree base = t;
while (handled_component_p (base))
base = TREE_OPERAND (base, 0);
if (DECL_P (base))
TREE_ADDRESSABLE (base) = 1;
t = build1 (ADDR_EXPR, ptrtype, t);
}
else
t = build1 (ADDR_EXPR, ptrtype, t);
return t;
}
/* Build an expression for the address of T with type PTRTYPE. This
function modifies the input parameter 'T' by sometimes setting the
TREE_ADDRESSABLE flag. */
tree
build_fold_addr_expr_with_type (tree t, tree ptrtype)
{
return build_fold_addr_expr_with_type_1 (t, ptrtype, false);
}
/* Build an expression for the address of T. This function modifies
the input parameter 'T' by sometimes setting the TREE_ADDRESSABLE
flag. When called from fold functions, use fold_addr_expr instead. */
/* Build an expression for the address of T. */
tree
build_fold_addr_expr (tree t)
{
return build_fold_addr_expr_with_type_1 (t,
build_pointer_type (TREE_TYPE (t)),
false);
}
/* Same as build_fold_addr_expr, builds an expression for the address
of T, but avoids touching the input node 't'. Fold functions
should use this version. */
static tree
fold_addr_expr (tree t)
{
tree ptrtype = build_pointer_type (TREE_TYPE (t));
return build_fold_addr_expr_with_type_1 (t, ptrtype, true);
return build_fold_addr_expr_with_type (t, ptrtype);
}
/* Fold a unary expression of code CODE and type TYPE with operand
@ -8245,7 +8208,7 @@ fold_unary (enum tree_code code, tree type, tree op0)
if (! offset && bitpos == 0
&& TYPE_MAIN_VARIANT (TREE_TYPE (type))
== TYPE_MAIN_VARIANT (TREE_TYPE (base)))
return fold_convert (type, fold_addr_expr (base));
return fold_convert (type, build_fold_addr_expr (base));
}
if (TREE_CODE (op0) == MODIFY_EXPR
@ -9155,9 +9118,9 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1)
&& operand_equal_p (offset0, offset1, 0))))
{
if (indirect_base0)
base0 = fold_addr_expr (base0);
base0 = build_fold_addr_expr (base0);
if (indirect_base1)
base1 = fold_addr_expr (base1);
base1 = build_fold_addr_expr (base1);
return fold_build2 (code, type, base0, base1);
}
}
@ -15829,7 +15792,7 @@ split_address_to_core_and_offset (tree exp,
core = get_inner_reference (TREE_OPERAND (exp, 0), &bitsize, pbitpos,
poffset, &mode, &unsignedp, &volatilep,
false);
core = fold_addr_expr (core);
core = build_fold_addr_expr (core);
}
else
{

View File

@ -1,3 +1,31 @@
2009-03-27 Richard Guenther <rguenther@suse.de>
* trans-array.c (gfc_conv_descriptor_data_addr): Use
gfc_build_addr_expr instead of build_fold_addr_expr.
(gfc_trans_allocate_array_storage, gfc_trans_array_constructor_value,
gfc_trans_constant_array_constructor, gfc_conv_array_data,
gfc_conv_expr_descriptor, gfc_conv_array_parameter): Likewise.
* trans-expr.c (gfc_conv_missing_dummy, gfc_conv_variable,
gfc_conv_function_val, gfc_conv_operator_assign,
gfc_conv_subref_array_arg, gfc_conv_function_call,
gfc_conv_expr_reference, gfc_trans_scalar_assign): Likewise.
* trans-intrinsic.c (gfc_conv_intrinsic_exponent,
gfc_conv_intrinsic_ctime, gfc_conv_intrinsic_fdate,
gfc_conv_intrinsic_ttynam, gfc_conv_intrinsic_minmax_char,
gfc_conv_intrinsic_fraction, gfc_conv_intrinsic_spacing,
gfc_conv_intrinsic_rrspacing, gfc_conv_intrinsic_set_exponent,
gfc_conv_intrinsic_array_transfer, gfc_conv_intrinsic_transfer,
gfc_conv_intrinsic_si_kind, gfc_conv_intrinsic_trim): Likewise.
* trans-io.c (gfc_trans_io_runtime_check, set_parameter_ref,
gfc_convert_array_to_string, gfc_trans_open, gfc_trans_close,
build_filepos, gfc_trans_inquire, gfc_trans_wait,
nml_get_addr_expr, transfer_namelist_element, build_dt,
gfc_trans_dt_end, transfer_array_component, transfer_expr,
transfer_array_desc, gfc_trans_transfer): Likewise.
* trans-stmt.c (gfc_trans_allocate, gfc_trans_deallocate): Likewise.
* trans.c (gfc_build_addr_expr): Mark the base of the address
TREE_ADDRESSABLE.
2009-03-27 Tobias Burnus <burnus@net-b.de>
* gfortran.h (enum init_local_real.): Add GFC_INIT_REAL_SNAN.

View File

@ -194,7 +194,7 @@ gfc_conv_descriptor_data_addr (tree desc)
gcc_assert (DATA_FIELD == 0);
t = fold_build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
return build_fold_addr_expr (t);
return gfc_build_addr_expr (NULL_TREE, t);
}
tree
@ -533,7 +533,7 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post,
tmp = build_array_type (gfc_get_element_type (TREE_TYPE (desc)),
tmp);
tmp = gfc_create_var (tmp, "A");
tmp = build_fold_addr_expr (tmp);
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
gfc_conv_descriptor_data_set (pre, desc, tmp);
}
else
@ -1281,8 +1281,8 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type,
tmp = gfc_conv_descriptor_data_get (desc);
tmp = build_fold_indirect_ref (tmp);
tmp = gfc_build_array_ref (tmp, *poffset, NULL);
tmp = build_fold_addr_expr (tmp);
init = build_fold_addr_expr (init);
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
init = gfc_build_addr_expr (NULL_TREE, init);
size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type));
bound = build_int_cst (NULL_TREE, n * size);
@ -1683,7 +1683,7 @@ gfc_trans_constant_array_constructor (gfc_loopinfo * loop,
info = &ss->data.info;
info->descriptor = tmp;
info->data = build_fold_addr_expr (tmp);
info->data = gfc_build_addr_expr (NULL_TREE, tmp);
info->offset = gfc_index_zero_node;
for (i = 0; i < info->dimen; i++)
@ -2136,7 +2136,7 @@ gfc_conv_array_data (tree descriptor)
else
{
/* Descriptorless arrays. */
return build_fold_addr_expr (descriptor);
return gfc_build_addr_expr (NULL_TREE, descriptor);
}
}
else
@ -4836,7 +4836,7 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
{
/* We pass full arrays directly. This means that pointers and
allocatable arrays should also work. */
se->expr = build_fold_addr_expr (desc);
se->expr = gfc_build_addr_expr (NULL_TREE, desc);
}
else
{
@ -4867,7 +4867,7 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
/* For pointer assignments pass the descriptor directly. */
se->ss = secss;
se->expr = build_fold_addr_expr (se->expr);
se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
gfc_conv_expr (se, expr);
return;
}
@ -5189,7 +5189,7 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
{
/* Get a pointer to the new descriptor. */
if (se->want_pointer)
se->expr = build_fold_addr_expr (desc);
se->expr = gfc_build_addr_expr (NULL_TREE, desc);
else
se->expr = desc;
}
@ -5255,7 +5255,7 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77,
if (sym->attr.dummy || POINTER_TYPE_P (TREE_TYPE (tmp)))
se->expr = tmp;
else
se->expr = build_fold_addr_expr (tmp);
se->expr = gfc_build_addr_expr (NULL_TREE, tmp);
return;
}
if (sym->attr.allocatable)
@ -5275,7 +5275,7 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77,
{
/* Result of the enclosing function. */
gfc_conv_expr_descriptor (se, expr, ss);
se->expr = build_fold_addr_expr (se->expr);
se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
if (g77 && TREE_TYPE (TREE_TYPE (se->expr)) != NULL_TREE
&& GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (TREE_TYPE (se->expr))))

View File

@ -164,7 +164,7 @@ gfc_conv_missing_dummy (gfc_se * se, gfc_expr * arg, gfc_typespec ts, int kind)
tmp = build3 (COND_EXPR, TREE_TYPE (tmp), present, tmp,
fold_convert (TREE_TYPE (tmp), integer_one_node));
tmp = gfc_evaluate_now (tmp, &se->pre);
se->expr = build_fold_addr_expr (tmp);
se->expr = gfc_build_addr_expr (NULL_TREE, tmp);
}
else
{
@ -603,7 +603,7 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr)
if (!sym->attr.dummy && !sym->attr.proc_pointer)
{
gcc_assert (TREE_CODE (se->expr) == FUNCTION_DECL);
se->expr = build_fold_addr_expr (se->expr);
se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
}
return;
}
@ -705,7 +705,7 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr)
if (expr->ts.type == BT_CHARACTER)
gfc_conv_string_parameter (se);
else
se->expr = build_fold_addr_expr (se->expr);
se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
}
}
@ -1519,7 +1519,7 @@ gfc_conv_function_val (gfc_se * se, gfc_symbol * sym)
if (!POINTER_TYPE_P (TREE_TYPE (tmp)))
{
gcc_assert (TREE_CODE (tmp) == FUNCTION_DECL);
tmp = build_fold_addr_expr (tmp);
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
}
}
se->expr = tmp;
@ -1547,8 +1547,8 @@ gfc_conv_operator_assign (gfc_se *lse, gfc_se *rse, gfc_symbol *sym)
gfc_add_block_to_block (&block, &rse->pre);
/* Build the argument list for the call, including hidden string lengths. */
args = gfc_chainon_list (NULL_TREE, build_fold_addr_expr (lse->expr));
args = gfc_chainon_list (args, build_fold_addr_expr (rse->expr));
args = gfc_chainon_list (NULL_TREE, gfc_build_addr_expr (NULL_TREE, lse->expr));
args = gfc_chainon_list (args, gfc_build_addr_expr (NULL_TREE, rse->expr));
if (lse->string_length != NULL_TREE)
args = gfc_chainon_list (args, lse->string_length);
if (rse->string_length != NULL_TREE)
@ -2371,7 +2371,7 @@ gfc_conv_subref_array_arg (gfc_se * parmse, gfc_expr * expr,
if (g77)
parmse->expr = gfc_conv_descriptor_data_get (parmse->expr);
else
parmse->expr = build_fold_addr_expr (parmse->expr);
parmse->expr = gfc_build_addr_expr (NULL_TREE, parmse->expr);
return;
}
@ -2666,7 +2666,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
&& fsym && fsym->attr.target)
{
gfc_conv_expr (&parmse, e);
parmse.expr = build_fold_addr_expr (parmse.expr);
parmse.expr = gfc_build_addr_expr (NULL_TREE, parmse.expr);
}
else
{
@ -2680,7 +2680,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
indirection. The null pointer already contains
this level of indirection. */
parm_kind = SCALAR_POINTER;
parmse.expr = build_fold_addr_expr (parmse.expr);
parmse.expr = gfc_build_addr_expr (NULL_TREE, parmse.expr);
}
}
}
@ -2881,7 +2881,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
/* Pass the temporary as the first argument. */
tmp = info->descriptor;
tmp = build_fold_addr_expr (tmp);
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
retargs = gfc_chainon_list (retargs, tmp);
}
else if (ts.type == BT_CHARACTER)
@ -2897,7 +2897,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
var = gfc_create_var (type, "pstr");
/* Provide an address expression for the function arguments. */
var = build_fold_addr_expr (var);
var = gfc_build_addr_expr (NULL_TREE, var);
}
else
var = gfc_conv_string_tmp (se, type, len);
@ -2909,7 +2909,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
gcc_assert (gfc_option.flag_f2c && ts.type == BT_COMPLEX);
type = gfc_get_complex_type (ts.kind);
var = build_fold_addr_expr (gfc_create_var (type, "cmplx"));
var = gfc_build_addr_expr (NULL_TREE, gfc_create_var (type, "cmplx"));
retargs = gfc_chainon_list (retargs, var);
}
@ -2945,7 +2945,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
TREE_TYPE (sym->backend_decl)
= build_function_type (integer_type_node,
TYPE_ARG_TYPES (TREE_TYPE (sym->backend_decl)));
se->expr = build_fold_addr_expr (sym->backend_decl);
se->expr = gfc_build_addr_expr (NULL_TREE, sym->backend_decl);
}
else
TREE_TYPE (TREE_TYPE (TREE_TYPE (se->expr))) = integer_type_node;
@ -4010,7 +4010,7 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr)
gfc_add_block_to_block (&se->pre, &se->post);
/* Take the address of that value. */
se->expr = build_fold_addr_expr (var);
se->expr = gfc_build_addr_expr (NULL_TREE, var);
}
@ -4226,8 +4226,8 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rse, gfc_typespec ts,
if (r_is_var)
{
cond = fold_build2 (EQ_EXPR, boolean_type_node,
build_fold_addr_expr (lse->expr),
build_fold_addr_expr (rse->expr));
gfc_build_addr_expr (NULL_TREE, lse->expr),
gfc_build_addr_expr (NULL_TREE, rse->expr));
cond = gfc_evaluate_now (cond, &lse->pre);
}

View File

@ -807,7 +807,7 @@ gfc_conv_intrinsic_exponent (gfc_se *se, gfc_expr *expr)
res = gfc_create_var (integer_type_node, NULL);
tmp = build_call_expr (built_in_decls[frexp], 2, arg,
build_fold_addr_expr (res));
gfc_build_addr_expr (NULL_TREE, res));
gfc_add_expr_to_block (&se->pre, tmp);
type = gfc_typenode_for_spec (&expr->ts);
@ -1375,8 +1375,8 @@ gfc_conv_intrinsic_ctime (gfc_se * se, gfc_expr * expr)
len = gfc_create_var (gfc_get_int_type (8), "len");
gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
args[0] = build_fold_addr_expr (var);
args[1] = build_fold_addr_expr (len);
args[0] = gfc_build_addr_expr (NULL_TREE, var);
args[1] = gfc_build_addr_expr (NULL_TREE, len);
fndecl = build_addr (gfor_fndecl_ctime, current_function_decl);
tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_ctime)),
@ -1413,8 +1413,8 @@ gfc_conv_intrinsic_fdate (gfc_se * se, gfc_expr * expr)
len = gfc_create_var (gfc_get_int_type (4), "len");
gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
args[0] = build_fold_addr_expr (var);
args[1] = build_fold_addr_expr (len);
args[0] = gfc_build_addr_expr (NULL_TREE, var);
args[1] = gfc_build_addr_expr (NULL_TREE, len);
fndecl = build_addr (gfor_fndecl_fdate, current_function_decl);
tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_fdate)),
@ -1453,8 +1453,8 @@ gfc_conv_intrinsic_ttynam (gfc_se * se, gfc_expr * expr)
len = gfc_create_var (gfc_get_int_type (4), "len");
gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
args[0] = build_fold_addr_expr (var);
args[1] = build_fold_addr_expr (len);
args[0] = gfc_build_addr_expr (NULL_TREE, var);
args[1] = gfc_build_addr_expr (NULL_TREE, len);
fndecl = build_addr (gfor_fndecl_ttynam, current_function_decl);
tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_ttynam)),
@ -1577,7 +1577,7 @@ gfc_conv_intrinsic_minmax_char (gfc_se * se, gfc_expr * expr, int op)
/* Create the result variables. */
len = gfc_create_var (gfc_charlen_type_node, "len");
args[0] = build_fold_addr_expr (len);
args[0] = gfc_build_addr_expr (NULL_TREE, len);
var = gfc_create_var (gfc_get_pchar_type (expr->ts.kind), "pstr");
args[1] = gfc_build_addr_expr (ppvoid_type_node, var);
args[2] = build_int_cst (NULL_TREE, op);
@ -3124,7 +3124,7 @@ gfc_conv_intrinsic_fraction (gfc_se * se, gfc_expr * expr)
tmp = gfc_create_var (integer_type_node, NULL);
se->expr = build_call_expr (built_in_decls[frexp], 2,
fold_convert (type, arg),
build_fold_addr_expr (tmp));
gfc_build_addr_expr (NULL_TREE, tmp));
se->expr = fold_convert (type, se->expr);
}
@ -3232,7 +3232,7 @@ gfc_conv_intrinsic_spacing (gfc_se * se, gfc_expr * expr)
/* Build the block for s /= 0. */
gfc_start_block (&block);
tmp = build_call_expr (built_in_decls[frexp], 2, arg,
build_fold_addr_expr (e));
gfc_build_addr_expr (NULL_TREE, e));
gfc_add_expr_to_block (&block, tmp);
tmp = fold_build2 (MINUS_EXPR, integer_type_node, e, prec);
@ -3310,7 +3310,7 @@ gfc_conv_intrinsic_rrspacing (gfc_se * se, gfc_expr * expr)
gfc_start_block (&block);
tmp = build_call_expr (built_in_decls[frexp], 2, arg,
build_fold_addr_expr (e));
gfc_build_addr_expr (NULL_TREE, e));
gfc_add_expr_to_block (&block, tmp);
tmp = fold_build2 (MINUS_EXPR, integer_type_node,
@ -3393,7 +3393,7 @@ gfc_conv_intrinsic_set_exponent (gfc_se * se, gfc_expr * expr)
tmp = gfc_create_var (integer_type_node, NULL);
tmp = build_call_expr (built_in_decls[frexp], 2,
fold_convert (type, args[0]),
build_fold_addr_expr (tmp));
gfc_build_addr_expr (NULL_TREE, tmp));
se->expr = build_call_expr (built_in_decls[scalbn], 2, tmp,
fold_convert (integer_type_node, args[1]));
se->expr = fold_convert (type, se->expr);
@ -3713,7 +3713,7 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr)
if (arg->expr->expr_type == EXPR_VARIABLE
&& arg->expr->ref->u.ar.type != AR_FULL)
{
tmp = build_fold_addr_expr (argse.expr);
tmp = gfc_build_addr_expr (NULL_TREE, argse.expr);
if (gfc_option.warn_array_temp)
gfc_warning ("Creating array temporary at %L", &expr->where);
@ -3954,7 +3954,7 @@ scalar_transfer:
ptr = convert (build_pointer_type (mold_type), source);
/* Use memcpy to do the transfer. */
tmp = build_fold_addr_expr (tmpdecl);
tmp = gfc_build_addr_expr (NULL_TREE, tmpdecl);
tmp = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3,
fold_convert (pvoid_type_node, tmp),
fold_convert (pvoid_type_node, ptr),
@ -4127,7 +4127,7 @@ gfc_conv_intrinsic_si_kind (gfc_se *se, gfc_expr *expr)
/* The argument to SELECTED_INT_KIND is INTEGER(4). */
type = gfc_get_int_type (4);
arg = build_fold_addr_expr (fold_convert (type, arg));
arg = gfc_build_addr_expr (NULL_TREE, fold_convert (type, arg));
/* Convert it to the required type. */
type = gfc_typenode_for_spec (&expr->ts);
@ -4203,7 +4203,7 @@ gfc_conv_intrinsic_trim (gfc_se * se, gfc_expr * expr)
len = gfc_create_var (gfc_get_int_type (4), "len");
gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
args[0] = build_fold_addr_expr (len);
args[0] = gfc_build_addr_expr (NULL_TREE, len);
args[1] = addr;
if (expr->ts.kind == 1)

View File

@ -239,7 +239,7 @@ gfc_trans_io_runtime_check (tree cond, tree var, int error_code,
/* The code to generate the error. */
gfc_start_block (&block);
arg1 = build_fold_addr_expr (var);
arg1 = gfc_build_addr_expr (NULL_TREE, var);
arg2 = build_int_cst (integer_type_node, error_code),
@ -530,7 +530,7 @@ set_parameter_ref (stmtblock_t *block, stmtblock_t *postblock,
if (TYPE_MODE (TREE_TYPE (se.expr))
== TYPE_MODE (TREE_TYPE (TREE_TYPE (p->field))))
{
addr = convert (TREE_TYPE (p->field), build_fold_addr_expr (se.expr));
addr = convert (TREE_TYPE (p->field), gfc_build_addr_expr (NULL_TREE, se.expr));
/* If this is for the iostat variable initialize the
user variable to LIBERROR_OK which is zero. */
@ -552,7 +552,7 @@ set_parameter_ref (stmtblock_t *block, stmtblock_t *postblock,
gfc_add_modify (block, tmpvar,
build_int_cst (TREE_TYPE (tmpvar), LIBERROR_OK));
addr = build_fold_addr_expr (tmpvar);
addr = gfc_build_addr_expr (NULL_TREE, tmpvar);
/* After the I/O operation, we set the variable from the temporary. */
tmp = convert (TREE_TYPE (se.expr), tmpvar);
gfc_add_modify (postblock, se.expr, tmp);
@ -621,7 +621,7 @@ gfc_convert_array_to_string (gfc_se * se, gfc_expr * e)
{
size = fold_build2 (MINUS_EXPR, gfc_array_index_type, size,
TREE_OPERAND (se->expr, 1));
se->expr = build_fold_addr_expr (se->expr);
se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
}
tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type));
@ -966,7 +966,7 @@ gfc_trans_open (gfc_code * code)
else
set_parameter_const (&block, var, IOPARM_common_unit, 0);
tmp = build_fold_addr_expr (var);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr (iocall[IOCALL_OPEN], 1, tmp);
gfc_add_expr_to_block (&block, tmp);
@ -1018,7 +1018,7 @@ gfc_trans_close (gfc_code * code)
else
set_parameter_const (&block, var, IOPARM_common_unit, 0);
tmp = build_fold_addr_expr (var);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr (iocall[IOCALL_CLOSE], 1, tmp);
gfc_add_expr_to_block (&block, tmp);
@ -1068,7 +1068,7 @@ build_filepos (tree function, gfc_code * code)
else
set_parameter_const (&block, var, IOPARM_common_unit, 0);
tmp = build_fold_addr_expr (var);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr (function, 1, tmp);
gfc_add_expr_to_block (&block, tmp);
@ -1325,7 +1325,7 @@ gfc_trans_inquire (gfc_code * code)
else
set_parameter_const (&block, var, IOPARM_common_unit, 0);
tmp = build_fold_addr_expr (var);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr (iocall[IOCALL_INQUIRE], 1, tmp);
gfc_add_expr_to_block (&block, tmp);
@ -1374,7 +1374,7 @@ gfc_trans_wait (gfc_code * code)
if (p->unit)
set_parameter_value (&block, var, IOPARM_common_unit, p->unit);
tmp = build_fold_addr_expr (var);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr (iocall[IOCALL_WAIT], 1, tmp);
gfc_add_expr_to_block (&block, tmp);
@ -1488,7 +1488,7 @@ nml_get_addr_expr (gfc_symbol * sym, gfc_component * c,
/* Now build the address expression. */
tmp = build_fold_addr_expr (tmp);
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
/* If scalar dummy, resolve indirect reference now. */
@ -1581,7 +1581,7 @@ transfer_namelist_element (stmtblock_t * block, const char * var_name,
The call for the scalar part transfers:
(address, name, type, kind or string_length, dtype) */
dt_parm_addr = build_fold_addr_expr (dt_parm);
dt_parm_addr = gfc_build_addr_expr (NULL_TREE, dt_parm);
if (ts->type == BT_CHARACTER)
tmp = ts->cl->backend_decl;
@ -1791,7 +1791,7 @@ build_dt (tree function, gfc_code * code)
else
set_parameter_const (&block, var, IOPARM_common_flags, mask);
tmp = build_fold_addr_expr (var);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr (function, 1, tmp);
gfc_add_expr_to_block (&block, tmp);
@ -1871,7 +1871,7 @@ gfc_trans_dt_end (gfc_code * code)
gcc_unreachable ();
}
tmp = build_fold_addr_expr (dt_parm);
tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
tmp = build_call_expr (function, 1, tmp);
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, dt_post_end_block);
@ -1955,7 +1955,7 @@ transfer_array_component (tree expr, gfc_component * cm, locus * where)
/* Now se.expr contains an element of the array. Take the address and pass
it to the IO routines. */
tmp = build_fold_addr_expr (se.expr);
tmp = gfc_build_addr_expr (NULL_TREE, se.expr);
transfer_expr (&se, &cm->ts, tmp, NULL);
/* We are done now with the loop body. Wrap up the scalarizer and
@ -2053,7 +2053,7 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code)
}
arg3 = build_int_cst (NULL_TREE, kind);
function = iocall[IOCALL_X_CHARACTER_WIDE];
tmp = build_fold_addr_expr (dt_parm);
tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
tmp = build_call_expr (function, 4, tmp, addr_expr, arg2, arg3);
gfc_add_expr_to_block (&se->pre, tmp);
gfc_add_block_to_block (&se->pre, &se->post);
@ -2093,7 +2093,7 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code)
else
{
if (!c->attr.pointer)
tmp = build_fold_addr_expr (tmp);
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
transfer_expr (se, &c->ts, tmp, code);
}
}
@ -2103,7 +2103,7 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code)
internal_error ("Bad IO basetype (%d)", ts->type);
}
tmp = build_fold_addr_expr (dt_parm);
tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
tmp = build_call_expr (function, 3, tmp, addr_expr, arg2);
gfc_add_expr_to_block (&se->pre, tmp);
gfc_add_block_to_block (&se->pre, &se->post);
@ -2126,7 +2126,7 @@ transfer_array_desc (gfc_se * se, gfc_typespec * ts, tree addr_expr)
kind_arg = build_int_cst (NULL_TREE, ts->kind);
tmp = build_fold_addr_expr (dt_parm);
tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
tmp = build_call_expr (iocall[IOCALL_X_ARRAY], 4,
tmp, addr_expr, kind_arg, charlen_arg);
gfc_add_expr_to_block (&se->pre, tmp);
@ -2198,7 +2198,7 @@ gfc_trans_transfer (gfc_code * code)
{
/* Get the descriptor. */
gfc_conv_expr_descriptor (&se, expr, ss);
tmp = build_fold_addr_expr (se.expr);
tmp = gfc_build_addr_expr (NULL_TREE, se.expr);
}
transfer_array_desc (&se, &expr->ts, tmp);

View File

@ -3893,7 +3893,7 @@ gfc_trans_allocate (gfc_code * code)
tree gfc_int4_type_node = gfc_get_int_type (4);
stat = gfc_create_var (gfc_int4_type_node, "stat");
pstat = build_fold_addr_expr (stat);
pstat = gfc_build_addr_expr (NULL_TREE, stat);
error_label = gfc_build_label_decl (NULL_TREE);
TREE_USED (error_label) = 1;
@ -3999,11 +3999,11 @@ gfc_trans_deallocate (gfc_code * code)
/* Variable used with the library call. */
stat = gfc_create_var (gfc_int4_type_node, "stat");
pstat = build_fold_addr_expr (stat);
pstat = gfc_build_addr_expr (NULL_TREE, stat);
/* Running total of possible deallocation failures. */
astat = gfc_create_var (gfc_int4_type_node, "astat");
apstat = build_fold_addr_expr (astat);
apstat = gfc_build_addr_expr (NULL_TREE, astat);
/* Initialize astat to 0. */
gfc_add_modify (&block, astat, build_int_cst (TREE_TYPE (astat), 0));

View File

@ -293,8 +293,9 @@ gfc_build_addr_expr (tree type, tree t)
}
else
{
if (DECL_P (t))
TREE_ADDRESSABLE (t) = 1;
tree base = get_base_address (t);
if (base && DECL_P (base))
TREE_ADDRESSABLE (base) = 1;
t = fold_build1 (ADDR_EXPR, natural_type, t);
}

View File

@ -107,12 +107,14 @@ static enum gimplify_status gimplify_compound_expr (tree *, gimple_seq *, bool);
/* Mark X addressable. Unlike the langhook we expect X to be in gimple
form and we don't do any syntax checking. */
static void
void
mark_addressable (tree x)
{
while (handled_component_p (x))
x = TREE_OPERAND (x, 0);
if (TREE_CODE (x) != VAR_DECL && TREE_CODE (x) != PARM_DECL)
if (TREE_CODE (x) != VAR_DECL
&& TREE_CODE (x) != PARM_DECL
&& TREE_CODE (x) != RESULT_DECL)
return ;
TREE_ADDRESSABLE (x) = 1;
}
@ -3056,9 +3058,11 @@ gimplify_modify_expr_to_memcpy (tree *expr_p, tree size, bool want_value,
to = TREE_OPERAND (*expr_p, 0);
from = TREE_OPERAND (*expr_p, 1);
mark_addressable (from);
from_ptr = build_fold_addr_expr (from);
gimplify_arg (&from_ptr, seq_p, EXPR_LOCATION (*expr_p));
mark_addressable (to);
to_ptr = build_fold_addr_expr (to);
gimplify_arg (&to_ptr, seq_p, EXPR_LOCATION (*expr_p));

View File

@ -1595,6 +1595,7 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
DECL_ARG_TYPE (t) = ptr_type_node;
DECL_CONTEXT (t) = current_function_decl;
TREE_USED (t) = 1;
TREE_ADDRESSABLE (t) = 1;
TREE_CHAIN (t) = DECL_ARGUMENTS (decl);
DECL_ARGUMENTS (decl) = t;
}
@ -2316,6 +2317,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
x = create_tmp_var_raw (TREE_TYPE (TREE_TYPE (new_var)),
name);
gimple_add_tmp_var (x);
TREE_ADDRESSABLE (x) = 1;
x = build_fold_addr_expr_with_type (x, TREE_TYPE (new_var));
}
else
@ -6344,6 +6346,7 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
ctx->sender_decl
= create_tmp_var (ctx->srecord_type ? ctx->srecord_type
: ctx->record_type, ".omp_data_o");
TREE_ADDRESSABLE (ctx->sender_decl) = 1;
gimple_omp_taskreg_set_data_arg (stmt, ctx->sender_decl);
}

View File

@ -1145,6 +1145,7 @@ tree force_gimple_operand (tree, gimple_seq *, bool, tree);
tree force_gimple_operand_gsi (gimple_stmt_iterator *, tree, bool, tree,
bool, enum gsi_iterator_update);
tree gimple_fold_indirect_ref (tree);
void mark_addressable (tree);
/* In tree-ssa-structalias.c */
bool find_what_p_points_to (tree);

View File

@ -99,6 +99,8 @@ create_iv (tree base, tree step, tree var, struct loop *loop,
}
if (POINTER_TYPE_P (TREE_TYPE (base)))
{
if (TREE_CODE (base) == ADDR_EXPR)
mark_addressable (TREE_OPERAND (base, 0));
step = fold_convert (sizetype, step);
if (incr_op == MINUS_EXPR)
step = fold_build1 (NEGATE_EXPR, sizetype, step);

View File

@ -478,6 +478,21 @@ verify_phi_args (gimple phi, basic_block bb, basic_block *definition_block)
op_p, phi, e->flags & EDGE_ABNORMAL, NULL);
}
if (TREE_CODE (op) == ADDR_EXPR)
{
tree base = TREE_OPERAND (op, 0);
while (handled_component_p (base))
base = TREE_OPERAND (base, 0);
if ((TREE_CODE (base) == VAR_DECL
|| TREE_CODE (base) == PARM_DECL
|| TREE_CODE (base) == RESULT_DECL)
&& !TREE_ADDRESSABLE (base))
{
error ("address taken, but ADDRESSABLE bit not set");
err = true;
}
}
if (e->dest != bb)
{
error ("wrong edge %d->%d for PHI argument",