This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [lto] Fix 34 testsuite failures


On Wed, May 13, 2009 at 10:10 PM, Diego Novillo <dnovillo@google.com> wrote:
> This patch fixes 33 failures in check-gcc and 1 failure in
> libstdc++. ?This adds another piece to the gimple type system by
> providing an implementation for get_alias_set().
>
> The basic problem was that for unions, we were considering all
> fields in the union to have different alias sets. ?This initial
> implementation is mostly a verbatim copy of the C/C++ notions of
> alias sets. ?This will evolve, of course, but this should be a
> good start.

Didn't I fix the union access case within the oracle? ... or do you hit the
same problem on the RTL level (I didn't check there)?

Thanks,
Richard.

> Tested on x86_64.
>
>
> Diego.
>
>
>
> ? ? ? ?* gimple.c: Include alias.h.
> ? ? ? ?(gimple_signed_or_unsigned_type): New.
> ? ? ? ?(gimple_unsigned_type): New.
> ? ? ? ?(gimple_signed_type): New.
> ? ? ? ?(gimple_get_alias_set): New.
> ? ? ? ?* gimple.h (gimple_unsigned_type): Declare.
> ? ? ? ?(gimple_signed_type): Declare.
> ? ? ? ?(gimple_get_alias_set): Declare.
> ? ? ? ?* Makefile.in (gimple.o): Add dependency on ALIAS_H.
>
> lto/ChangeLog
>
> ? ? ? ?* lto-lang.c (LANG_HOOKS_GET_ALIAS_SET): Define.
>
> Index: lto/lto-lang.c
> ===================================================================
> --- lto/lto-lang.c ? ? ?(revision 147489)
> +++ lto/lto-lang.c ? ? ?(working copy)
> @@ -1035,6 +1035,8 @@ static void lto_init_ts (void)
> ?#define LANG_HOOKS_HANDLE_OPTION lto_handle_option
> ?#undef LANG_HOOKS_POST_OPTIONS
> ?#define LANG_HOOKS_POST_OPTIONS lto_post_options
> +#undef LANG_HOOKS_GET_ALIAS_SET
> +#define LANG_HOOKS_GET_ALIAS_SET gimple_get_alias_set
> ?#undef LANG_HOOKS_MARK_ADDRESSABLE
> ?#define LANG_HOOKS_MARK_ADDRESSABLE lto_mark_addressable
> ?#undef LANG_HOOKS_TYPE_FOR_MODE
> Index: Makefile.in
> ===================================================================
> --- Makefile.in (revision 147489)
> +++ Makefile.in (working copy)
> @@ -2490,7 +2490,7 @@ tree-object-size.o: tree-object-size.c $
> ? ?$(TREE_PASS_H) tree-ssa-propagate.h
> ?gimple.o : gimple.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TREE_H) \
> ? ?$(GGC_H) $(GIMPLE_H) $(TOPLEV_H) $(DIAGNOSTIC_H) gt-gimple.h \
> - ? $(TREE_FLOW_H) value-prof.h $(FLAGS_H) $(TARGET_H)
> + ? $(TREE_FLOW_H) value-prof.h $(FLAGS_H) $(TARGET_H) $(ALIAS_H)
> ?gimple-pretty-print.o : gimple-pretty-print.c $(CONFIG_H) $(SYSTEM_H) \
> ? ?$(TREE_H) $(DIAGNOSTIC_H) $(REAL_H) $(HASHTAB_H) $(TREE_FLOW_H) \
> ? ?$(TM_H) coretypes.h $(TREE_PASS_H) $(GIMPLE_H) value-prof.h
> Index: gimple.c
> ===================================================================
> --- gimple.c ? ?(revision 147489)
> +++ gimple.c ? ?(working copy)
> @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3.
> ?#include "tree-flow.h"
> ?#include "value-prof.h"
> ?#include "flags.h"
> +#include "alias.h"
>
> ?/* Global type table. ?FIXME lto, it should be possible to re-use some
> ? ?of the type hashing routines in tree.c (type_hash_canon, type_hash_lookup,
> @@ -3753,6 +3754,243 @@ print_gimple_types_stats (void)
> ?}
>
>
> +/* Return a type the same as TYPE except unsigned or
> + ? signed according to UNSIGNEDP. ?*/
> +
> +static tree
> +gimple_signed_or_unsigned_type (bool unsignedp, tree type)
> +{
> + ?tree type1;
> +
> + ?type1 = TYPE_MAIN_VARIANT (type);
> + ?if (type1 == signed_char_type_node
> + ? ? ?|| type1 == char_type_node
> + ? ? ?|| type1 == unsigned_char_type_node)
> + ? ?return unsignedp ? unsigned_char_type_node : signed_char_type_node;
> + ?if (type1 == integer_type_node || type1 == unsigned_type_node)
> + ? ?return unsignedp ? unsigned_type_node : integer_type_node;
> + ?if (type1 == short_integer_type_node || type1 == short_unsigned_type_node)
> + ? ?return unsignedp ? short_unsigned_type_node : short_integer_type_node;
> + ?if (type1 == long_integer_type_node || type1 == long_unsigned_type_node)
> + ? ?return unsignedp ? long_unsigned_type_node : long_integer_type_node;
> + ?if (type1 == long_long_integer_type_node
> + ? ? ?|| type1 == long_long_unsigned_type_node)
> + ? ?return unsignedp
> + ? ? ? ? ? ? long_long_unsigned_type_node
> + ? ? ? ? ?: long_long_integer_type_node;
> +#if HOST_BITS_PER_WIDE_INT >= 64
> + ?if (type1 == intTI_type_node || type1 == unsigned_intTI_type_node)
> + ? ?return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
> +#endif
> + ?if (type1 == intDI_type_node || type1 == unsigned_intDI_type_node)
> + ? ?return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
> + ?if (type1 == intSI_type_node || type1 == unsigned_intSI_type_node)
> + ? ?return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
> + ?if (type1 == intHI_type_node || type1 == unsigned_intHI_type_node)
> + ? ?return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
> + ?if (type1 == intQI_type_node || type1 == unsigned_intQI_type_node)
> + ? ?return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
> +
> +#define GIMPLE_FIXED_TYPES(NAME) ? ? ? ? ? \
> + ?if (type1 == short_ ## NAME ## _type_node \
> + ? ? ?|| type1 == unsigned_short_ ## NAME ## _type_node) \
> + ? ?return unsignedp ? unsigned_short_ ## NAME ## _type_node \
> + ? ? ? ? ? ? ? ? ? ?: short_ ## NAME ## _type_node; \
> + ?if (type1 == NAME ## _type_node \
> + ? ? ?|| type1 == unsigned_ ## NAME ## _type_node) \
> + ? ?return unsignedp ? unsigned_ ## NAME ## _type_node \
> + ? ? ? ? ? ? ? ? ? ?: NAME ## _type_node; \
> + ?if (type1 == long_ ## NAME ## _type_node \
> + ? ? ?|| type1 == unsigned_long_ ## NAME ## _type_node) \
> + ? ?return unsignedp ? unsigned_long_ ## NAME ## _type_node \
> + ? ? ? ? ? ? ? ? ? ?: long_ ## NAME ## _type_node; \
> + ?if (type1 == long_long_ ## NAME ## _type_node \
> + ? ? ?|| type1 == unsigned_long_long_ ## NAME ## _type_node) \
> + ? ?return unsignedp ? unsigned_long_long_ ## NAME ## _type_node \
> + ? ? ? ? ? ? ? ? ? ?: long_long_ ## NAME ## _type_node;
> +
> +#define GIMPLE_FIXED_MODE_TYPES(NAME) \
> + ?if (type1 == NAME ## _type_node \
> + ? ? ?|| type1 == u ## NAME ## _type_node) \
> + ? ?return unsignedp ? u ## NAME ## _type_node \
> + ? ? ? ? ? ? ? ? ? ?: NAME ## _type_node;
> +
> +#define GIMPLE_FIXED_TYPES_SAT(NAME) \
> + ?if (type1 == sat_ ## short_ ## NAME ## _type_node \
> + ? ? ?|| type1 == sat_ ## unsigned_short_ ## NAME ## _type_node) \
> + ? ?return unsignedp ? sat_ ## unsigned_short_ ## NAME ## _type_node \
> + ? ? ? ? ? ? ? ? ? ?: sat_ ## short_ ## NAME ## _type_node; \
> + ?if (type1 == sat_ ## NAME ## _type_node \
> + ? ? ?|| type1 == sat_ ## unsigned_ ## NAME ## _type_node) \
> + ? ?return unsignedp ? sat_ ## unsigned_ ## NAME ## _type_node \
> + ? ? ? ? ? ? ? ? ? ?: sat_ ## NAME ## _type_node; \
> + ?if (type1 == sat_ ## long_ ## NAME ## _type_node \
> + ? ? ?|| type1 == sat_ ## unsigned_long_ ## NAME ## _type_node) \
> + ? ?return unsignedp ? sat_ ## unsigned_long_ ## NAME ## _type_node \
> + ? ? ? ? ? ? ? ? ? ?: sat_ ## long_ ## NAME ## _type_node; \
> + ?if (type1 == sat_ ## long_long_ ## NAME ## _type_node \
> + ? ? ?|| type1 == sat_ ## unsigned_long_long_ ## NAME ## _type_node) \
> + ? ?return unsignedp ? sat_ ## unsigned_long_long_ ## NAME ## _type_node \
> + ? ? ? ? ? ? ? ? ? ?: sat_ ## long_long_ ## NAME ## _type_node;
> +
> +#define GIMPLE_FIXED_MODE_TYPES_SAT(NAME) ? ? ?\
> + ?if (type1 == sat_ ## NAME ## _type_node \
> + ? ? ?|| type1 == sat_ ## u ## NAME ## _type_node) \
> + ? ?return unsignedp ? sat_ ## u ## NAME ## _type_node \
> + ? ? ? ? ? ? ? ? ? ?: sat_ ## NAME ## _type_node;
> +
> + ?GIMPLE_FIXED_TYPES (fract);
> + ?GIMPLE_FIXED_TYPES_SAT (fract);
> + ?GIMPLE_FIXED_TYPES (accum);
> + ?GIMPLE_FIXED_TYPES_SAT (accum);
> +
> + ?GIMPLE_FIXED_MODE_TYPES (qq);
> + ?GIMPLE_FIXED_MODE_TYPES (hq);
> + ?GIMPLE_FIXED_MODE_TYPES (sq);
> + ?GIMPLE_FIXED_MODE_TYPES (dq);
> + ?GIMPLE_FIXED_MODE_TYPES (tq);
> + ?GIMPLE_FIXED_MODE_TYPES_SAT (qq);
> + ?GIMPLE_FIXED_MODE_TYPES_SAT (hq);
> + ?GIMPLE_FIXED_MODE_TYPES_SAT (sq);
> + ?GIMPLE_FIXED_MODE_TYPES_SAT (dq);
> + ?GIMPLE_FIXED_MODE_TYPES_SAT (tq);
> + ?GIMPLE_FIXED_MODE_TYPES (ha);
> + ?GIMPLE_FIXED_MODE_TYPES (sa);
> + ?GIMPLE_FIXED_MODE_TYPES (da);
> + ?GIMPLE_FIXED_MODE_TYPES (ta);
> + ?GIMPLE_FIXED_MODE_TYPES_SAT (ha);
> + ?GIMPLE_FIXED_MODE_TYPES_SAT (sa);
> + ?GIMPLE_FIXED_MODE_TYPES_SAT (da);
> + ?GIMPLE_FIXED_MODE_TYPES_SAT (ta);
> +
> + ?/* For ENUMERAL_TYPEs in C++, must check the mode of the types, not
> + ? ? the precision; they have precision set to match their range, but
> + ? ? may use a wider mode to match an ABI. ?If we change modes, we may
> + ? ? wind up with bad conversions. ?For INTEGER_TYPEs in C, must check
> + ? ? the precision as well, so as to yield correct results for
> + ? ? bit-field types. ?C++ does not have these separate bit-field
> + ? ? types, and producing a signed or unsigned variant of an
> + ? ? ENUMERAL_TYPE may cause other problems as well. ?*/
> + ?if (!INTEGRAL_TYPE_P (type)
> + ? ? ?|| TYPE_UNSIGNED (type) == unsignedp)
> + ? ?return type;
> +
> +#define TYPE_OK(node) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> + ?(TYPE_MODE (type) == TYPE_MODE (node) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> + ? && TYPE_PRECISION (type) == TYPE_PRECISION (node))
> + ?if (TYPE_OK (signed_char_type_node))
> + ? ?return unsignedp ? unsigned_char_type_node : signed_char_type_node;
> + ?if (TYPE_OK (integer_type_node))
> + ? ?return unsignedp ? unsigned_type_node : integer_type_node;
> + ?if (TYPE_OK (short_integer_type_node))
> + ? ?return unsignedp ? short_unsigned_type_node : short_integer_type_node;
> + ?if (TYPE_OK (long_integer_type_node))
> + ? ?return unsignedp ? long_unsigned_type_node : long_integer_type_node;
> + ?if (TYPE_OK (long_long_integer_type_node))
> + ? ?return (unsignedp
> + ? ? ? ? ? ? long_long_unsigned_type_node
> + ? ? ? ? ? : long_long_integer_type_node);
> +
> +#if HOST_BITS_PER_WIDE_INT >= 64
> + ?if (TYPE_OK (intTI_type_node))
> + ? ?return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
> +#endif
> + ?if (TYPE_OK (intDI_type_node))
> + ? ?return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
> + ?if (TYPE_OK (intSI_type_node))
> + ? ?return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
> + ?if (TYPE_OK (intHI_type_node))
> + ? ?return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
> + ?if (TYPE_OK (intQI_type_node))
> + ? ?return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
> +
> +#undef GIMPLE_FIXED_TYPES
> +#undef GIMPLE_FIXED_MODE_TYPES
> +#undef GIMPLE_FIXED_TYPES_SAT
> +#undef GIMPLE_FIXED_MODE_TYPES_SAT
> +#undef TYPE_OK
> +
> + ?return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp);
> +}
> +
> +
> +/* Return an unsigned type the same as TYPE in other respects. ?*/
> +
> +tree
> +gimple_unsigned_type (tree type)
> +{
> + ?return gimple_signed_or_unsigned_type (true, type);
> +}
> +
> +
> +/* Return a signed type the same as TYPE in other respects. ?*/
> +
> +tree
> +gimple_signed_type (tree type)
> +{
> + ?return gimple_signed_or_unsigned_type (false, type);
> +}
> +
> +
> +/* Return the typed-based alias set for T, which may be an expression
> + ? or a type. ?Return -1 if we don't do anything special. ?*/
> +
> +alias_set_type
> +gimple_get_alias_set (tree t)
> +{
> + ?tree u;
> +
> + ?/* Permit type-punning when accessing a union, provided the access
> + ? ? is directly through the union. ?For example, this code does not
> + ? ? permit taking the address of a union member and then storing
> + ? ? through it. ?Even the type-punning allowed here is a GCC
> + ? ? extension, albeit a common and useful one; the C standard says
> + ? ? that such accesses have implementation-defined behavior. ?*/
> + ?for (u = t;
> + ? ? ? TREE_CODE (u) == COMPONENT_REF || TREE_CODE (u) == ARRAY_REF;
> + ? ? ? u = TREE_OPERAND (u, 0))
> + ? ?if (TREE_CODE (u) == COMPONENT_REF
> + ? ? ? && TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE)
> + ? ? ?return 0;
> +
> + ?/* That's all the expressions we handle specially. ?*/
> + ?if (!TYPE_P (t))
> + ? ?return -1;
> +
> + ?/* For convenience, follow the C standard when dealing with
> + ? ? character types. ?Any object may be accessed via an lvalue that
> + ? ? has character type. ?*/
> + ?if (t == char_type_node
> + ? ? ?|| t == signed_char_type_node
> + ? ? ?|| t == unsigned_char_type_node)
> + ? ?return 0;
> +
> + ?/* Allow aliasing between signed and unsigned variants of the same
> + ? ? type. ?We treat the signed variant as canonical. ?*/
> + ?if (TREE_CODE (t) == INTEGER_TYPE && TYPE_UNSIGNED (t))
> + ? ?{
> + ? ? ?tree t1 = gimple_signed_type (t);
> +
> + ? ? ?/* t1 == t can happen for boolean nodes which are always unsigned. ?*/
> + ? ? ?if (t1 != t)
> + ? ? ? return get_alias_set (t1);
> + ? ?}
> + ?else if (POINTER_TYPE_P (t))
> + ? ?{
> + ? ? ?/* For pointer types, disregard qualifiers and assume that
> + ? ? ? ?pointers to the same type but different cv-qualifiers may
> + ? ? ? ?alias each other. ?This is similar to what the C/C++ FEs do. ?*/
> + ? ? ?tree t1;
> +
> + ? ? ?t1 = build_type_no_quals (t);
> + ? ? ?if (t1 != t)
> + ? ? ? return get_alias_set (t1);
> + ? ?}
> +
> + ?return -1;
> +}
> +
> +
> ?/* Data structure used to count the number of dereferences to PTR
> ? ?inside an expression. ?*/
> ?struct count_ptr_d
> Index: gimple.h
> ===================================================================
> --- gimple.h ? ?(revision 147489)
> +++ gimple.h ? ?(working copy)
> @@ -886,6 +886,9 @@ extern void recalculate_side_effects (tr
> ?extern int gimple_types_compatible_p (tree, tree);
> ?extern tree gimple_register_type (tree);
> ?extern void print_gimple_types_stats (void);
> +extern tree gimple_unsigned_type (tree);
> +extern tree gimple_signed_type (tree);
> +extern alias_set_type gimple_get_alias_set (tree);
> ?extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned *);
> ?extern bool walk_stmt_load_store_addr_ops (gimple, void *,
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]