#include "splay-tree.h"
#include "vec.h"
#include "gimple.h"
+#include "tree-pass.h"
enum gimplify_omp_var_data
}
}
-/* Subroutine for find_single_pointer_decl. */
-
-static tree
-find_single_pointer_decl_1 (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
- void *data)
-{
- tree *pdecl = (tree *) data;
-
- /* We are only looking for pointers at the same level as the
- original tree; we must not look through any indirections.
- Returning anything other than NULL_TREE will cause the caller to
- not find a base. */
- if (REFERENCE_CLASS_P (*tp))
- return *tp;
-
- if (DECL_P (*tp) && POINTER_TYPE_P (TREE_TYPE (*tp)))
- {
- if (*pdecl)
- {
- /* We already found a pointer decl; return anything other
- than NULL_TREE to unwind from walk_tree signalling that
- we have a duplicate. */
- return *tp;
- }
- *pdecl = *tp;
- }
-
- return NULL_TREE;
-}
-
-/* Find the single DECL of pointer type in the tree T, used directly
- rather than via an indirection, and return it. If there are zero
- or more than one such DECLs, return NULL. */
-
-static tree
-find_single_pointer_decl (tree t)
-{
- tree decl = NULL_TREE;
-
- if (walk_tree (&t, find_single_pointer_decl_1, &decl, NULL))
- {
- /* find_single_pointer_decl_1 returns a nonzero value, causing
- walk_tree to return a nonzero value, to indicate that it
- found more than one pointer DECL or that it found an
- indirection. */
- return NULL_TREE;
- }
-
- return decl;
-}
-
/* Create a new temporary name with PREFIX. Returns an identifier. */
static GTY(()) unsigned int tmp_var_id_num;
new_type = build_type_variant (type, 0, 0);
TYPE_ATTRIBUTES (new_type) = TYPE_ATTRIBUTES (type);
- tmp_var = build_decl (VAR_DECL, prefix ? create_tmp_var_name (prefix) : NULL,
+ tmp_var = build_decl (input_location,
+ VAR_DECL, prefix ? create_tmp_var_name (prefix) : NULL,
type);
/* The variable was declared by the compiler. */
t = lookup_tmp_var (val, is_formal);
- if (is_formal)
- {
- tree u = find_single_pointer_decl (val);
-
- if (u && TREE_CODE (u) == VAR_DECL && DECL_BASED_ON_RESTRICT_P (u))
- u = DECL_GET_RESTRICT_BASE (u);
- if (u && TYPE_RESTRICT (TREE_TYPE (u)))
- {
- if (DECL_BASED_ON_RESTRICT_P (t))
- gcc_assert (u == DECL_GET_RESTRICT_BASE (t));
- else
- {
- DECL_BASED_ON_RESTRICT_P (t) = 1;
- SET_DECL_RESTRICT_BASE (t, u);
- }
- }
-
- if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE
- || TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
- DECL_GIMPLE_REG_P (t) = 1;
- }
+ if (is_formal
+ && (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE
+ || TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE))
+ DECL_GIMPLE_REG_P (t) = 1;
mod = build2 (INIT_EXPR, TREE_TYPE (t), t, unshare_expr (val));
if (EXPR_HAS_LOCATION (val))
- SET_EXPR_LOCUS (mod, EXPR_LOCUS (val));
+ SET_EXPR_LOCATION (mod, EXPR_LOCATION (val));
else
SET_EXPR_LOCATION (mod, input_location);
gimple_set_plf (g, GF_PLF_1, true);
}
-/* Set the location for gimple statement GS to LOCUS. */
+/* Set the location for gimple statement GS to LOCATION. */
static void
annotate_one_with_location (gimple gs, location_t location)
}
-/* Set the location for all the statements in a sequence STMT_P to LOCUS. */
+/* Set the location for all the statements in a sequence STMT_P to LOCATION. */
void
annotate_all_with_location (gimple_seq stmt_p, location_t location)
/* Preliminarily mark non-addressed complex variables as eligible
for promotion to gimple registers. We'll transform their uses
- as we find them. */
- if ((TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE
- || TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
+ as we find them.
+ We exclude complex types if not optimizing because they can be
+ subject to partial stores in GNU C by means of the __real__ and
+ __imag__ operators and we cannot promote them to total stores
+ (see gimplify_modify_expr_complex_part). */
+ if (optimize
+ && (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE
+ || TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
&& !TREE_THIS_VOLATILE (t)
&& (TREE_CODE (t) == VAR_DECL && !DECL_HARD_REGISTER (t))
&& !needs_to_live_in_memory (t))
gimplify_loop_expr (tree *expr_p, gimple_seq *pre_p)
{
tree saved_label = gimplify_ctxp->exit_label;
- tree start_label = create_artificial_label ();
+ tree start_label = create_artificial_label (UNKNOWN_LOCATION);
gimplify_seq_add_stmt (pre_p, gimple_build_label (start_label));
}
len = i;
+ if (!VEC_empty (tree, labels))
+ sort_case_labels (labels);
+
if (!default_case)
{
- gimple new_default;
+ tree type = TREE_TYPE (switch_expr);
/* If the switch has no default label, add one, so that we jump
- around the switch body. */
- default_case = build3 (CASE_LABEL_EXPR, void_type_node, NULL_TREE,
- NULL_TREE, create_artificial_label ());
- new_default = gimple_build_label (CASE_LABEL (default_case));
- gimplify_seq_add_stmt (&switch_body_seq, new_default);
- }
+ around the switch body. If the labels already cover the whole
+ range of type, add the default label pointing to one of the
+ existing labels. */
+ if (type == void_type_node)
+ type = TREE_TYPE (SWITCH_COND (switch_expr));
+ if (len
+ && INTEGRAL_TYPE_P (type)
+ && TYPE_MIN_VALUE (type)
+ && TYPE_MAX_VALUE (type)
+ && tree_int_cst_equal (CASE_LOW (VEC_index (tree, labels, 0)),
+ TYPE_MIN_VALUE (type)))
+ {
+ tree low, high = CASE_HIGH (VEC_index (tree, labels, len - 1));
+ if (!high)
+ high = CASE_LOW (VEC_index (tree, labels, len - 1));
+ if (tree_int_cst_equal (high, TYPE_MAX_VALUE (type)))
+ {
+ for (i = 1; i < len; i++)
+ {
+ high = CASE_LOW (VEC_index (tree, labels, i));
+ low = CASE_HIGH (VEC_index (tree, labels, i - 1));
+ if (!low)
+ low = CASE_LOW (VEC_index (tree, labels, i - 1));
+ if ((TREE_INT_CST_LOW (low) + 1
+ != TREE_INT_CST_LOW (high))
+ || (TREE_INT_CST_HIGH (low)
+ + (TREE_INT_CST_LOW (high) == 0)
+ != TREE_INT_CST_HIGH (high)))
+ break;
+ }
+ if (i == len)
+ default_case = build3 (CASE_LABEL_EXPR, void_type_node,
+ NULL_TREE, NULL_TREE,
+ CASE_LABEL (VEC_index (tree,
+ labels, 0)));
+ }
+ }
- if (!VEC_empty (tree, labels))
- sort_case_labels (labels);
+ if (!default_case)
+ {
+ gimple new_default;
+
+ default_case
+ = build3 (CASE_LABEL_EXPR, void_type_node,
+ NULL_TREE, NULL_TREE,
+ create_artificial_label (UNKNOWN_LOCATION));
+ new_default = gimple_build_label (CASE_LABEL (default_case));
+ gimplify_seq_add_stmt (&switch_body_seq, new_default);
+ }
+ }
gimple_switch = gimple_build_switch_vec (SWITCH_COND (switch_expr),
default_case, labels);
if (*label_p == NULL_TREE)
{
- tree label = create_artificial_label ();
+ tree label = create_artificial_label (UNKNOWN_LOCATION);
*label_p = label;
}
gimplify_conversion (tree *expr_p)
{
tree tem;
+ location_t loc = EXPR_LOCATION (*expr_p);
gcc_assert (CONVERT_EXPR_P (*expr_p));
-
+
/* Then strip away all but the outermost conversion. */
STRIP_SIGN_NOPS (TREE_OPERAND (*expr_p, 0));
&& POINTER_TYPE_P (TREE_TYPE (*expr_p))
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (*expr_p, 0)))
&& (tem = maybe_fold_offset_to_address
- (TREE_OPERAND (*expr_p, 0),
- integer_zero_node, TREE_TYPE (*expr_p))) != NULL_TREE)
+ (EXPR_LOCATION (*expr_p), TREE_OPERAND (*expr_p, 0),
+ integer_zero_node, TREE_TYPE (*expr_p))) != NULL_TREE)
*expr_p = tem;
/* If we still have a conversion at the toplevel,
/* If we have a conversion to a non-register type force the
use of a VIEW_CONVERT_EXPR instead. */
- if (!is_gimple_reg_type (TREE_TYPE (*expr_p)))
- *expr_p = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (*expr_p),
- TREE_OPERAND (*expr_p, 0));
+ if (CONVERT_EXPR_P (*expr_p) && !is_gimple_reg_type (TREE_TYPE (*expr_p)))
+ *expr_p = fold_build1_loc (loc, VIEW_CONVERT_EXPR, TREE_TYPE (*expr_p),
+ TREE_OPERAND (*expr_p, 0));
return GS_OK;
}
VEC(tree,heap) *stack;
enum gimplify_status ret = GS_OK, tret;
int i;
+ location_t loc = EXPR_LOCATION (*expr_p);
/* Create a stack of the subexpressions so later we can walk them in
order from inner to outer. */
restart:
/* Fold INDIRECT_REFs now to turn them into ARRAY_REFs. */
if (TREE_CODE (*p) == INDIRECT_REF)
- *p = fold_indirect_ref (*p);
+ *p = fold_indirect_ref_loc (loc, *p);
if (handled_component_p (*p))
;
/* Divide the element size by the alignment of the element
type (above). */
- elmt_size = size_binop (EXACT_DIV_EXPR, elmt_size, factor);
+ elmt_size = size_binop_loc (loc, EXACT_DIV_EXPR, elmt_size, factor);
if (!is_gimple_min_invariant (elmt_size))
{
= size_int (DECL_OFFSET_ALIGN (field) / BITS_PER_UNIT);
/* Divide the offset by its alignment. */
- offset = size_binop (EXACT_DIV_EXPR, offset, factor);
+ offset = size_binop_loc (loc, EXACT_DIV_EXPR, offset, factor);
if (!is_gimple_min_invariant (offset))
{
bool postfix;
enum tree_code arith_code;
enum gimplify_status ret;
+ location_t loc = EXPR_LOCATION (*expr_p);
code = TREE_CODE (*expr_p);
if (!is_gimple_min_lval (lvalue))
{
mark_addressable (lvalue);
- lvalue = build_fold_addr_expr (lvalue);
+ lvalue = build_fold_addr_expr_loc (input_location, lvalue);
gimplify_expr (&lvalue, pre_p, post_p, is_gimple_val, fb_rvalue);
- lvalue = build_fold_indirect_ref (lvalue);
+ lvalue = build_fold_indirect_ref_loc (input_location, lvalue);
}
ret = gimplify_expr (&lhs, pre_p, post_p, is_gimple_val, fb_rvalue);
if (ret == GS_ERROR)
/* For POINTERs increment, use POINTER_PLUS_EXPR. */
if (POINTER_TYPE_P (TREE_TYPE (lhs)))
{
- rhs = fold_convert (sizetype, rhs);
+ rhs = fold_convert_loc (loc, sizetype, rhs);
if (arith_code == MINUS_EXPR)
- rhs = fold_build1 (NEGATE_EXPR, TREE_TYPE (rhs), rhs);
+ rhs = fold_build1_loc (loc, NEGATE_EXPR, TREE_TYPE (rhs), rhs);
arith_code = POINTER_PLUS_EXPR;
}
/* If this is a variable sized type, we must remember the size. */
maybe_with_size_expr (arg_p);
+ /* FIXME diagnostics: This will mess up gcc.dg/Warray-bounds.c. */
/* Make sure arguments have the same location as the function call
itself. */
protected_set_expr_location (*arg_p, call_location);
int i, nargs;
gimple call;
bool builtin_va_start_p = FALSE;
+ location_t loc = EXPR_LOCATION (*expr_p);
gcc_assert (TREE_CODE (*expr_p) == CALL_EXPR);
fndecl = get_callee_fndecl (*expr_p);
if (fndecl && DECL_BUILT_IN (fndecl))
{
- tree new_tree = fold_call_expr (*expr_p, !want_value);
+ tree new_tree = fold_call_expr (input_location, *expr_p, !want_value);
if (new_tree && new_tree != *expr_p)
{
if (call_expr_nargs (*expr_p) < 2)
{
error ("too few arguments to function %<va_start%>");
- *expr_p = build_empty_stmt ();
+ *expr_p = build_empty_stmt (EXPR_LOCATION (*expr_p));
return GS_OK;
}
if (fold_builtin_next_arg (*expr_p, true))
{
- *expr_p = build_empty_stmt ();
+ *expr_p = build_empty_stmt (EXPR_LOCATION (*expr_p));
return GS_OK;
}
}
tree call = *expr_p;
--nargs;
- *expr_p = build_call_array (TREE_TYPE (call), CALL_EXPR_FN (call),
- nargs, CALL_EXPR_ARGP (call));
+ *expr_p = build_call_array_loc (loc, TREE_TYPE (call),
+ CALL_EXPR_FN (call),
+ nargs, CALL_EXPR_ARGP (call));
/* Copy all CALL_EXPR flags, location and block, except
CALL_EXPR_VA_ARG_PACK flag. */
= CALL_EXPR_RETURN_SLOT_OPT (call);
CALL_FROM_THUNK_P (*expr_p) = CALL_FROM_THUNK_P (call);
CALL_CANNOT_INLINE_P (*expr_p) = CALL_CANNOT_INLINE_P (call);
- SET_EXPR_LOCUS (*expr_p, EXPR_LOCUS (call));
+ SET_EXPR_LOCATION (*expr_p, EXPR_LOCATION (call));
TREE_BLOCK (*expr_p) = TREE_BLOCK (call);
/* Set CALL_EXPR_VA_ARG_PACK. */
/* Try this again in case gimplification exposed something. */
if (ret != GS_ERROR)
{
- tree new_tree = fold_call_expr (*expr_p, !want_value);
+ tree new_tree = fold_call_expr (input_location, *expr_p, !want_value);
if (new_tree && new_tree != *expr_p)
{
gimple_boolify (tree expr)
{
tree type = TREE_TYPE (expr);
+ location_t loc = EXPR_LOCATION (expr);
if (TREE_CODE (type) == BOOLEAN_TYPE)
return expr;
default:
/* Other expressions that get here must have boolean values, but
might need to be converted to the appropriate mode. */
- return fold_convert (boolean_type_node, expr);
+ return fold_convert_loc (loc, boolean_type_node, expr);
}
}
gimple gimple_cond;
enum tree_code pred_code;
gimple_seq seq = NULL;
+ location_t loc = EXPR_LOCATION (*expr_p);
type = TREE_TYPE (expr);
if (TREE_TYPE (TREE_OPERAND (expr, 1)) != void_type_node)
TREE_OPERAND (expr, 1) =
- build_fold_addr_expr (TREE_OPERAND (expr, 1));
+ build_fold_addr_expr_loc (loc, TREE_OPERAND (expr, 1));
if (TREE_TYPE (TREE_OPERAND (expr, 2)) != void_type_node)
TREE_OPERAND (expr, 2) =
- build_fold_addr_expr (TREE_OPERAND (expr, 2));
+ build_fold_addr_expr_loc (loc, TREE_OPERAND (expr, 2));
tmp = create_tmp_var (type, "iftmp");
expr = build3 (COND_EXPR, void_type_node, TREE_OPERAND (expr, 0),
TREE_OPERAND (expr, 1), TREE_OPERAND (expr, 2));
- result = build_fold_indirect_ref (tmp);
+ result = build_fold_indirect_ref_loc (loc, tmp);
}
/* Build the then clause, 't1 = a;'. But don't build an assignment
have_then_clause_p = true;
}
else
- label_true = create_artificial_label ();
+ label_true = create_artificial_label (UNKNOWN_LOCATION);
if (TREE_OPERAND (expr, 2) != NULL
&& TREE_CODE (TREE_OPERAND (expr, 2)) == GOTO_EXPR
&& TREE_CODE (GOTO_DESTINATION (TREE_OPERAND (expr, 2))) == LABEL_DECL
have_else_clause_p = true;
}
else
- label_false = create_artificial_label ();
+ label_false = create_artificial_label (UNKNOWN_LOCATION);
gimple_cond_get_ops_from_tree (COND_EXPR_COND (expr), &pred_code, &arm1,
&arm2);
&& gimple_seq_may_fallthru (seq))
{
gimple g;
- label_cont = create_artificial_label ();
+ label_cont = create_artificial_label (UNKNOWN_LOCATION);
g = gimple_build_goto (label_cont);
{
tree t, to, to_ptr, from, from_ptr;
gimple gs;
+ location_t loc = EXPR_LOCATION (*expr_p);
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));
+ from_ptr = build_fold_addr_expr_loc (loc, from);
+ gimplify_arg (&from_ptr, seq_p, loc);
mark_addressable (to);
- to_ptr = build_fold_addr_expr (to);
- gimplify_arg (&to_ptr, seq_p, EXPR_LOCATION (*expr_p));
+ to_ptr = build_fold_addr_expr_loc (loc, to);
+ gimplify_arg (&to_ptr, seq_p, loc);
t = implicit_built_in_decls[BUILT_IN_MEMCPY];
{
tree t, from, to, to_ptr;
gimple gs;
+ location_t loc = EXPR_LOCATION (*expr_p);
/* Assert our assumptions, to abort instead of producing wrong code
silently if they are not met. Beware that the RHS CONSTRUCTOR might
/* Now proceed. */
to = TREE_OPERAND (*expr_p, 0);
- to_ptr = build_fold_addr_expr (to);
- gimplify_arg (&to_ptr, seq_p, EXPR_LOCATION (*expr_p));
+ to_ptr = build_fold_addr_expr_loc (loc, to);
+ gimplify_arg (&to_ptr, seq_p, loc);
t = implicit_built_in_decls[BUILT_IN_MEMSET];
gs = gimple_build_call (t, 3, to_ptr, integer_zero_node, size);
tree loop_entry_label, loop_exit_label, fall_thru_label;
tree var, var_type, cref, tmp;
- loop_entry_label = create_artificial_label ();
- loop_exit_label = create_artificial_label ();
- fall_thru_label = create_artificial_label ();
+ loop_entry_label = create_artificial_label (UNKNOWN_LOCATION);
+ loop_exit_label = create_artificial_label (UNKNOWN_LOCATION);
+ fall_thru_label = create_artificial_label (UNKNOWN_LOCATION);
/* Create and initialize the index variable. */
var_type = TREE_TYPE (upper);
gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
bool want_value, bool notify_temp_creation)
{
- tree object, new_ctor;
- tree ctor = TREE_OPERAND (*expr_p, 1);
- tree type = TREE_TYPE (ctor);
+ tree object, ctor, type;
enum gimplify_status ret;
VEC(constructor_elt,gc) *elts;
- if (TREE_CODE (ctor) != CONSTRUCTOR)
- return GS_UNHANDLED;
+ gcc_assert (TREE_CODE (TREE_OPERAND (*expr_p, 1)) == CONSTRUCTOR);
if (!notify_temp_creation)
{
}
object = TREE_OPERAND (*expr_p, 0);
- new_ctor = optimize_compound_literals_in_ctor (ctor);
- elts = CONSTRUCTOR_ELTS (new_ctor);
+ ctor = TREE_OPERAND (*expr_p, 1) =
+ optimize_compound_literals_in_ctor (TREE_OPERAND (*expr_p, 1));
+ type = TREE_TYPE (ctor);
+ elts = CONSTRUCTOR_ELTS (ctor);
ret = GS_ALL_DONE;
switch (TREE_CODE (type))
tree *to_p = &TREE_OPERAND (*expr_p, 0);
enum gimplify_status ret = GS_UNHANDLED;
gimple assign;
+ location_t loc = EXPR_LOCATION (*expr_p);
gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR
|| TREE_CODE (*expr_p) == INIT_EXPR);
{
STRIP_USELESS_TYPE_CONVERSION (*from_p);
if (!useless_type_conversion_p (TREE_TYPE (*to_p), TREE_TYPE (*from_p)))
- *from_p = fold_convert (TREE_TYPE (*to_p), *from_p);
+ *from_p = fold_convert_loc (loc, TREE_TYPE (*to_p), *from_p);
}
/* See if any simplifications can be done based on what the RHS is. */
gimple_call_set_lhs (assign, *to_p);
}
else
- assign = gimple_build_assign (*to_p, *from_p);
+ {
+ assign = gimple_build_assign (*to_p, *from_p);
+ gimple_set_location (assign, EXPR_LOCATION (*expr_p));
+ }
gimplify_seq_add_stmt (pre_p, assign);
tree op0 = TREE_OPERAND (*expr_p, 0);
tree op1 = TREE_OPERAND (*expr_p, 1);
tree t, arg, dest, src;
+ location_t loc = EXPR_LOCATION (*expr_p);
arg = TYPE_SIZE_UNIT (TREE_TYPE (op0));
arg = unshare_expr (arg);
arg = SUBSTITUTE_PLACEHOLDER_IN_EXPR (arg, op0);
- src = build_fold_addr_expr (op1);
- dest = build_fold_addr_expr (op0);
+ src = build_fold_addr_expr_loc (loc, op1);
+ dest = build_fold_addr_expr_loc (loc, op0);
t = implicit_built_in_decls[BUILT_IN_MEMCMP];
- t = build_call_expr (t, 3, dest, src, arg);
+ t = build_call_expr_loc (loc, t, 3, dest, src, arg);
*expr_p
= build2 (TREE_CODE (*expr_p), TREE_TYPE (*expr_p), t, integer_zero_node);
static enum gimplify_status
gimplify_scalar_mode_aggregate_compare (tree *expr_p)
{
+ location_t loc = EXPR_LOCATION (*expr_p);
tree op0 = TREE_OPERAND (*expr_p, 0);
tree op1 = TREE_OPERAND (*expr_p, 1);
tree type = TREE_TYPE (op0);
tree scalar_type = lang_hooks.types.type_for_mode (TYPE_MODE (type), 1);
- op0 = fold_build1 (VIEW_CONVERT_EXPR, scalar_type, op0);
- op1 = fold_build1 (VIEW_CONVERT_EXPR, scalar_type, op1);
+ op0 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, scalar_type, op0);
+ op1 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, scalar_type, op1);
*expr_p
- = fold_build2 (TREE_CODE (*expr_p), TREE_TYPE (*expr_p), op0, op1);
+ = fold_build2_loc (loc, TREE_CODE (*expr_p), TREE_TYPE (*expr_p), op0, op1);
return GS_OK;
}
tree type = TREE_TYPE (*expr_p);
*expr_p = build3 (COND_EXPR, type, *expr_p,
- fold_convert (type, boolean_true_node),
- fold_convert (type, boolean_false_node));
+ fold_convert_loc (locus, type, boolean_true_node),
+ fold_convert_loc (locus, type, boolean_false_node));
SET_EXPR_LOCATION (*expr_p, locus);
tree expr = *expr_p;
tree op0 = TREE_OPERAND (expr, 0);
enum gimplify_status ret;
+ location_t loc = EXPR_LOCATION (*expr_p);
switch (TREE_CODE (op0))
{
tree t_op00 = TREE_TYPE (op00);
if (!useless_type_conversion_p (t_expr, t_op00))
- op00 = fold_convert (TREE_TYPE (expr), op00);
+ op00 = fold_convert_loc (loc, TREE_TYPE (expr), op00);
*expr_p = op00;
ret = GS_OK;
}
if (tree_ssa_useless_type_conversion (TREE_OPERAND (op0, 0)))
op0 = TREE_OPERAND (op0, 0);
- *expr_p = fold_convert (TREE_TYPE (expr),
- build_fold_addr_expr (TREE_OPERAND (op0, 0)));
+ *expr_p = fold_convert_loc (loc, TREE_TYPE (expr),
+ build_fold_addr_expr_loc (loc,
+ TREE_OPERAND (op0, 0)));
ret = GS_OK;
break;
for (link = ASM_CLOBBERS (expr); link; ++i, link = TREE_CHAIN (link))
VEC_safe_push (tree, gc, clobbers, link);
-
- stmt = gimple_build_asm_vec (TREE_STRING_POINTER (ASM_STRING (expr)),
- inputs, outputs, clobbers);
- gimple_asm_set_volatile (stmt, ASM_VOLATILE_P (expr));
- gimple_asm_set_input (stmt, ASM_INPUT_P (expr));
+ /* Do not add ASMs with errors to the gimple IL stream. */
+ if (ret != GS_ERROR)
+ {
+ stmt = gimple_build_asm_vec (TREE_STRING_POINTER (ASM_STRING (expr)),
+ inputs, outputs, clobbers);
- gimplify_seq_add_stmt (pre_p, stmt);
+ gimple_asm_set_volatile (stmt, ASM_VOLATILE_P (expr));
+ gimple_asm_set_input (stmt, ASM_INPUT_P (expr));
+
+ gimplify_seq_add_stmt (pre_p, stmt);
+ }
return ret;
}
switch (default_kind)
{
case OMP_CLAUSE_DEFAULT_NONE:
- error ("%qs not specified in enclosing parallel",
- IDENTIFIER_POINTER (DECL_NAME (decl)));
- error ("%Henclosing parallel", &ctx->location);
+ error ("%qE not specified in enclosing parallel",
+ DECL_NAME (decl));
+ error_at (ctx->location, "enclosing parallel");
/* FALLTHRU */
case OMP_CLAUSE_DEFAULT_SHARED:
flags |= GOVD_SHARED;
{
if (ctx == gimplify_omp_ctxp)
{
- error ("iteration variable %qs should be private",
- IDENTIFIER_POINTER (DECL_NAME (decl)));
+ error ("iteration variable %qE should be private",
+ DECL_NAME (decl));
n->value = GOVD_PRIVATE;
return true;
}
&& gimplify_omp_ctxp->outer_context == ctx)))
{
if ((n->value & GOVD_FIRSTPRIVATE) != 0)
- error ("iteration variable %qs should not be firstprivate",
- IDENTIFIER_POINTER (DECL_NAME (decl)));
+ error ("iteration variable %qE should not be firstprivate",
+ DECL_NAME (decl));
else if ((n->value & GOVD_REDUCTION) != 0)
- error ("iteration variable %qs should not be reduction",
- IDENTIFIER_POINTER (DECL_NAME (decl)));
+ error ("iteration variable %qE should not be reduction",
+ DECL_NAME (decl));
}
return (ctx == gimplify_omp_ctxp
|| (ctx->region_type == ORT_COMBINED_PARALLEL
&& region_type == ORT_WORKSHARE
&& omp_check_private (ctx, decl))
{
- error ("%s variable %qs is private in outer context",
- check_non_private, IDENTIFIER_POINTER (DECL_NAME (decl)));
+ error ("%s variable %qE is private in outer context",
+ check_non_private, DECL_NAME (decl));
remove = true;
}
break;
else
gcc_unreachable ();
- clause = build_omp_clause (code);
+ clause = build_omp_clause (input_location, code);
OMP_CLAUSE_DECL (clause) = decl;
OMP_CLAUSE_CHAIN (clause) = *list_p;
if (private_debug)
break;
case INDIRECT_REF:
- *expr_p = fold_indirect_ref (*expr_p);
+ *expr_p = fold_indirect_ref_loc (input_location, *expr_p);
if (*expr_p != save_expr)
break;
/* else fall through. */
}
break;
+ case TARGET_MEM_REF:
+ {
+ enum gimplify_status r0 = GS_ALL_DONE, r1 = GS_ALL_DONE;
+
+ if (TMR_SYMBOL (*expr_p))
+ r0 = gimplify_expr (&TMR_SYMBOL (*expr_p), pre_p,
+ post_p, is_gimple_lvalue, fb_either);
+ else if (TMR_BASE (*expr_p))
+ r0 = gimplify_expr (&TMR_BASE (*expr_p), pre_p,
+ post_p, is_gimple_val, fb_either);
+ if (TMR_INDEX (*expr_p))
+ r1 = gimplify_expr (&TMR_INDEX (*expr_p), pre_p,
+ post_p, is_gimple_val, fb_rvalue);
+ /* TMR_STEP and TMR_OFFSET are always integer constants. */
+ ret = MIN (r0, r1);
+ }
+ break;
+
case NON_LVALUE_EXPR:
/* This should have been stripped above. */
gcc_unreachable ();
gimplify_and_add (EH_FILTER_FAILURE (*expr_p), &failure);
ehf = gimple_build_eh_filter (EH_FILTER_TYPES (*expr_p), failure);
+ gimple_set_no_warning (ehf, TREE_NO_WARNING (*expr_p));
gimple_eh_filter_set_must_not_throw
(ehf, EH_FILTER_MUST_NOT_THROW (*expr_p));
gimplify_seq_add_stmt (pre_p, ehf);
break;
}
- case CHANGE_DYNAMIC_TYPE_EXPR:
- {
- gimple cdt;
-
- ret = gimplify_expr (&CHANGE_DYNAMIC_TYPE_LOCATION (*expr_p),
- pre_p, post_p, is_gimple_reg, fb_lvalue);
- cdt = gimple_build_cdt (CHANGE_DYNAMIC_TYPE_NEW_TYPE (*expr_p),
- CHANGE_DYNAMIC_TYPE_LOCATION (*expr_p));
- gimplify_seq_add_stmt (pre_p, cdt);
- ret = GS_ALL_DONE;
- }
- break;
-
case OBJ_TYPE_REF:
{
enum gimplify_status r0, r1;
*/
if (TREE_CODE (TREE_OPERAND (*expr_p, 1)) == INTEGER_CST
&& (tmp = maybe_fold_offset_to_address
- (TREE_OPERAND (*expr_p, 0), TREE_OPERAND (*expr_p, 1),
- TREE_TYPE (*expr_p))))
+ (EXPR_LOCATION (*expr_p),
+ TREE_OPERAND (*expr_p, 0), TREE_OPERAND (*expr_p, 1),
+ TREE_TYPE (*expr_p))))
{
*expr_p = tmp;
break;
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p,
0),0)))
&& (tmp = maybe_fold_offset_to_address
- (TREE_OPERAND (TREE_OPERAND (*expr_p, 0), 0),
- TREE_OPERAND (*expr_p, 1),
- TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p, 0),
- 0)))))
+ (EXPR_LOCATION (*expr_p),
+ TREE_OPERAND (TREE_OPERAND (*expr_p, 0), 0),
+ TREE_OPERAND (*expr_p, 1),
+ TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p, 0),
+ 0)))))
{
*expr_p = fold_convert (TREE_TYPE (*expr_p), tmp);
break;
/* An lvalue will do. Take the address of the expression, store it
in a temporary, and replace the expression with an INDIRECT_REF of
that temporary. */
- tmp = build_fold_addr_expr (*expr_p);
+ tmp = build_fold_addr_expr_loc (input_location, *expr_p);
gimplify_expr (&tmp, pre_p, post_p, is_gimple_reg, fb_rvalue);
*expr_p = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (tmp)), tmp);
}
/* The postqueue might change the value of the expression between
the initialization and use of the temporary, so we can't use a
formal temp. FIXME do we care? */
- *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p);
+ {
+ *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p);
+ if (TREE_CODE (TREE_TYPE (*expr_p)) == COMPLEX_TYPE
+ || TREE_CODE (TREE_TYPE (*expr_p)) == VECTOR_TYPE)
+ DECL_GIMPLE_REG_P (*expr_p) = 1;
+ }
else
*expr_p = get_formal_tmp_var (*expr_p, pre_p);
}
tmp = build1 (NOP_EXPR, type, expr);
stmt = gimplify_assign (*expr_p, tmp, stmt_p);
if (EXPR_HAS_LOCATION (expr))
- gimple_set_location (stmt, *EXPR_LOCUS (expr));
+ gimple_set_location (stmt, EXPR_LOCATION (expr));
else
gimple_set_location (stmt, input_location);
}
gimple_seq seq;
gimple bind;
+ gcc_assert (!gimple_body (fndecl));
+
oldfn = current_function_decl;
current_function_decl = fndecl;
if (DECL_STRUCT_FUNCTION (fndecl))
}
DECL_SAVED_TREE (fndecl) = NULL_TREE;
+ cfun->curr_properties = PROP_gimple_any;
current_function_decl = oldfn;
pop_cfun ();
DECL_GIMPLE_REG_P (temp) = 1;
if (TREE_CODE (orig_lhs) == SSA_NAME)
orig_lhs = SSA_NAME_VAR (orig_lhs);
- if (TREE_CODE (orig_lhs) == VAR_DECL
- && DECL_BASED_ON_RESTRICT_P (orig_lhs))
- {
- DECL_BASED_ON_RESTRICT_P (temp) = 1;
- SET_DECL_RESTRICT_BASE (temp,
- DECL_GET_RESTRICT_BASE (orig_lhs));
- }
if (gimple_in_ssa_p (cfun))
temp = make_ssa_name (temp, NULL);