+2008-04-23 Paolo Bonzini <bonzini@gnu.org>
+
+ * tree-cfg.c (verify_expr): Check with is_gimple_address. Don't
+ check TREE_INVARIANT.
+ * tree-gimple.c (is_gimple_address): New.
+ (is_gimple_invariant_address): Simplify using decl_address_invariant_p.
+ * tree-gimple.h (is_gimple_address): New.
+ * tree.h (decl_address_invariant_p): New.
+ * tree.c (make_node_stat): Don't set TREE_INVARIANT.
+ (build_string): Likewise.
+ (decl_address_invariant_p): New, from is_gimple_invariant_address.
+ (tree_invariant_p_1): Likewise.
+ (save_expr): Use it.
+ (tree_invariant_p): New.
+ (skip_simple_arithmetic): Use it.
+ (stabilize_reference_1): Use it.
+ (recompute_tree_invariant_for_addr_expr): Don't update TREE_INVARIANT,
+ simplify.
+ (build1_stat): Drop code to compute TREE_INVARIANT.
+ (build2_stat): Drop code to compute TREE_INVARIANT.
+ (build3_stat): Drop code to compute TREE_INVARIANT.
+ (build4_stat): Drop code to compute TREE_INVARIANT.
+ (build5_stat): Drop code to compute TREE_INVARIANT.
+ (build7_stat): Drop code to compute TREE_INVARIANT.
+ (merge_dllimport_decl_attributes): Don't mention TREE_INVARIANT.
+ * tree.h (struct tree_base): Remove invariant_flag.
+ (TREE_INVARIANT): Remove.
+ * builtins.c (build_string_literal): Don't set TREE_INVARIANT.
+ (fold_builtin_expect): Check TREE_CONSTANT.
+ * tree-ssa-ccp.c (fold_stmt_r): Adjust comment.
+ * c-tree.h (c_expr_to_decl): Drop third parameter.
+ * c-typeck.c (build_external_ref): Don't set TREE_INVARIANT.
+ (build_c_cast): Don't set TREE_INVARIANT.
+ (pop_init_level): Don't set TREE_INVARIANT.
+ (c_objc_common_truthvalue_conversion): Don't set TREE_INVARIANT.
+ * gimplify.c (gimplify_init_ctor_preeval): Add assertion, test
+ TREE_CONSTANT.
+ (gimplify_init_constructor): Don't set TREE_INVARIANT.
+ (gimplify_addr_expr): Adjust comment.
+ * tree-mudflap.c (mf_build_string):
+ * print-tree.c (print_node): Don't print TREE_INVARIANT.
+ * tree-nested.c (convert_nonlocal_reference): Adjust comment.
+ * c-common.c (fix_string_type): Don't set TREE_INVARIANT.
+ * langhooks-def.h (lhd_expr_to_decl): Drop third parameter.
+ * langhooks.c (lhd_expr_to_decl): Drop third parameter.
+ * langhooks.h (struct lang_hooks): Drop third parameter from
+ expr_to_decl.
+
2008-04-23 Richard Guenther <rguenther@suse.de>
PR tree-optimization/27799
+2008-04-23 Paolo Bonzini <bonzini@gnu.org>
+
+ * trans.c (Attribute_to_gnu): Don't set TREE_INVARIANT.
+ (call_to_gnu): Don't set TREE_INVARIANT.
+ * utils2.c (gnat_build_constructor): Don't set TREE_INVARIANT.
+
2008-04-22 Joel Sherrill <joel.sherrill@oarcorp.com>
* s-osinte-rtems.adb: Add sigalstack function.
t = build2 (FDESC_EXPR, TREE_TYPE (gnu_field), gnu_prefix,
build_int_cst (NULL_TREE, i));
TREE_CONSTANT (t) = 1;
- TREE_INVARIANT (t) = 1;
}
else
t = build3 (COMPONENT_REF, ptr_void_ftype, gnu_result,
gnu_result
= build1 (SAVE_EXPR, TREE_TYPE (gnu_result), gnu_result);
TREE_SIDE_EFFECTS (gnu_result) = 1;
- TREE_INVARIANT (gnu_result) = 1;
if (attribute == Attr_First)
pa->first = gnu_result;
else if (attribute == Attr_Last)
used as the object and copied back after the call if needed. */
gnu_name = build1 (SAVE_EXPR, TREE_TYPE (gnu_name), gnu_name);
TREE_SIDE_EFFECTS (gnu_name) = 1;
- TREE_INVARIANT (gnu_name) = 1;
/* Set up to move the copy back to the original. */
if (Ekind (gnat_formal) != E_In_Parameter)
}
result = build_constructor_from_list (type, list);
- TREE_CONSTANT (result) = TREE_INVARIANT (result)
- = TREE_STATIC (result) = allconstant;
+ TREE_CONSTANT (result) = TREE_STATIC (result) = allconstant;
TREE_SIDE_EFFECTS (result) = side_effects;
TREE_READONLY (result) = TYPE_READONLY (type) || allconstant;
return result;
type = build_array_type (elem, index);
TREE_TYPE (t) = type;
TREE_CONSTANT (t) = 1;
- TREE_INVARIANT (t) = 1;
TREE_READONLY (t) = 1;
TREE_STATIC (t) = 1;
}
/* If the argument isn't invariant then there's nothing else we can do. */
- if (!TREE_INVARIANT (arg0))
+ if (!TREE_CONSTANT (arg0))
return NULL_TREE;
/* If we expect that a comparison against the argument will fold to
TREE_TYPE (value) = a_type;
TREE_CONSTANT (value) = 1;
- TREE_INVARIANT (value) = 1;
TREE_READONLY (value) = 1;
TREE_STATIC (value) = 1;
return value;
extern tree c_finish_goto_ptr (tree);
extern void c_begin_vm_scope (unsigned int);
extern void c_end_vm_scope (unsigned int);
-extern tree c_expr_to_decl (tree, bool *, bool *, bool *);
+extern tree c_expr_to_decl (tree, bool *, bool *);
extern tree c_begin_omp_parallel (void);
extern tree c_finish_omp_parallel (tree, tree);
extern tree c_finish_omp_clauses (tree);
used_types_insert (TREE_TYPE (ref));
ref = DECL_INITIAL (ref);
TREE_CONSTANT (ref) = 1;
- TREE_INVARIANT (ref) = 1;
}
else if (current_function_decl != 0
&& !DECL_FILE_SCOPE_P (current_function_decl)
build_constructor_single (type, field, value),
true, 0);
TREE_CONSTANT (t) = TREE_CONSTANT (value);
- TREE_INVARIANT (t) = TREE_INVARIANT (value);
return t;
}
error ("cast to union type from type not present in union");
ret.value = build_constructor (constructor_type,
constructor_elements);
if (constructor_constant)
- TREE_CONSTANT (ret.value) = TREE_INVARIANT (ret.value) = 1;
+ TREE_CONSTANT (ret.value) = 1;
if (constructor_constant && constructor_simple)
TREE_STATIC (ret.value) = 1;
}
required. */
tree
-c_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED,
- bool *ti ATTRIBUTE_UNUSED, bool *se)
+c_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se)
{
if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
{
+2008-04-23 Paolo Bonzini <bonzini@gnu.org>
+
+ * typeck.c (get_member_function_from_ptrfunc): Don't set TREE_INVARIANT.
+ (build_ptrmemfunc1): Don't set TREE_INVARIANT.
+ * init.c (build_zero_init): Don't set TREE_INVARIANT.
+ * class.c (build_base_path): Don't set TREE_INVARIANT.
+ (build_vtbl_ref_1): Don't set TREE_INVARIANT.
+ (build_vtbl_initializer): Don't set TREE_INVARIANT.
+ * decl.c (build_enumerator): Don't set TREE_INVARIANT.
+ * rtti.c (tinfo_base_init): Don't set TREE_INVARIANT.
+ (generic_initializer): Don't set TREE_INVARIANT.
+ (ptr_initializer): Don't set TREE_INVARIANT.
+ (ptm_initializer): Don't set TREE_INVARIANT.
+ (class_initializer): Don't set TREE_INVARIANT.
+ * typeck2.c (process_init_constructor): Don't set TREE_INVARIANT.
+ * pt.c (push_inline_template_parms_recursive): Don't set TREE_INVARIANT.
+ (build_template_parm_index): Don't set TREE_INVARIANT.
+ (reduce_template_parm_level): Don't set TREE_INVARIANT.
+ (process_template_parm): Don't set TREE_INVARIANT.
+
2008-04-22 Jason Merrill <jason@redhat.com>
PR c++/35316
v_offset);
v_offset = cp_build_indirect_ref (v_offset, NULL, tf_warning_or_error);
TREE_CONSTANT (v_offset) = 1;
- TREE_INVARIANT (v_offset) = 1;
offset = convert_to_integer (ptrdiff_type_node,
size_diffop (offset,
aref = build_array_ref (vtbl, idx);
TREE_CONSTANT (aref) |= TREE_CONSTANT (vtbl) && TREE_CONSTANT (idx);
- TREE_INVARIANT (aref) = TREE_CONSTANT (aref);
return aref;
}
TREE_OPERAND (init, 0),
build_int_cst (NULL_TREE, i));
TREE_CONSTANT (fdesc) = 1;
- TREE_INVARIANT (fdesc) = 1;
vfun_inits = tree_cons (NULL_TREE, fdesc, vfun_inits);
}
DECL_CONTEXT (decl) = FROB_CONTEXT (context);
TREE_CONSTANT (decl) = 1;
- TREE_INVARIANT (decl) = 1;
TREE_READONLY (decl) = 1;
DECL_INITIAL (decl) = value;
/* In all cases, the initializer is a constant. */
if (init)
- {
- TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
- }
+ TREE_CONSTANT (init) = 1;
return init;
}
TREE_TYPE (parm));
DECL_ARTIFICIAL (decl) = 1;
TREE_CONSTANT (decl) = 1;
- TREE_INVARIANT (decl) = 1;
TREE_READONLY (decl) = 1;
DECL_INITIAL (decl) = DECL_INITIAL (parm);
SET_DECL_TEMPLATE_PARM_P (decl);
TEMPLATE_PARM_DECL (t) = decl;
TREE_TYPE (t) = type;
TREE_CONSTANT (t) = TREE_CONSTANT (decl);
- TREE_INVARIANT (t) = TREE_INVARIANT (decl);
TREE_READONLY (t) = TREE_READONLY (decl);
return t;
decl = build_decl (TREE_CODE (orig_decl), DECL_NAME (orig_decl), type);
TREE_CONSTANT (decl) = TREE_CONSTANT (orig_decl);
- TREE_INVARIANT (decl) = TREE_INVARIANT (orig_decl);
TREE_READONLY (decl) = TREE_READONLY (orig_decl);
DECL_ARTIFICIAL (decl) = 1;
SET_DECL_TEMPLATE_PARM_P (decl);
/* A template parameter is not modifiable. */
TREE_CONSTANT (parm) = 1;
- TREE_INVARIANT (parm) = 1;
TREE_READONLY (parm) = 1;
decl = build_decl (CONST_DECL, DECL_NAME (parm), TREE_TYPE (parm));
TREE_CONSTANT (decl) = 1;
- TREE_INVARIANT (decl) = 1;
TREE_READONLY (decl) = 1;
DECL_INITIAL (parm) = DECL_INITIAL (decl)
= build_template_parm_index (idx, processing_template_decl,
init = build_constructor_from_list (NULL_TREE, nreverse (init));
TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
TREE_STATIC (init) = 1;
init = tree_cons (NULL_TREE, init, NULL_TREE);
init = build_constructor_from_list (NULL_TREE, init);
TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
TREE_STATIC (init) = 1;
return init;
}
init = build_constructor_from_list (NULL_TREE, nreverse (init));
TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
TREE_STATIC (init) = 1;
return init;
}
init = build_constructor_from_list (NULL_TREE, nreverse (init));
TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
TREE_STATIC (init) = 1;
return init;
}
TREE_CHAIN (init) = trail;
init = build_constructor_from_list (NULL_TREE, init);
TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
TREE_STATIC (init) = 1;
return init;
}
fold_convert (sizetype, idx));
e2 = cp_build_indirect_ref (e2, NULL, tf_warning_or_error);
TREE_CONSTANT (e2) = 1;
- TREE_INVARIANT (e2) = 1;
/* When using function descriptors, the address of the
vtable entry is treated as a function pointer. */
CONSTRUCTOR_APPEND_ELT(v, delta_field, delta);
u = build_constructor (type, v);
TREE_CONSTANT (u) = TREE_CONSTANT (pfn) & TREE_CONSTANT (delta);
- TREE_INVARIANT (u) = TREE_INVARIANT (pfn) & TREE_INVARIANT (delta);
TREE_STATIC (u) = (TREE_CONSTANT (u)
&& (initializer_constant_valid_p (pfn, TREE_TYPE (pfn))
!= NULL_TREE)
if (!(flags & PICFLAG_NOT_ALL_CONSTANT))
{
TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
if (!(flags & PICFLAG_NOT_ALL_SIMPLE))
TREE_STATIC (init) = 1;
}
+2008-04-23 Paolo Bonzini <bonzini@gnu.org>
+
+ * trans-expr.c (gfc_conv_structure): Don't set TREE_INVARIANT.
+ * trans-array.c (gfc_build_null_descriptor): Don't set TREE_INVARIANT.
+ (gfc_trans_array_constructor_value): Don't set TREE_INVARIANT.
+ (gfc_build_constant_array_constructor): Don't set TREE_INVARIANT.
+ (gfc_conv_array_initializer): Don't set TREE_INVARIANT.
+ * trans-common.c (get_init_field): Don't set TREE_INVARIANT.
+ (create_common): Don't set TREE_INVARIANT.
+ * trans-stmt.c (gfc_trans_character_select): Don't set TREE_INVARIANT.
+ * trans-decl.c (gfc_generate_function_code): Don't set TREE_INVARIANT.
+
2008-04-21 Steve Ellcey <sje@cup.hp.com>
* f95-lang.c (gfc_init_decl_processing): use ptr_mode instead of Pmode.
/* Set a NULL data pointer. */
tmp = build_constructor_single (type, field, null_pointer_node);
TREE_CONSTANT (tmp) = 1;
- TREE_INVARIANT (tmp) = 1;
/* All other fields are ignored. */
return tmp;
init = build_constructor_from_list (tmptype, nreverse (list));
TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
TREE_STATIC (init) = 1;
/* Create a static variable to hold the data. */
tmp = gfc_create_var (tmptype, "data");
TREE_STATIC (tmp) = 1;
TREE_CONSTANT (tmp) = 1;
- TREE_INVARIANT (tmp) = 1;
TREE_READONLY (tmp) = 1;
DECL_INITIAL (tmp) = init;
init = tmp;
init = build_constructor_from_list (tmptype, nreverse (list));
TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
TREE_STATIC (init) = 1;
tmp = gfc_create_var (tmptype, "A");
TREE_STATIC (tmp) = 1;
TREE_CONSTANT (tmp) = 1;
- TREE_INVARIANT (tmp) = 1;
TREE_READONLY (tmp) = 1;
DECL_INITIAL (tmp) = init;
/* Create a constructor from the list of elements. */
tmp = build_constructor (type, v);
TREE_CONSTANT (tmp) = 1;
- TREE_INVARIANT (tmp) = 1;
return tmp;
}
init = build_constructor (TREE_TYPE (field), v);
TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
*field_init = init;
gcc_assert (!VEC_empty (constructor_elt, v));
ctor = build_constructor (union_type, v);
TREE_CONSTANT (ctor) = 1;
- TREE_INVARIANT (ctor) = 1;
TREE_STATIC (ctor) = 1;
DECL_INITIAL (decl) = ctor;
6)));
array = build_constructor_from_list (array_type, nreverse (array));
TREE_CONSTANT (array) = 1;
- TREE_INVARIANT (array) = 1;
TREE_STATIC (array) = 1;
/* Create a static variable to hold the jump table. */
var = gfc_create_var (array_type, "options");
TREE_CONSTANT (var) = 1;
- TREE_INVARIANT (var) = 1;
TREE_STATIC (var) = 1;
TREE_READONLY (var) = 1;
DECL_INITIAL (var) = array;
}
se->expr = build_constructor (type, v);
if (init)
- {
- TREE_CONSTANT(se->expr) = 1;
- TREE_INVARIANT(se->expr) = 1;
- }
+ TREE_CONSTANT (se->expr) = 1;
}
init = build_constructor_from_list (type, nreverse(init));
TREE_CONSTANT (init) = 1;
- TREE_INVARIANT (init) = 1;
TREE_STATIC (init) = 1;
/* Create a static variable to hold the jump table. */
tmp = gfc_create_var (type, "jumptable");
TREE_CONSTANT (tmp) = 1;
- TREE_INVARIANT (tmp) = 1;
TREE_STATIC (tmp) = 1;
TREE_READONLY (tmp) = 1;
DECL_INITIAL (tmp) = init;
{
enum gimplify_status one;
- /* If the value is invariant, then there's nothing to pre-evaluate.
- But ensure it doesn't have any side-effects since a SAVE_EXPR is
- invariant but has side effects and might contain a reference to
- the object we're initializing. */
- if (TREE_INVARIANT (*expr_p) && !TREE_SIDE_EFFECTS (*expr_p))
- return;
+ /* If the value is constant, then there's nothing to pre-evaluate. */
+ if (TREE_CONSTANT (*expr_p))
+ {
+ /* Ensure it does not have side effects, it might contain a reference to
+ the object we're initializing. */
+ gcc_assert (!TREE_SIDE_EFFECTS (*expr_p));
+ return;
+ }
/* If the type has non-trivial constructors, we can't pre-evaluate. */
if (TREE_ADDRESSABLE (TREE_TYPE (*expr_p)))
break;
TREE_CONSTANT (ctor) = 0;
- TREE_INVARIANT (ctor) = 0;
}
/* Vector types use CONSTRUCTOR all the way through gimple
if (TREE_CODE (op0) == INDIRECT_REF)
goto do_indirect_ref;
- /* Make sure TREE_INVARIANT, TREE_CONSTANT, and TREE_SIDE_EFFECTS
- is set properly. */
+ /* Make sure TREE_CONSTANT and TREE_SIDE_EFFECTS are set properly. */
recompute_tree_invariant_for_addr_expr (expr);
mark_addressable (TREE_OPERAND (expr, 0));
+2008-04-23 Paolo Bonzini <bonzini@gnu.org>
+
+ * class.c (build_utf8_ref): Don't set TREE_INVARIANT.
+ (build_classdollar_field): Don't set TREE_INVARIANT.
+ (get_dispatch_table): Don't set TREE_INVARIANT.
+ (make_class_data): Don't set TREE_INVARIANT.
+ (build_symbol_entry): Don't set TREE_INVARIANT.
+ (emit_symbol_table): Don't set TREE_INVARIANT.
+ * constants.c (build_constant_data_ref): Don't set TREE_INVARIANT.
+ (build_ref_from_constant_pool): Don't set TREE_INVARIANT.
+ * resource.c (compile_resource_data): Don't set TREE_INVARIANT.
+ * expr.c (cache_cpool_data_ref): Don't set TREE_INVARIANT.
+
2008-04-03 Tom Tromey <tromey@redhat.com>
* Make-lang.in (java_OBJS): New variable.
PUSH_FIELD_VALUE (cinit, "data", string);
FINISH_RECORD_CONSTRUCTOR (cinit);
TREE_CONSTANT (cinit) = 1;
- TREE_INVARIANT (cinit) = 1;
/* Generate a unique-enough identifier. */
sprintf(buf, "_Utf%d", ++utf8_count);
/* const */ 1, 0)),
/* const */ 1, 0)));
TREE_STATIC (decl) = 1;
- TREE_INVARIANT (decl) = 1;
TREE_CONSTANT (decl) = 1;
TREE_READONLY (decl) = 1;
TREE_PUBLIC (decl) = 1;
tree fdesc = build2 (FDESC_EXPR, nativecode_ptr_type_node,
method, build_int_cst (NULL_TREE, j));
TREE_CONSTANT (fdesc) = 1;
- TREE_INVARIANT (fdesc) = 1;
list = tree_cons (NULL_TREE, fdesc, list);
}
else
build1 (ADDR_EXPR, symbols_array_ptr_type,
TYPE_OTABLE_SYMS_DECL (type)));
TREE_CONSTANT (TYPE_OTABLE_DECL (type)) = 1;
- TREE_INVARIANT (TYPE_OTABLE_DECL (type)) = 1;
}
if (TYPE_ATABLE_METHODS(type) == NULL_TREE)
{
build1 (ADDR_EXPR, symbols_array_ptr_type,
TYPE_ATABLE_SYMS_DECL (type)));
TREE_CONSTANT (TYPE_ATABLE_DECL (type)) = 1;
- TREE_INVARIANT (TYPE_ATABLE_DECL (type)) = 1;
}
if (TYPE_ITABLE_METHODS(type) == NULL_TREE)
{
build1 (ADDR_EXPR, symbols_array_ptr_type,
TYPE_ITABLE_SYMS_DECL (type)));
TREE_CONSTANT (TYPE_ITABLE_DECL (type)) = 1;
- TREE_INVARIANT (TYPE_ITABLE_DECL (type)) = 1;
}
PUSH_FIELD_VALUE (cons, "catch_classes",
PUSH_FIELD_VALUE (sym, "signature", signature);
FINISH_RECORD_CONSTRUCTOR (sym);
TREE_CONSTANT (sym) = 1;
- TREE_INVARIANT (sym) = 1;
return sym;
}
PUSH_FIELD_VALUE (null_symbol, "signature", null_pointer_node);
FINISH_RECORD_CONSTRUCTOR (null_symbol);
TREE_CONSTANT (null_symbol) = 1;
- TREE_INVARIANT (null_symbol) = 1;
list = tree_cons (NULL_TREE, null_symbol, list);
/* Put the list in the right order and make it a constructor. */
TREE_THIS_NOTRAP (klass) = 1;
data = fold_convert (build_pointer_type (cpool_type), data);
d = build1 (INDIRECT_REF, cpool_type, data);
- TREE_INVARIANT (d) = 1;
return d;
}
i = build_int_cst (NULL_TREE, index);
d = build4 (ARRAY_REF, TREE_TYPE (TREE_TYPE (d)), d, i,
NULL_TREE, NULL_TREE);
- TREE_INVARIANT (d) = 1;
return d;
}
tree cpool_ptr = build_decl (VAR_DECL, NULL_TREE,
build_pointer_type (TREE_TYPE (d)));
java_add_local_var (cpool_ptr);
- TREE_INVARIANT (cpool_ptr) = 1;
TREE_CONSTANT (cpool_ptr) = 1;
java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (cpool_ptr),
PUSH_FIELD_VALUE (rinit, "data", data);
FINISH_RECORD_CONSTRUCTOR (rinit);
TREE_CONSTANT (rinit) = 1;
- TREE_INVARIANT (rinit) = 1;
decl = build_decl (VAR_DECL, java_mangle_resource_name (name), rtype);
TREE_STATIC (decl) = 1;
extern tree lhd_expr_size (const_tree);
extern size_t lhd_tree_size (enum tree_code);
extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT);
-extern tree lhd_expr_to_decl (tree, bool *, bool *, bool *);
+extern tree lhd_expr_to_decl (tree, bool *, bool *);
extern tree lhd_builtin_function (tree decl);
/* Declarations of default tree inlining hooks. */
}
tree
-lhd_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED,
- bool *ti ATTRIBUTE_UNUSED, bool *se ATTRIBUTE_UNUSED)
+lhd_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se ATTRIBUTE_UNUSED)
{
return expr;
}
void (*init_ts) (void);
/* Called by recompute_tree_invariant_for_addr_expr to go from EXPR
- to a contained expression or DECL, possibly updating *TC, *TI or
- *SE if in the process TREE_CONSTANT, TREE_INVARIANT or
- TREE_SIDE_EFFECTS need updating. */
- tree (*expr_to_decl) (tree expr, bool *tc, bool *ti, bool *se);
+ to a contained expression or DECL, possibly updating *TC or *SE
+ if in the process TREE_CONSTANT or TREE_SIDE_EFFECTS need updating. */
+ tree (*expr_to_decl) (tree expr, bool *tc, bool *se);
/* Whenever you add entries here, make sure you adjust langhooks-def.h
and langhooks.c accordingly. */
+2008-04-23 Paolo Bonzini <bonzini@gnu.org>
+
+ * objc-act.c (objc_build_string_object): Don't set TREE_INVARIANT.
+
2008-04-03 Tom Tromey <tromey@redhat.com>
* Make-lang.in (objc_OBJS): New variable.
initlist);
constructor = objc_build_constructor (internal_const_str_type,
nreverse (initlist));
- TREE_INVARIANT (constructor) = true;
if (!flag_next_runtime)
constructor
else if (TYPE_P (node) && TYPE_SIZES_GIMPLIFIED (node))
fputs (" sizes-gimplified", file);
- if (TREE_INVARIANT (node))
- fputs (" invariant", file);
if (TREE_ADDRESSABLE (node))
fputs (" addressable", file);
if (TREE_THIS_VOLATILE (node))
case ADDR_EXPR:
{
- bool old_invariant;
bool old_constant;
bool old_side_effects;
- bool new_invariant;
bool new_constant;
bool new_side_effects;
- old_invariant = TREE_INVARIANT (t);
+ gcc_assert (is_gimple_address (t));
+
old_constant = TREE_CONSTANT (t);
old_side_effects = TREE_SIDE_EFFECTS (t);
recompute_tree_invariant_for_addr_expr (t);
- new_invariant = TREE_INVARIANT (t);
new_side_effects = TREE_SIDE_EFFECTS (t);
new_constant = TREE_CONSTANT (t);
- if (old_invariant != new_invariant)
- {
- error ("invariant not recomputed when ADDR_EXPR changed");
- return t;
- }
-
if (old_constant != new_constant)
{
error ("constant not recomputed when ADDR_EXPR changed");
}
}
+/* Return true if T is a gimple address. */
+
+bool
+is_gimple_address (const_tree t)
+{
+ tree op;
+
+ if (TREE_CODE (t) != ADDR_EXPR)
+ return false;
+
+ op = TREE_OPERAND (t, 0);
+ while (handled_component_p (op))
+ {
+ if ((TREE_CODE (op) == ARRAY_REF
+ || TREE_CODE (op) == ARRAY_RANGE_REF)
+ && !is_gimple_val (TREE_OPERAND (op, 1)))
+ return false;
+
+ op = TREE_OPERAND (op, 0);
+ }
+
+ if (CONSTANT_CLASS_P (op) || INDIRECT_REF_P (op))
+ return true;
+
+ switch (TREE_CODE (op))
+ {
+ case PARM_DECL:
+ case RESULT_DECL:
+ case LABEL_DECL:
+ case FUNCTION_DECL:
+ case VAR_DECL:
+ case CONST_DECL:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
/* Return true if T is a gimple invariant address. */
bool
op = TREE_OPERAND (op, 0);
}
- if (CONSTANT_CLASS_P (op))
- return true;
-
- if (INDIRECT_REF_P (op))
- return false;
-
- switch (TREE_CODE (op))
- {
- case PARM_DECL:
- case RESULT_DECL:
- case LABEL_DECL:
- case FUNCTION_DECL:
- return true;
-
- case VAR_DECL:
- if (((TREE_STATIC (op) || DECL_EXTERNAL (op))
- && ! DECL_DLLIMPORT_P (op))
- || DECL_THREAD_LOCAL_P (op)
- || DECL_CONTEXT (op) == current_function_decl
- || decl_function_context (op) == current_function_decl)
- return true;
- break;
-
- case CONST_DECL:
- if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
- || decl_function_context (op) == current_function_decl)
- return true;
- break;
-
- default:
- gcc_unreachable ();
- }
-
- return false;
+ return CONSTANT_CLASS_P (op) || decl_address_invariant_p (op);
}
/* Return true if T is a GIMPLE minimal invariant. It's a restricted
/* Returns true iff T is any valid GIMPLE lvalue. */
extern bool is_gimple_lvalue (tree);
+/* Returns true iff T is a GIMPLE address. */
+bool is_gimple_address (const_tree);
/* Returns true iff T is a GIMPLE invariant address. */
bool is_gimple_invariant_address (const_tree);
/* Returns true iff T is a valid GIMPLE constant. */
TREE_TYPE (result) = build_array_type
(char_type_node, build_index_type (build_int_cst (NULL_TREE, len)));
TREE_CONSTANT (result) = 1;
- TREE_INVARIANT (result) = 1;
TREE_READONLY (result) = 1;
TREE_STATIC (result) = 1;
{
tree save_context;
- /* If we changed anything, then TREE_INVARIANT is be wrong,
- since we're no longer directly referencing a decl. */
+ /* If we changed anything, we might no longer be directly
+ referencing a decl. */
save_context = current_function_decl;
current_function_decl = info->context;
recompute_tree_invariant_for_addr_expr (t);
return t;
*walk_subtrees = 0;
- /* Set TREE_INVARIANT properly so that the value is properly
- considered constant, and so gets propagated as expected. */
+ /* Make sure the value is properly considered constant, and so gets
+ propagated as expected. */
if (*changed_p)
recompute_tree_invariant_for_addr_expr (expr);
return NULL_TREE;
case tcc_constant:
TREE_CONSTANT (t) = 1;
- TREE_INVARIANT (t) = 1;
break;
case tcc_expression:
memset (s, 0, sizeof (struct tree_common));
TREE_SET_CODE (s, STRING_CST);
TREE_CONSTANT (s) = 1;
- TREE_INVARIANT (s) = 1;
TREE_STRING_LENGTH (s) = len;
memcpy (s->string.str, str, len);
s->string.str[len] = '\0';
return NULL;
}
}
+
\f
+
+
+/* Return whether OP is a DECL whose address is function-invariant. */
+
+bool
+decl_address_invariant_p (const_tree op)
+{
+ /* The conditions below are slightly less strict than the one in
+ staticp. */
+
+ switch (TREE_CODE (op))
+ {
+ case PARM_DECL:
+ case RESULT_DECL:
+ case LABEL_DECL:
+ case FUNCTION_DECL:
+ return true;
+
+ case VAR_DECL:
+ if (((TREE_STATIC (op) || DECL_EXTERNAL (op))
+ && !DECL_DLLIMPORT_P (op))
+ || DECL_THREAD_LOCAL_P (op)
+ || DECL_CONTEXT (op) == current_function_decl
+ || decl_function_context (op) == current_function_decl)
+ return true;
+ break;
+
+ case CONST_DECL:
+ if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
+ || decl_function_context (op) == current_function_decl)
+ return true;
+ break;
+
+ default:
+ break;
+ }
+
+ return false;
+}
+
+
+/* Return true if T is function-invariant (internal function, does
+ not handle arithmetic; that's handled in skip_simple_arithmetic and
+ tree_invariant_p). */
+
+static bool tree_invariant_p (tree t);
+
+static bool
+tree_invariant_p_1 (tree t)
+{
+ tree op;
+
+ if (TREE_CONSTANT (t)
+ || (TREE_READONLY (t) && !TREE_SIDE_EFFECTS (t)))
+ return true;
+
+ switch (TREE_CODE (t))
+ {
+ case SAVE_EXPR:
+ return true;
+
+ case ADDR_EXPR:
+ op = TREE_OPERAND (t, 0);
+ while (handled_component_p (op))
+ {
+ switch (TREE_CODE (op))
+ {
+ case ARRAY_REF:
+ case ARRAY_RANGE_REF:
+ if (!tree_invariant_p (TREE_OPERAND (op, 1))
+ || TREE_OPERAND (op, 2) != NULL_TREE
+ || TREE_OPERAND (op, 3) != NULL_TREE)
+ return false;
+ break;
+
+ case COMPONENT_REF:
+ if (TREE_OPERAND (op, 2) != NULL_TREE)
+ return false;
+ break;
+
+ default:;
+ }
+ op = TREE_OPERAND (op, 0);
+ }
+
+ return CONSTANT_CLASS_P (op) || decl_address_invariant_p (op);
+
+ default:
+ break;
+ }
+
+ return false;
+}
+
+/* Return true if T is function-invariant. */
+
+static bool
+tree_invariant_p (tree t)
+{
+ tree inner = skip_simple_arithmetic (t);
+ return tree_invariant_p_1 (inner);
+}
+
/* Wrap a SAVE_EXPR around EXPR, if appropriate.
Do this to any expression which may be used in more than one place,
but must be evaluated only once.
Since it is no problem to reevaluate literals, we just return the
literal node. */
inner = skip_simple_arithmetic (t);
+ if (TREE_CODE (inner) == ERROR_MARK)
+ return inner;
- if (TREE_INVARIANT (inner)
- || (TREE_READONLY (inner) && ! TREE_SIDE_EFFECTS (inner))
- || TREE_CODE (inner) == SAVE_EXPR
- || TREE_CODE (inner) == ERROR_MARK)
+ if (tree_invariant_p_1 (inner))
return t;
/* If INNER contains a PLACEHOLDER_EXPR, we must evaluate it each time, since
value was computed on both sides of the jump. So make sure it isn't
eliminated as dead. */
TREE_SIDE_EFFECTS (t) = 1;
- TREE_INVARIANT (t) = 1;
return t;
}
inner = TREE_OPERAND (inner, 0);
else if (BINARY_CLASS_P (inner))
{
- if (TREE_INVARIANT (TREE_OPERAND (inner, 1)))
+ if (tree_invariant_p (TREE_OPERAND (inner, 1)))
inner = TREE_OPERAND (inner, 0);
- else if (TREE_INVARIANT (TREE_OPERAND (inner, 0)))
+ else if (tree_invariant_p (TREE_OPERAND (inner, 0)))
inner = TREE_OPERAND (inner, 1);
else
break;
ignore things that are actual constant or that already have been
handled by this function. */
- if (TREE_INVARIANT (e))
+ if (tree_invariant_p (e))
return e;
switch (TREE_CODE_CLASS (code))
TREE_READONLY (result) = TREE_READONLY (e);
TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (e);
TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (e);
- TREE_INVARIANT (result) = 1;
return result;
}
/* Low-level constructors for expressions. */
/* A helper function for build1 and constant folders. Set TREE_CONSTANT,
- TREE_INVARIANT, and TREE_SIDE_EFFECTS for an ADDR_EXPR. */
+ and TREE_SIDE_EFFECTS for an ADDR_EXPR. */
void
recompute_tree_invariant_for_addr_expr (tree t)
{
tree node;
- bool tc = true, ti = true, se = false;
+ bool tc = true, se = false;
/* We started out assuming this address is both invariant and constant, but
does not have side effects. Now go down any handled components and see if
??? Note that this code makes no attempt to deal with the case where
taking the address of something causes a copy due to misalignment. */
-#define UPDATE_TITCSE(NODE) \
+#define UPDATE_FLAGS(NODE) \
do { tree _node = (NODE); \
- if (_node && !TREE_INVARIANT (_node)) ti = false; \
if (_node && !TREE_CONSTANT (_node)) tc = false; \
if (_node && TREE_SIDE_EFFECTS (_node)) se = true; } while (0)
|| TREE_CODE (node) == ARRAY_RANGE_REF)
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (node, 0))) == ARRAY_TYPE)
{
- UPDATE_TITCSE (TREE_OPERAND (node, 1));
+ UPDATE_FLAGS (TREE_OPERAND (node, 1));
if (TREE_OPERAND (node, 2))
- UPDATE_TITCSE (TREE_OPERAND (node, 2));
+ UPDATE_FLAGS (TREE_OPERAND (node, 2));
if (TREE_OPERAND (node, 3))
- UPDATE_TITCSE (TREE_OPERAND (node, 3));
+ UPDATE_FLAGS (TREE_OPERAND (node, 3));
}
/* Likewise, just because this is a COMPONENT_REF doesn't mean we have a
FIELD_DECL, apparently. The G++ front end can put something else
&& TREE_CODE (TREE_OPERAND (node, 1)) == FIELD_DECL)
{
if (TREE_OPERAND (node, 2))
- UPDATE_TITCSE (TREE_OPERAND (node, 2));
+ UPDATE_FLAGS (TREE_OPERAND (node, 2));
}
else if (TREE_CODE (node) == BIT_FIELD_REF)
- UPDATE_TITCSE (TREE_OPERAND (node, 2));
+ UPDATE_FLAGS (TREE_OPERAND (node, 2));
}
- node = lang_hooks.expr_to_decl (node, &tc, &ti, &se);
+ node = lang_hooks.expr_to_decl (node, &tc, &se);
/* Now see what's inside. If it's an INDIRECT_REF, copy our properties from
- the address, since &(*a)->b is a form of addition. If it's a decl, it's
- invariant and constant if the decl is static. It's also invariant if it's
- a decl in the current function. Taking the address of a volatile variable
- is not volatile. If it's a constant, the address is both invariant and
- constant. Otherwise it's neither. */
+ the address, since &(*a)->b is a form of addition. If it's a constant, the
+ address is constant too. If it's a decl, its address is constant if the
+ decl is static. Everything else is not constant and, furthermore,
+ taking the address of a volatile variable is not volatile. */
if (TREE_CODE (node) == INDIRECT_REF)
- UPDATE_TITCSE (TREE_OPERAND (node, 0));
- else if (DECL_P (node))
- {
- if (staticp (node))
- ;
- else if (decl_function_context (node) == current_function_decl
- /* Addresses of thread-local variables are invariant. */
- || (TREE_CODE (node) == VAR_DECL
- && DECL_THREAD_LOCAL_P (node)))
- tc = false;
- else
- ti = tc = false;
- }
+ UPDATE_FLAGS (TREE_OPERAND (node, 0));
else if (CONSTANT_CLASS_P (node))
;
+ else if (DECL_P (node))
+ tc &= (staticp (node) != NULL_TREE);
else
{
- ti = tc = false;
+ tc = false;
se |= TREE_SIDE_EFFECTS (node);
}
+
TREE_CONSTANT (t) = tc;
- TREE_INVARIANT (t) = ti;
TREE_SIDE_EFFECTS (t) = se;
-#undef UPDATE_TITCSE
+#undef UPDATE_FLAGS
}
/* Build an expression of code CODE, data type TYPE, and operands as
&& node && !TYPE_P (node)
&& TREE_CONSTANT (node))
TREE_CONSTANT (t) = 1;
- if ((TREE_CODE_CLASS (code) == tcc_unary || code == VIEW_CONVERT_EXPR)
- && node && TREE_INVARIANT (node))
- TREE_INVARIANT (t) = 1;
if (TREE_CODE_CLASS (code) == tcc_reference
&& node && TREE_THIS_VOLATILE (node))
TREE_THIS_VOLATILE (t) = 1;
read_only = 0; \
if (!TREE_CONSTANT (arg##N)) \
constant = 0; \
- if (!TREE_INVARIANT (arg##N)) \
- invariant = 0; \
} \
} while (0)
tree
build2_stat (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL)
{
- bool constant, read_only, side_effects, invariant;
+ bool constant, read_only, side_effects;
tree t;
gcc_assert (TREE_CODE_LENGTH (code) == 2);
|| TREE_CODE_CLASS (code) == tcc_binary);
read_only = 1;
side_effects = TREE_SIDE_EFFECTS (t);
- invariant = constant;
PROCESS_ARG(0);
PROCESS_ARG(1);
TREE_READONLY (t) = read_only;
TREE_CONSTANT (t) = constant;
- TREE_INVARIANT (t) = invariant;
TREE_SIDE_EFFECTS (t) = side_effects;
TREE_THIS_VOLATILE (t)
= (TREE_CODE_CLASS (code) == tcc_reference
build3_stat (enum tree_code code, tree tt, tree arg0, tree arg1,
tree arg2 MEM_STAT_DECL)
{
- bool constant, read_only, side_effects, invariant;
+ bool constant, read_only, side_effects;
tree t;
gcc_assert (TREE_CODE_LENGTH (code) == 3);
build4_stat (enum tree_code code, tree tt, tree arg0, tree arg1,
tree arg2, tree arg3 MEM_STAT_DECL)
{
- bool constant, read_only, side_effects, invariant;
+ bool constant, read_only, side_effects;
tree t;
gcc_assert (TREE_CODE_LENGTH (code) == 4);
build5_stat (enum tree_code code, tree tt, tree arg0, tree arg1,
tree arg2, tree arg3, tree arg4 MEM_STAT_DECL)
{
- bool constant, read_only, side_effects, invariant;
+ bool constant, read_only, side_effects;
tree t;
gcc_assert (TREE_CODE_LENGTH (code) == 5);
tree arg2, tree arg3, tree arg4, tree arg5,
tree arg6 MEM_STAT_DECL)
{
- bool constant, read_only, side_effects, invariant;
+ bool constant, read_only, side_effects;
tree t;
gcc_assert (code == TARGET_MEM_REF);
"after being referenced with dll linkage", new);
/* If we have used a variable's address with dllimport linkage,
keep the old DECL_DLLIMPORT_P flag: the ADDR_EXPR using the
- decl may already have had TREE_INVARIANT and TREE_CONSTANT
- computed.
+ decl may already have had TREE_CONSTANT computed.
We still remove the attribute so that assembler code refers
to '&foo rather than '_imp__foo'. */
if (TREE_CODE (old) == VAR_DECL && TREE_ADDRESSABLE (old))
unsigned private_flag : 1;
unsigned protected_flag : 1;
unsigned deprecated_flag : 1;
- unsigned invariant_flag : 1;
unsigned saturating_flag : 1;
unsigned default_def_flag : 1;
unsigned lang_flag_6 : 1;
unsigned visited : 1;
- unsigned spare : 22;
+ unsigned spare : 23;
/* FIXME tuples: Eventually, we need to move this somewhere external to
the trees. */
Used in tree traversals to mark visited nodes.
- invariant_flag:
-
- TREE_INVARIANT in
- all expressions.
-
saturating_flag:
TYPE_SATURATING in
#define IDENTIFIER_TRANSPARENT_ALIAS(NODE) \
(IDENTIFIER_NODE_CHECK (NODE)->base.deprecated_flag)
-/* Value of expression is function invariant. A strict subset of
- TREE_CONSTANT, such an expression is constant over any one function
- invocation, though not across different invocations. May appear in
- any expression node. */
-#define TREE_INVARIANT(NODE) ((NODE)->base.invariant_flag)
-
/* In fixed-point types, means a saturating type. */
#define TYPE_SATURATING(NODE) ((NODE)->base.saturating_flag)
/* In tree.c */
extern int really_constant_p (const_tree);
+extern bool decl_address_invariant_p (const_tree);
extern int int_fits_type_p (const_tree, const_tree);
#ifndef GENERATOR_FILE
extern void get_type_static_bounds (const_tree, mpz_t, mpz_t);