alias.c (get_alias_set): Add support for TYPE_REF_CAN_ALIAS_ALL.

* alias.c (get_alias_set): Add support for TYPE_REF_CAN_ALIAS_ALL.
	* c-common.c (handle_mode_attribute): Add extra arg to
	build_pointer_type_for_mode and build_reference_type_for_mode.
	* c-typeck.c (build_c_cast): Only look at TREE_CONSTANT_OVERFLOW
	for INTEGER_CST.
	* tree.c (build_pointer_type_for_mode): Add arg CAN_ALIAS_ALL.
	Chain pointers via TYPE_NEXT_PTR_TO.
	(build_reference_type_for_mode): Similarly.
	(build_type_no_quals): Add extra arg to build_pointer_type_for_mode
	and build_reference_type_for_mode.
	(tree_check4_failed): New function.
	* tree.h (TREE_CHECK4, PTR_OR_REF_CHECK): New macros.
	(TYPE_REF_CAN_ALIAS_ALL, TYPE_NEXT_PTR_TO, TYPE_NEXT_REF_TO): Likewise.
	(TREE_NO_UNSUED_WARNING, TREE_VIA_VIRTUAL, TREE_CONSTANT_OVERFLOW):
	Add check.

	* cp/typeck.c (build_c_cast): Only look at TREE_CONSTANT_OVERFLOW
	for INTEGER_CST.

	* ada/decl.c (gnat_to_gnu_entity, case E_Access_Type): Pass value
	of No_Strict_Aliasing to build_pointer_type_for_mode.
	* ada/utils.c (update_pointer_to): Walk pointer and ref chains.

From-SVN: r79873
This commit is contained in:
Richard Kenner 2004-03-23 20:43:44 +00:00 committed by Richard Kenner
parent 95e59f1ada
commit 22421b79c8
11 changed files with 188 additions and 62 deletions

View File

@ -1,3 +1,21 @@
2004-03-23 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* alias.c (get_alias_set): Add support for TYPE_REF_CAN_ALIAS_ALL.
* c-common.c (handle_mode_attribute): Add extra arg to
build_pointer_type_for_mode and build_reference_type_for_mode.
* c-typeck.c (build_c_cast): Only look at TREE_CONSTANT_OVERFLOW
for INTEGER_CST.
* tree.c (build_pointer_type_for_mode): Add arg CAN_ALIAS_ALL.
Chain pointers via TYPE_NEXT_PTR_TO.
(build_reference_type_for_mode): Similarly.
(build_type_no_quals): Add extra arg to build_pointer_type_for_mode
and build_reference_type_for_mode.
(tree_check4_failed): New function.
* tree.h (TREE_CHECK4, PTR_OR_REF_CHECK): New macros.
(TYPE_REF_CAN_ALIAS_ALL, TYPE_NEXT_PTR_TO, TYPE_NEXT_REF_TO): Likewise.
(TREE_NO_UNSUED_WARNING, TREE_VIA_VIRTUAL, TREE_CONSTANT_OVERFLOW):
Add check.
2004-03-23 Roger Sayle <roger@eyesopen.com>
* fold-const.c (tree_expr_nonnegative_p): A&B is nonnegative when

View File

@ -1,3 +1,9 @@
2004-03-23 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* decl.c (gnat_to_gnu_entity, case E_Access_Type): Pass value
of No_Strict_Aliasing to build_pointer_type_for_mode.
* utils.c (update_pointer_to): Walk pointer and ref chains.
2004-03-22 Cyrille Comar <comar@act-europe.fr>
* ali.ads: Fix Comment about Dynamic_Elab.

View File

@ -2929,8 +2929,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
}
else if (gnat_desig_type == gnat_entity)
{
gnu_type = build_pointer_type_for_mode (make_node (VOID_TYPE),
p_mode);
gnu_type
= build_pointer_type_for_mode (make_node (VOID_TYPE),
p_mode,
No_Strict_Aliasing (gnat_entity));
TREE_TYPE (gnu_type) = TYPE_POINTER_TO (gnu_type) = gnu_type;
}
else
@ -2982,7 +2984,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
}
}
gnu_type = build_pointer_type_for_mode (gnu_desig_type, p_mode);
gnu_type
= build_pointer_type_for_mode (gnu_desig_type, p_mode,
No_Strict_Aliasing (gnat_entity));
}
/* If we are not defining this object and we made a dummy pointer,

View File

@ -2665,24 +2665,30 @@ update_pointer_to (tree old_type, tree new_type)
/* Otherwise, first handle the simple case. */
if (TREE_CODE (new_type) != UNCONSTRAINED_ARRAY_TYPE)
{
if (ptr != 0)
TREE_TYPE (ptr) = new_type;
TYPE_POINTER_TO (new_type) = ptr;
if (ref != 0)
TREE_TYPE (ref) = new_type;
TYPE_REFERENCE_TO (new_type) = ref;
if (ptr != 0 && TYPE_NAME (ptr) != 0
&& TREE_CODE (TYPE_NAME (ptr)) == TYPE_DECL
&& TREE_CODE (new_type) != ENUMERAL_TYPE)
rest_of_decl_compilation (TYPE_NAME (ptr), NULL,
global_bindings_p (), 0);
if (ref != 0 && TYPE_NAME (ref) != 0
&& TREE_CODE (TYPE_NAME (ref)) == TYPE_DECL
&& TREE_CODE (new_type) != ENUMERAL_TYPE)
rest_of_decl_compilation (TYPE_NAME (ref), NULL,
global_bindings_p (), 0);
for (; ptr; ptr = TYPE_NEXT_PTR_TO (ptr))
{
TREE_TYPE (ptr) = new_type;
if (TYPE_NAME (ptr) != 0
&& TREE_CODE (TYPE_NAME (ptr)) == TYPE_DECL
&& TREE_CODE (new_type) != ENUMERAL_TYPE)
rest_of_decl_compilation (TYPE_NAME (ptr), NULL,
global_bindings_p (), 0);
}
for (; ref; ref = TYPE_NEXT_PTR_TO (ref))
{
TREE_TYPE (ref) = new_type;
if (TYPE_NAME (ref) != 0
&& TREE_CODE (TYPE_NAME (ref)) == TYPE_DECL
&& TREE_CODE (new_type) != ENUMERAL_TYPE)
rest_of_decl_compilation (TYPE_NAME (ref), NULL,
global_bindings_p (), 0);
}
}
/* Now deal with the unconstrained array case. In this case the "pointer"

View File

@ -533,8 +533,11 @@ get_alias_set (tree t)
}
/* If we have an INDIRECT_REF via a void pointer, we don't
know anything about what that might alias. */
else if (TREE_CODE (TREE_TYPE (inner)) == VOID_TYPE)
know anything about what that might alias. Likewise if the
pointer is marked that way. */
else if (TREE_CODE (TREE_TYPE (inner)) == VOID_TYPE
|| (TYPE_REF_CAN_ALIAS_ALL
(TREE_TYPE (TREE_OPERAND (inner, 0)))))
return 0;
}

View File

@ -4629,13 +4629,13 @@ handle_mode_attribute (tree *node, tree name, tree args ATTRIBUTE_UNUSED,
if (TREE_CODE (type) == POINTER_TYPE)
{
ptr_type = build_pointer_type_for_mode (TREE_TYPE (type),
mode);
mode, false);
*node = ptr_type;
}
else if (TREE_CODE (type) == REFERENCE_TYPE)
{
ptr_type = build_reference_type_for_mode (TREE_TYPE (type),
mode);
mode, false);
*node = ptr_type;
}
else

View File

@ -3074,7 +3074,9 @@ build_c_cast (tree type, tree expr)
if (TREE_CODE (value) == INTEGER_CST)
{
TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
if (TREE_CODE_CLASS (TREE_CODE (ovalue)) == 'c')
TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
}
}

View File

@ -1,3 +1,8 @@
2004-03-23 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* typeck.c (build_c_cast): Only look at TREE_CONSTANT_OVERFLOW
for INTEGER_CST.
2004-03-22 Gabriel Dos Reis <gdr@integrable-solutions.net>
* cxx-pretty-print.c (pp_cxx_parameter_declaration_clause): Declare.

View File

@ -4919,7 +4919,9 @@ build_c_cast (tree type, tree expr)
if (TREE_CODE (value) == INTEGER_CST)
{
TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
if (TREE_CODE_CLASS (TREE_CODE (ovalue)) == 'c')
TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
}
}

View File

@ -3878,29 +3878,42 @@ iterative_hash_expr (tree t, hashval_t val)
(RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
constructed by language-dependent code, not here.) */
/* Construct, lay out and return the type of pointers to TO_TYPE
with mode MODE. If such a type has already been constructed,
reuse it. */
/* Construct, lay out and return the type of pointers to TO_TYPE with
mode MODE. If CAN_ALIAS_ALL is TRUE, indicate this type can
reference all of memory. If such a type has already been
constructed, reuse it. */
tree
build_pointer_type_for_mode (tree to_type, enum machine_mode mode)
build_pointer_type_for_mode (tree to_type, enum machine_mode mode,
bool can_alias_all)
{
tree t = TYPE_POINTER_TO (to_type);
tree t;
/* In some cases, languages will have things that aren't a POINTER_TYPE
(such as a RECORD_TYPE for fat pointers in Ada) as TYPE_POINTER_TO.
In that case, return that type without regard to the rest of our
operands.
??? This is a kludge, but consistent with the way this function has
always operated and there doesn't seem to be a good way to avoid this
at the moment. */
if (TYPE_POINTER_TO (to_type) != 0
&& TREE_CODE (TYPE_POINTER_TO (to_type)) != POINTER_TYPE)
return TYPE_POINTER_TO (to_type);
/* First, if we already have a type for pointers to TO_TYPE and it's
the proper mode, use it. */
if (t != 0 && mode == ptr_mode)
return t;
for (t = TYPE_POINTER_TO (to_type); t; t = TYPE_NEXT_PTR_TO (t))
if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
return t;
t = make_node (POINTER_TYPE);
TREE_TYPE (t) = to_type;
TYPE_MODE (t) = mode;
/* We can only record one type as "the" pointer to TO_TYPE. We choose to
record the pointer whose mode is ptr_mode. */
if (mode == ptr_mode)
TYPE_POINTER_TO (to_type) = t;
TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
TYPE_NEXT_PTR_TO (t) = TYPE_POINTER_TO (to_type);
TYPE_POINTER_TO (to_type) = t;
/* Lay out the type. This function has many callers that are concerned
with expression-construction, and this simplifies them all. */
@ -3914,29 +3927,41 @@ build_pointer_type_for_mode (tree to_type, enum machine_mode mode)
tree
build_pointer_type (tree to_type)
{
return build_pointer_type_for_mode (to_type, ptr_mode);
return build_pointer_type_for_mode (to_type, ptr_mode, false);
}
/* Construct, lay out and return the type of references to TO_TYPE
with mode MODE. If such a type has already been constructed,
reuse it. */
/* Same as build_pointer_type_for_mode, but for REFERENCE_TYPE. */
tree
build_reference_type_for_mode (tree to_type, enum machine_mode mode)
build_reference_type_for_mode (tree to_type, enum machine_mode mode,
bool can_alias_all)
{
tree t = TYPE_REFERENCE_TO (to_type);
tree t;
/* First, if we already have a type for pointers to TO_TYPE, use it. */
if (t != 0 && mode == ptr_mode)
return t;
/* In some cases, languages will have things that aren't a REFERENCE_TYPE
(such as a RECORD_TYPE for fat pointers in Ada) as TYPE_REFERENCE_TO.
In that case, return that type without regard to the rest of our
operands.
??? This is a kludge, but consistent with the way this function has
always operated and there doesn't seem to be a good way to avoid this
at the moment. */
if (TYPE_REFERENCE_TO (to_type) != 0
&& TREE_CODE (TYPE_REFERENCE_TO (to_type)) != REFERENCE_TYPE)
return TYPE_REFERENCE_TO (to_type);
/* First, if we already have a type for pointers to TO_TYPE and it's
the proper mode, use it. */
for (t = TYPE_REFERENCE_TO (to_type); t; t = TYPE_NEXT_REF_TO (t))
if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
return t;
t = make_node (REFERENCE_TYPE);
TREE_TYPE (t) = to_type;
TYPE_MODE (t) = mode;
/* Record this type as the pointer to TO_TYPE. */
if (mode == ptr_mode)
TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
TYPE_NEXT_REF_TO (t) = TYPE_REFERENCE_TO (to_type);
TYPE_REFERENCE_TO (to_type) = t;
layout_type (t);
@ -3951,7 +3976,7 @@ build_reference_type_for_mode (tree to_type, enum machine_mode mode)
tree
build_reference_type (tree to_type)
{
return build_reference_type_for_mode (to_type, ptr_mode);
return build_reference_type_for_mode (to_type, ptr_mode, false);
}
/* Build a type that is compatible with t but has no cv quals anywhere
@ -3966,11 +3991,13 @@ build_type_no_quals (tree t)
{
case POINTER_TYPE:
return build_pointer_type_for_mode (build_type_no_quals (TREE_TYPE (t)),
TYPE_MODE (t));
TYPE_MODE (t),
TYPE_REF_CAN_ALIAS_ALL (t));
case REFERENCE_TYPE:
return
build_reference_type_for_mode (build_type_no_quals (TREE_TYPE (t)),
TYPE_MODE (t));
TYPE_MODE (t),
TYPE_REF_CAN_ALIAS_ALL (t));
default:
return TYPE_MAIN_VARIANT (t);
}
@ -5022,6 +5049,21 @@ tree_check3_failed (const tree node, enum tree_code code1,
function, trim_filename (file), line);
}
/* ... and for four different codes. */
void
tree_check4_failed (const tree node, enum tree_code code1,
enum tree_code code2, enum tree_code code3,
enum tree_code code4, const char *file, int line,
const char *function)
{
internal_error
("tree check: expected %s, %s, %s or %s; have %s in %s, at %s:%d",
tree_code_name[code1], tree_code_name[code2], tree_code_name[code3],
tree_code_name[code4], tree_code_name[TREE_CODE (node)], function,
trim_filename (file), line);
}
/* ... and for five different codes. */
void

View File

@ -197,7 +197,8 @@ struct tree_common GTY(())
TREE_STATIC in
VAR_DECL, FUNCTION_DECL, CONSTRUCTOR, ADDR_EXPR
TREE_NO_UNUSED_WARNING in
CONVERT_EXPR, NOP_EXPR, COMPOUND_EXPR
CONVERT_EXPR, NOP_EXPR, COMPOUND_EXPR, NON_LVALUE_EXPR
??? plus other expressions, apparently (e.g. MODIFY_EXPR).
TREE_VIA_VIRTUAL in
TREE_LIST or TREE_VEC
TREE_CONSTANT_OVERFLOW in
@ -207,11 +208,14 @@ struct tree_common GTY(())
CLEANUP_EH_ONLY in
TARGET_EXPR, WITH_CLEANUP_EXPR, CLEANUP_STMT,
TREE_LIST elements of a block's cleanup list.
TYPE_REF_CAN_ALIAS_ALL in
POINTER_TYPE, REFERENCE_TYPE
public_flag:
TREE_OVERFLOW in
INTEGER_CST, REAL_CST, COMPLEX_CST, VECTOR_CST
??? and other expressions?
TREE_PUBLIC in
VAR_DECL or FUNCTION_DECL or IDENTIFIER_NODE
EXPR_WFL_EMIT_LINE_NOTE in
@ -324,6 +328,16 @@ struct tree_common GTY(())
__LINE__, __FUNCTION__); \
__t; })
#define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) __extension__ \
({ const tree __t = (T); \
if (TREE_CODE (__t) != (CODE1) \
&& TREE_CODE (__t) != (CODE2) \
&& TREE_CODE (__t) != (CODE3) \
&& TREE_CODE (__t) != (CODE4)) \
tree_check4_failed (__t, (CODE1), (CODE2), (CODE3), (CODE4), \
__FILE__, __LINE__, __FUNCTION__); \
__t; })
#define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) __extension__ \
({ const tree __t = (T); \
if (TREE_CODE (__t) != (CODE1) \
@ -402,6 +416,10 @@ extern void tree_check3_failed (const tree, enum tree_code, enum tree_code,
enum tree_code, const char *, int,
const char *)
ATTRIBUTE_NORETURN;
extern void tree_check4_failed (const tree, enum tree_code, enum tree_code,
enum tree_code, enum tree_code,
const char *, int, const char *)
ATTRIBUTE_NORETURN;
extern void tree_check5_failed (const tree, enum tree_code, enum tree_code,
enum tree_code, enum tree_code, enum tree_code,
const char *, int, const char *)
@ -422,6 +440,7 @@ extern void tree_operand_check_failed (int, enum tree_code,
#define TREE_CHECK(T, CODE) (T)
#define TREE_CHECK2(T, CODE1, CODE2) (T)
#define TREE_CHECK3(T, CODE1, CODE2, CODE3) (T)
#define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) (T)
#define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) (T)
#define TREE_CLASS_CHECK(T, CODE) (T)
#define EXPR_CHECK(T) (T)
@ -439,6 +458,7 @@ extern void tree_operand_check_failed (int, enum tree_code,
#define CST_CHECK(T) TREE_CLASS_CHECK (T, 'c')
#define STMT_CHECK(T) TREE_CLASS_CHECK (T, 's')
#define FUNC_OR_METHOD_CHECK(T) TREE_CHECK2 (T, FUNCTION_TYPE, METHOD_TYPE)
#define PTR_OR_REF_CHECK(T) TREE_CHECK2 (T, POINTER_TYPE, REFERENCE_TYPE)
#define SET_ARRAY_OR_VECTOR_CHECK(T) \
TREE_CHECK3 (T, ARRAY_TYPE, SET_TYPE, VECTOR_TYPE)
@ -597,7 +617,10 @@ extern void tree_operand_check_failed (int, enum tree_code,
/* In a VAR_DECL, nonzero means allocate static storage.
In a FUNCTION_DECL, nonzero if function has been defined.
In a CONSTRUCTOR, nonzero means allocate static storage. */
In a CONSTRUCTOR, nonzero means allocate static storage.
??? This is also used in lots of other nodes in unclear ways which
should be cleaned up some day. */
#define TREE_STATIC(NODE) ((NODE)->common.static_flag)
/* In a TARGET_EXPR, WITH_CLEANUP_EXPR, CLEANUP_STMT, or element of a
@ -605,29 +628,42 @@ extern void tree_operand_check_failed (int, enum tree_code,
executed if an exception is thrown, not on normal exit of its scope. */
#define CLEANUP_EH_ONLY(NODE) ((NODE)->common.static_flag)
/* In a CONVERT_EXPR, NOP_EXPR or COMPOUND_EXPR, this means the node was
made implicitly and should not lead to an "unused value" warning. */
#define TREE_NO_UNUSED_WARNING(NODE) ((NODE)->common.static_flag)
/* In a CONVERT_EXPR, NOP_EXPR, NON_LVALUE_EXPR or COMPOUND_EXPR, this means
the node was made implicitly and should not lead to an "unused value"
warning.
??? Apparently this is also used on other expression types (such as
MODIFY_EXPR. This needs to be cleaned up sometime. */
#define TREE_NO_UNUSED_WARNING(NODE) (EXPR_CHECK (NODE)->common.static_flag)
/* Nonzero for a TREE_LIST or TREE_VEC node means that the derivation
chain is via a `virtual' declaration. */
#define TREE_VIA_VIRTUAL(NODE) ((NODE)->common.static_flag)
#define TREE_VIA_VIRTUAL(NODE) \
(TREE_CHECK2 (NODE, TREE_LIST, TREE_VEC)->common.static_flag)
/* In an INTEGER_CST, REAL_CST, COMPLEX_CST, or VECTOR_CST this means
there was an overflow in folding. This is distinct from
TREE_OVERFLOW because ANSI C requires a diagnostic when overflows
occur in constant expressions. */
#define TREE_CONSTANT_OVERFLOW(NODE) ((NODE)->common.static_flag)
#define TREE_CONSTANT_OVERFLOW(NODE) (CST_CHECK (NODE)->common.static_flag)
/* In an IDENTIFIER_NODE, this means that assemble_name was called with
this string as an argument. */
#define TREE_SYMBOL_REFERENCED(NODE) \
(IDENTIFIER_NODE_CHECK (NODE)->common.static_flag)
/* Nonzero in a pointer or reference type means the data pointed to
by this type can alias anything. */
#define TYPE_REF_CAN_ALIAS_ALL(NODE) \
(PTR_OR_REF_CHECK (NODE)->common.static_flag)
/* In an INTEGER_CST, REAL_CST, COMPLEX_CST, or VECTOR_CST, this means
there was an overflow in folding, and no warning has been issued
for this subexpression. TREE_OVERFLOW implies
TREE_CONSTANT_OVERFLOW, but not vice versa. */
for this subexpression. TREE_OVERFLOW implies TREE_CONSTANT_OVERFLOW,
but not vice versa.
??? Apparently, lots of code assumes this is defined in all
expressions. */
#define TREE_OVERFLOW(NODE) ((NODE)->common.public_flag)
/* In a VAR_DECL or FUNCTION_DECL,
@ -1021,6 +1057,8 @@ struct tree_block GTY(())
#define TYPE_OFFSET_BASETYPE(NODE) (OFFSET_TYPE_CHECK (NODE)->type.maxval)
#define TYPE_POINTER_TO(NODE) (TYPE_CHECK (NODE)->type.pointer_to)
#define TYPE_REFERENCE_TO(NODE) (TYPE_CHECK (NODE)->type.reference_to)
#define TYPE_NEXT_PTR_TO(NODE) (POINTER_TYPE_CHECK (NODE)->type.minval)
#define TYPE_NEXT_REF_TO(NODE) (REFERENCE_TYPE_CHECK (NODE)->type.minval)
#define TYPE_MIN_VALUE(NODE) (NUMERICAL_TYPE_CHECK (NODE)->type.minval)
#define TYPE_MAX_VALUE(NODE) (NUMERICAL_TYPE_CHECK (NODE)->type.maxval)
#define TYPE_PRECISION(NODE) (TYPE_CHECK (NODE)->type.precision)
@ -2190,9 +2228,9 @@ extern tree make_unsigned_type (int);
extern void initialize_sizetypes (void);
extern void set_sizetype (tree);
extern void fixup_unsigned_type (tree);
extern tree build_pointer_type_for_mode (tree, enum machine_mode);
extern tree build_pointer_type_for_mode (tree, enum machine_mode, bool);
extern tree build_pointer_type (tree);
extern tree build_reference_type_for_mode (tree, enum machine_mode);
extern tree build_reference_type_for_mode (tree, enum machine_mode, bool);
extern tree build_reference_type (tree);
extern tree build_vector_type_for_mode (tree, enum machine_mode);
extern tree build_vector_type (tree innertype, int nunits);