Index: Makefile.in =================================================================== RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v retrieving revision 1.903.2.192 diff -u -d -b -w -c -3 -p -r1.903.2.192 Makefile.in cvs server: conflicting specifications of output style *** Makefile.in 10 Mar 2004 18:04:23 -0000 1.903.2.192 --- Makefile.in 11 Mar 2004 23:43:38 -0000 *************** tree-ssa-forwprop.o : tree-ssa-forwprop. *** 1566,1583 **** $(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) tree-ssa-phiopt.o : tree-ssa-phiopt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) errors.h $(GGC_H) $(TREE_H) $(RTL_H) $(TM_P_H) $(BASIC_BLOCK_H) \ ! $(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) tree-nrv.o : tree-nrv.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) $(TREE_H) $(RTL_H) function.h $(BASIC_BLOCK_H) $(EXPR_H) \ ! diagnostic.h $(TREE_FLOW_H) $(TIMEVAR_H) $(TREE_DUMP_H) tree-pass.h tree-ssa-copy.o : tree-ssa-copy.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \ errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \ ! $(BASIC_BLOCK_H) tree-pass.h tree-ssa-dom.o : tree-ssa-dom.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \ errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \ ! $(BASIC_BLOCK_H) domwalk.h real.h tree-pass.h flags.h tree-ssanames.o : tree-ssanames.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) $(TREE_H) varray.h $(GGC_H) gt-tree-ssanames.h tree-phinodes.o : tree-phinodes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ --- 1566,1583 ---- $(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) tree-ssa-phiopt.o : tree-ssa-phiopt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) errors.h $(GGC_H) $(TREE_H) $(RTL_H) $(TM_P_H) $(BASIC_BLOCK_H) \ ! $(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) langhooks.h tree-nrv.o : tree-nrv.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) $(TREE_H) $(RTL_H) function.h $(BASIC_BLOCK_H) $(EXPR_H) \ ! diagnostic.h $(TREE_FLOW_H) $(TIMEVAR_H) $(TREE_DUMP_H) tree-pass.h langhooks.h tree-ssa-copy.o : tree-ssa-copy.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \ errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \ ! $(BASIC_BLOCK_H) tree-pass.h langhooks.h tree-ssa-dom.o : tree-ssa-dom.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \ errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \ ! $(BASIC_BLOCK_H) domwalk.h real.h tree-pass.h flags.h langhooks.h tree-ssanames.o : tree-ssanames.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) $(TREE_H) varray.h $(GGC_H) gt-tree-ssanames.h tree-phinodes.o : tree-phinodes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ *************** tree-ssa-dce.o : tree-ssa-dce.c $(CONFIG *** 1837,1843 **** tree-ssa-ccp.o : tree-ssa-ccp.c $(CONFIG_H) system.h errors.h $(TREE_H) \ $(RTL_H) $(TM_P_H) $(TREE_FLOW_H) diagnostic.h tree-inline.h \ $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_SIMPLE_H) \ ! $(EXPR_H) tree-pass.h flags.h tree-sra.o : tree-sra.c $(CONFIG_H) system.h errors.h $(TREE_H) $(RTL_H) \ $(TM_P_H) $(TREE_FLOW_H) diagnostic.h tree-inline.h \ $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_SIMPLE_H) \ --- 1837,1843 ---- tree-ssa-ccp.o : tree-ssa-ccp.c $(CONFIG_H) system.h errors.h $(TREE_H) \ $(RTL_H) $(TM_P_H) $(TREE_FLOW_H) diagnostic.h tree-inline.h \ $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_SIMPLE_H) \ ! $(EXPR_H) tree-pass.h flags.h langhooks.h tree-sra.o : tree-sra.c $(CONFIG_H) system.h errors.h $(TREE_H) $(RTL_H) \ $(TM_P_H) $(TREE_FLOW_H) diagnostic.h tree-inline.h \ $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_SIMPLE_H) \ Index: c-common.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-common.c,v retrieving revision 1.344.2.63 diff -u -d -b -w -c -3 -p -r1.344.2.63 c-common.c cvs server: conflicting specifications of output style *** c-common.c 2 Mar 2004 18:41:21 -0000 1.344.2.63 --- c-common.c 11 Mar 2004 23:43:38 -0000 *************** Software Foundation, 59 Temple Place - S *** 43,48 **** --- 43,49 ---- #include "c-tree.h" #include "toplev.h" #include "tree-iterator.h" + #include "hashtab.h" cpp_reader *parse_in; /* Declared in c-pragma.h. */ *************** c_apply_type_quals_to_decl (int type_qua *** 2816,2821 **** --- 2817,2865 ---- } } + /* Hash function for the problem of multiple type definitions in + different files. This must hash all types that will compare + equal via comptypes to the same value. In practice it hashes + on some of the simple stuff and leaves the details to comptypes. */ + + static hashval_t + c_type_hash (const void *p) + { + int i = 0; + int shift, size; + tree t = (tree)p; + tree t2; + switch (TREE_CODE (t)) + { + /* For pointers, hash on pointee type plus some swizzling. */ + case POINTER_TYPE: + return c_type_hash (TREE_TYPE (t)) ^ 0x3003003; + /* Hash on number of elements and total size. */ + case ENUMERAL_TYPE: + shift = 3; + t2 = TYPE_VALUES (t); + break; + case RECORD_TYPE: + shift = 0; + t2 = TYPE_FIELDS (t); + break; + case QUAL_UNION_TYPE: + shift = 1; + t2 = TYPE_FIELDS (t); + break; + case UNION_TYPE: + shift = 2; + t2 = TYPE_FIELDS (t); + break; + default: + abort (); + } + for (; t2; t2 = TREE_CHAIN (t2)) + i++; + size = TREE_INT_CST_LOW (TYPE_SIZE (t)); + return ((size << 24) | (i << shift)); + } + /* 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. */ *************** HOST_WIDE_INT *** 2823,2828 **** --- 2867,2874 ---- c_common_get_alias_set (tree t) { tree u; + PTR *slot; + static htab_t type_hash_table; /* Permit type-punning when accessing a union, provided the access is directly through the union. For example, this code does not *************** c_common_get_alias_set (tree t) *** 2894,2899 **** --- 2940,3001 ---- if (t1 != t) return get_alias_set (t1); } + + /* Handle the case of multiple type nodes referring to "the same" type, + which occurs with IMA. These share an alias set. FIXME: Currently only + C90 is handled. (In C99 type compatibility is not transitive, which + complicates things mightily. The alias set splay trees can theoretically + represent this, but insertion is tricky when you consider all the + different orders things might arrive in.) */ + + if (c_language != clk_c || flag_isoc99) + return -1; + + /* Save time if there's only one input file. */ + if (!current_file_decl || TREE_CHAIN (current_file_decl) == NULL_TREE) + return -1; + + /* Pointers need special handling if they point to any type that + needs special handling (below). */ + if (TREE_CODE (t) == POINTER_TYPE) + { + tree t2; + /* Find bottom type under any nested POINTERs. */ + for (t2 = TREE_TYPE (t); + TREE_CODE (t2) == POINTER_TYPE; + t2 = TREE_TYPE (t2)) + ; + if (TREE_CODE (t2) != RECORD_TYPE + && TREE_CODE (t2) != ENUMERAL_TYPE + && TREE_CODE (t2) != QUAL_UNION_TYPE + && TREE_CODE (t2) != UNION_TYPE) + return -1; + if (TYPE_SIZE (t2) == 0) + return -1; + } + /* These are the only cases that need special handling. */ + if (TREE_CODE (t) != RECORD_TYPE + && TREE_CODE (t) != ENUMERAL_TYPE + && TREE_CODE (t) != QUAL_UNION_TYPE + && TREE_CODE (t) != UNION_TYPE + && TREE_CODE (t) != POINTER_TYPE) + return -1; + /* Undefined? */ + if (TYPE_SIZE (t) == 0) + return -1; + + /* Look up t in hash table. Only one of the compatible types within each + alias set is recorded in the table. */ + if (!type_hash_table) + type_hash_table = htab_create (1021, c_type_hash, + (htab_eq)(*lang_hooks.types_eq_p), NULL); + slot = htab_find_slot (type_hash_table, t, INSERT); + if (*slot != NULL) + return TYPE_ALIAS_SET ((tree)*slot); + else + /* Our caller will assign and record (in t) a new alias set; all we need + to do is remember t in the hash table. */ + *slot = t; return -1; } Index: c-decl.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v retrieving revision 1.334.2.84 diff -u -d -b -w -c -3 -p -r1.334.2.84 c-decl.c cvs server: conflicting specifications of output style *** c-decl.c 5 Mar 2004 23:48:04 -0000 1.334.2.84 --- c-decl.c 11 Mar 2004 23:43:38 -0000 *************** static GTY(()) tree truly_local_external *** 143,152 **** static GTY(()) tree first_builtin_decl; static GTY(()) tree last_builtin_decl; - /* A DECL for the current file-scope context. */ - - static GTY(()) tree current_file_decl; - /* Set to 0 at beginning of a function definition, set to 1 if a return statement that specifies a return value is seen. */ --- 143,148 ---- Index: c-lang.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-lang.c,v retrieving revision 1.94.2.20 diff -u -d -b -w -c -3 -p -r1.94.2.20 c-lang.c cvs server: conflicting specifications of output style *** c-lang.c 13 Feb 2004 13:10:57 -0000 1.94.2.20 --- c-lang.c 11 Mar 2004 23:43:38 -0000 *************** enum c_language_kind c_language = clk_c; *** 150,155 **** --- 150,158 ---- #undef LANG_HOOKS_GIMPLIFY_EXPR #define LANG_HOOKS_GIMPLIFY_EXPR c_gimplify_expr + #undef LANG_HOOKS_TYPES_EQ_P + #define LANG_HOOKS_TYPES_EQ_P c_types_eq_p + /* ### When changing hooks, consider if ObjC needs changing too!! ### */ /* Each front end provides its own. */ *************** finish_file (void) *** 196,201 **** --- 199,209 ---- c_objc_common_finish_file (); } + int + c_types_eq_p (tree x, tree y) + { + return comptypes (x, y, 0); + } static void c_initialize_diagnostics (diagnostic_context *context) { Index: c-tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-tree.h,v retrieving revision 1.99.2.32 diff -u -d -b -w -c -3 -p -r1.99.2.32 c-tree.h cvs server: conflicting specifications of output style *** c-tree.h 4 Mar 2004 15:38:33 -0000 1.99.2.32 --- c-tree.h 11 Mar 2004 23:43:38 -0000 *************** extern void c_finish_case (void); *** 303,308 **** --- 303,309 ---- extern tree build_asm_expr (tree, tree, tree, tree, bool); extern tree build_asm_stmt (tree, tree); extern tree c_convert_parm_for_inlining (tree, tree, tree, int); + extern int c_types_eq_p (tree, tree); /* Set to 0 at beginning of a function definition, set to 1 if a return statement that specifies a return value is seen. */ Index: c-typeck.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v retrieving revision 1.196.2.42 diff -u -d -b -w -c -3 -p -r1.196.2.42 c-typeck.c cvs server: conflicting specifications of output style *** c-typeck.c 9 Mar 2004 22:23:29 -0000 1.196.2.42 --- c-typeck.c 11 Mar 2004 23:43:38 -0000 *************** tagged_types_tu_compatible_p (tree t1, t *** 672,682 **** /* We have to verify that the tags of the types are the same. This is harder than it looks because this may be a typedef, so we have to go look at the original type. It may even be a typedef of a ! typedef... */ ! while (TYPE_NAME (t1) && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL) t1 = DECL_ORIGINAL_TYPE (TYPE_NAME (t1)); ! while (TYPE_NAME (t2) && TREE_CODE (TYPE_NAME (t2)) == TYPE_DECL) t2 = DECL_ORIGINAL_TYPE (TYPE_NAME (t2)); /* C90 didn't have the requirement that the two tags be the same. */ --- 672,686 ---- /* We have to verify that the tags of the types are the same. This is harder than it looks because this may be a typedef, so we have to go look at the original type. It may even be a typedef of a ! typedef... ! In the case of compiler-created builtin structs the TYPE_DECL ! may be a dummy, with no DECL_ORIGINAL_TYPE. Don't fault. */ ! while (TYPE_NAME (t1) && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL ! && DECL_ORIGINAL_TYPE (TYPE_NAME (t1))) t1 = DECL_ORIGINAL_TYPE (TYPE_NAME (t1)); ! while (TYPE_NAME (t2) && TREE_CODE (TYPE_NAME (t2)) == TYPE_DECL ! && DECL_ORIGINAL_TYPE (TYPE_NAME (t2))) t2 = DECL_ORIGINAL_TYPE (TYPE_NAME (t2)); /* C90 didn't have the requirement that the two tags be the same. */ Index: gimplify.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v retrieving revision 1.1.2.144 diff -u -d -b -w -c -3 -p -r1.1.2.144 gimplify.c cvs server: conflicting specifications of output style *** gimplify.c 26 Feb 2004 05:15:59 -0000 1.1.2.144 --- gimplify.c 11 Mar 2004 23:43:38 -0000 *************** canonicalize_addr_expr (tree* expr_p) *** 1464,1476 **** /* Both cast and addr_expr types should address the same object type. */ dctype = TREE_TYPE (ctype); ddatype = TREE_TYPE (datype); ! if (TYPE_MAIN_VARIANT (ddatype) != TYPE_MAIN_VARIANT (dctype)) return; /* The addr_expr and the object type should match. */ obj_expr = TREE_OPERAND (addr_expr, 0); otype = TREE_TYPE (obj_expr); ! if (TYPE_MAIN_VARIANT (otype) != TYPE_MAIN_VARIANT (datype)) return; /* All checks succeeded. Build a new node to merge the cast. */ --- 1464,1478 ---- /* Both cast and addr_expr types should address the same object type. */ dctype = TREE_TYPE (ctype); ddatype = TREE_TYPE (datype); ! if (!(*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (ddatype), ! TYPE_MAIN_VARIANT (dctype))) return; /* The addr_expr and the object type should match. */ obj_expr = TREE_OPERAND (addr_expr, 0); otype = TREE_TYPE (obj_expr); ! if (!(*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (otype), ! TYPE_MAIN_VARIANT (datype))) return; /* All checks succeeded. Build a new node to merge the cast. */ *************** gimplify_expr (tree *expr_p, tree *pre_p *** 3510,3516 **** static bool cpt_same_type (tree a, tree b) { ! if (TYPE_MAIN_VARIANT (a) == TYPE_MAIN_VARIANT (b)) return true; /* ??? The C++ FE decomposes METHOD_TYPES to FUNCTION_TYPES and doesn't --- 3512,3519 ---- static bool cpt_same_type (tree a, tree b) { ! if ((*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (a), ! TYPE_MAIN_VARIANT (b))) return true; /* ??? The C++ FE decomposes METHOD_TYPES to FUNCTION_TYPES and doesn't Index: langhooks-def.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/langhooks-def.h,v retrieving revision 1.34.2.31 diff -u -d -b -w -c -3 -p -r1.34.2.31 langhooks-def.h cvs server: conflicting specifications of output style *** langhooks-def.h 4 Mar 2004 15:38:48 -0000 1.34.2.31 --- langhooks-def.h 11 Mar 2004 23:43:38 -0000 *************** extern int lhd_unsafe_for_reeval (tree); *** 55,60 **** --- 55,61 ---- extern void lhd_clear_binding_stack (void); extern void lhd_print_tree_nothing (FILE *, tree, int); extern const char *lhd_decl_printable_name (tree, int); + extern int lhd_types_eq_p (tree, tree); extern rtx lhd_expand_expr (tree, rtx, enum machine_mode, int, rtx *); extern int lhd_expand_decl (tree); extern void lhd_print_error_function (struct diagnostic_context *, *************** extern int lhd_gimplify_expr (tree *, tr *** 128,133 **** --- 129,135 ---- #define LANG_HOOKS_GET_CALLEE_FNDECL lhd_return_null_tree #define LANG_HOOKS_EXPR_SIZE lhd_expr_size #define LANG_HOOKS_TREE_SIZE lhd_tree_size + #define LANG_HOOKS_TYPES_EQ_P lhd_types_eq_p #define LANG_HOOKS_FUNCTION_INIT lhd_do_nothing_f #define LANG_HOOKS_FUNCTION_FINAL lhd_do_nothing_f *************** extern tree lhd_make_node (enum tree_cod *** 309,314 **** --- 311,317 ---- LANG_HOOKS_PRINT_TYPE, \ LANG_HOOKS_PRINT_IDENTIFIER, \ LANG_HOOKS_DECL_PRINTABLE_NAME, \ + LANG_HOOKS_TYPES_EQ_P, \ LANG_HOOKS_GET_CALLEE_FNDECL, \ LANG_HOOKS_PRINT_ERROR_FUNCTION, \ LANG_HOOKS_EXPR_SIZE, \ Index: langhooks.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/langhooks.c,v retrieving revision 1.31.2.23 diff -u -d -b -w -c -3 -p -r1.31.2.23 langhooks.c cvs server: conflicting specifications of output style *** langhooks.c 4 Mar 2004 15:38:48 -0000 1.31.2.23 --- langhooks.c 11 Mar 2004 23:43:38 -0000 *************** lhd_decl_printable_name (tree decl, int *** 294,299 **** --- 294,309 ---- return IDENTIFIER_POINTER (DECL_NAME (decl)); } + /* This compares two types for equivalence ("compatible" in C-based languages). + This routine should only return 1 if it is sure. It should not be used + in contexts where erroneously returning 0 causes problems. */ + + int + lhd_types_eq_p (tree x, tree y) + { + return x == y; + } + /* lang_hooks.tree_inlining.walk_subtrees is called by walk_tree() after handling common cases, but before walking code-specific sub-trees. If this hook is overridden for a language, it should Index: langhooks.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v retrieving revision 1.42.2.31 diff -u -d -b -w -c -3 -p -r1.42.2.31 langhooks.h cvs server: conflicting specifications of output style *** langhooks.h 2 Mar 2004 18:41:41 -0000 1.42.2.31 --- langhooks.h 11 Mar 2004 23:43:38 -0000 *************** struct lang_hooks *** 382,387 **** --- 382,392 ---- types in C++. */ const char *(*decl_printable_name) (tree decl, int verbosity); + /* This compares two types for equivalence ("compatible" in C-based languages). + This routine should only return 1 if it is sure. It should not be used + in contexts where erroneously returning 0 causes problems. */ + int (*types_eq_p) (tree x, tree y); + /* Given a CALL_EXPR, return a function decl that is its target. */ tree (*lang_get_callee_fndecl) (tree); Index: stmt.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/stmt.c,v retrieving revision 1.267.2.52 diff -u -d -b -w -c -3 -p -r1.267.2.52 stmt.c cvs server: conflicting specifications of output style *** stmt.c 5 Mar 2004 23:48:17 -0000 1.267.2.52 --- stmt.c 11 Mar 2004 23:43:38 -0000 *************** tail_recursion_args (tree actuals, tree *** 3291,3298 **** for (a = actuals, f = formals, i = 0; a && f; a = TREE_CHAIN (a), f = TREE_CHAIN (f), i++) { ! if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (a))) ! != TYPE_MAIN_VARIANT (TREE_TYPE (f))) return 0; if (GET_CODE (DECL_RTL (f)) != REG || DECL_MODE (f) == BLKmode) return 0; --- 3291,3298 ---- for (a = actuals, f = formals, i = 0; a && f; a = TREE_CHAIN (a), f = TREE_CHAIN (f), i++) { ! if (!(*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (a))), ! TYPE_MAIN_VARIANT (TREE_TYPE (f)))) return 0; if (GET_CODE (DECL_RTL (f)) != REG || DECL_MODE (f) == BLKmode) return 0; Index: toplev.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/toplev.c,v retrieving revision 1.654.2.105 diff -u -d -b -w -c -3 -p -r1.654.2.105 toplev.c cvs server: conflicting specifications of output style *** toplev.c 4 Mar 2004 15:38:54 -0000 1.654.2.105 --- toplev.c 11 Mar 2004 23:43:38 -0000 *************** tree current_function_decl; *** 212,217 **** --- 212,222 ---- if none. */ tree current_function_func_begin_label; + /* A DECL for the current file-scope context. When using IMA, this heads a + chain of FILE_DECLs; currently only C uses it. */ + + tree current_file_decl; + /* Nonzero if doing dwarf2 duplicate elimination. */ int flag_eliminate_dwarf2_dups = 0; Index: tree-nrv.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-nrv.c,v retrieving revision 1.1.2.5 diff -u -d -b -w -c -3 -p -r1.1.2.5 tree-nrv.c cvs server: conflicting specifications of output style *** tree-nrv.c 26 Feb 2004 22:39:00 -0000 1.1.2.5 --- tree-nrv.c 11 Mar 2004 23:43:38 -0000 *************** Boston, MA 02111-1307, USA. */ *** 32,37 **** --- 32,38 ---- #include "timevar.h" #include "tree-dump.h" #include "tree-pass.h" + #include "langhooks.h" /* This file implements return value optimizations for functions which return aggregate types. *************** tree_nrv (void) *** 156,163 **** || TREE_STATIC (found) || TREE_ADDRESSABLE (found) || DECL_ALIGN (found) > DECL_ALIGN (result) ! || (TYPE_MAIN_VARIANT (TREE_TYPE (found)) ! != TYPE_MAIN_VARIANT (result_type))) return; } } --- 157,164 ---- || TREE_STATIC (found) || TREE_ADDRESSABLE (found) || DECL_ALIGN (found) > DECL_ALIGN (result) ! || !((*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (TREE_TYPE (found)), ! TYPE_MAIN_VARIANT (result_type)))) return; } } Index: tree-ssa-ccp.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v retrieving revision 1.1.2.145 diff -u -d -b -w -c -3 -p -r1.1.2.145 tree-ssa-ccp.c cvs server: conflicting specifications of output style *** tree-ssa-ccp.c 28 Feb 2004 01:06:20 -0000 1.1.2.145 --- tree-ssa-ccp.c 11 Mar 2004 23:43:38 -0000 *************** Software Foundation, 59 Temple Place - S *** 40,45 **** --- 40,46 ---- #include "errors.h" #include "ggc.h" #include "tree.h" + #include "langhooks.h" /* These RTL headers are needed for basic-block.h. */ #include "rtl.h" *************** maybe_fold_offset_to_array_ref (tree bas *** 1434,1440 **** if (TREE_CODE (array_type) != ARRAY_TYPE) return NULL_TREE; elt_type = TREE_TYPE (array_type); ! if (TYPE_MAIN_VARIANT (orig_type) != TYPE_MAIN_VARIANT (elt_type)) return NULL_TREE; /* Whee. Ignore indexing of variable sized types. */ --- 1435,1442 ---- if (TREE_CODE (array_type) != ARRAY_TYPE) return NULL_TREE; elt_type = TREE_TYPE (array_type); ! if (!(*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT(orig_type), ! TYPE_MAIN_VARIANT(elt_type))) return NULL_TREE; /* Whee. Ignore indexing of variable sized types. */ *************** maybe_fold_offset_to_component_ref (tree *** 1487,1493 **** return NULL_TREE; /* Short-circuit silly cases. */ ! if (TYPE_MAIN_VARIANT (record_type) == TYPE_MAIN_VARIANT (orig_type)) return NULL_TREE; tail_array_field = NULL_TREE; --- 1489,1496 ---- return NULL_TREE; /* Short-circuit silly cases. */ ! if ((*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT(record_type), ! TYPE_MAIN_VARIANT(orig_type))) return NULL_TREE; tail_array_field = NULL_TREE; *************** maybe_fold_offset_to_component_ref (tree *** 1544,1550 **** /* Here we exactly match the offset being checked. If the types match, then we can return that field. */ ! else if (TYPE_MAIN_VARIANT (orig_type) == TYPE_MAIN_VARIANT (field_type)) { if (base_is_ptr) base = build1 (INDIRECT_REF, record_type, base); --- 1547,1554 ---- /* Here we exactly match the offset being checked. If the types match, then we can return that field. */ ! else if ((*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (orig_type), ! TYPE_MAIN_VARIANT (field_type))) { if (base_is_ptr) base = build1 (INDIRECT_REF, record_type, base); *************** fold_stmt_r (tree *expr_p, int *walk_sub *** 1806,1811 **** --- 1810,1846 ---- *walk_subtrees = 0; t = maybe_fold_stmt_plus (expr); + break; + + case COMPONENT_REF: + t = walk_tree (&TREE_OPERAND (expr, 0), fold_stmt_r, data, NULL); + if (t) + return t; + *walk_subtrees = 0; + + /* Make sure the FIELD_DECL is actually a field in the type on + the lhs. In cases with IMA it is possible that it came + from another, equivalent type at this point. We have + already checked the equivalence in this case. + For unions, we must match on name; do this for structs + also for simplicity. */ + + if ((current_file_decl && TREE_CHAIN (current_file_decl)) + && (DECL_FIELD_CONTEXT (TREE_OPERAND (expr, 1)) != + TREE_TYPE (TREE_OPERAND (expr, 0)))) + { + tree f; + for (f = TYPE_FIELDS (TREE_TYPE (TREE_OPERAND (expr, 0))); + f; f = TREE_CHAIN (f)) + { + if (DECL_NAME (f) == DECL_NAME (TREE_OPERAND (expr, 1))) + { + TREE_OPERAND (expr, 1) = f; + break; + } + } + /* Fall through is an error; it will be detected in tree-sra. */ + } break; default: Index: tree-ssa-copy.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-copy.c,v retrieving revision 1.1.2.3 diff -u -d -b -w -c -3 -p -r1.1.2.3 tree-ssa-copy.c cvs server: conflicting specifications of output style *** tree-ssa-copy.c 25 Feb 2004 03:22:47 -0000 1.1.2.3 --- tree-ssa-copy.c 11 Mar 2004 23:43:38 -0000 *************** Boston, MA 02111-1307, USA. */ *** 37,42 **** --- 37,43 ---- #include "tree-dump.h" #include "tree-flow.h" #include "tree-pass.h" + #include "langhooks.h" /* This file provides a handful of interfaces for performing const/copy propagation and simple expression replacement which keep variable *************** cprop_into_stmt (tree stmt, varray_type *** 226,232 **** constant by converting the constant to the proper type. Note that convert may return a non-gimple expression, in which case we ignore this propagation opportunity. */ ! if (TYPE_MAIN_VARIANT (op_type) != TYPE_MAIN_VARIANT (val_type) && TREE_CODE (val) != SSA_NAME) { val = convert (TREE_TYPE (*op_p), val); --- 227,234 ---- constant by converting the constant to the proper type. Note that convert may return a non-gimple expression, in which case we ignore this propagation opportunity. */ ! if (!(*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT(op_type), ! TYPE_MAIN_VARIANT(val_type)) && TREE_CODE (val) != SSA_NAME) { val = convert (TREE_TYPE (*op_p), val); Index: tree-ssa-dom.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v retrieving revision 1.1.2.146 diff -u -d -b -w -c -3 -p -r1.1.2.146 tree-ssa-dom.c cvs server: conflicting specifications of output style *** tree-ssa-dom.c 8 Mar 2004 02:07:31 -0000 1.1.2.146 --- tree-ssa-dom.c 11 Mar 2004 23:43:38 -0000 *************** Boston, MA 02111-1307, USA. */ *** 41,47 **** #include "real.h" #include "tree-pass.h" #include "flags.h" ! /* This file implements optimizations on the dominator tree. */ --- 41,47 ---- #include "real.h" #include "tree-pass.h" #include "flags.h" ! #include "langhooks.h" /* This file implements optimizations on the dominator tree. */ *************** avail_expr_eq (const void *p1, const voi *** 3090,3097 **** same VUSE operands. */ if (TREE_CODE (rhs1) == TREE_CODE (rhs2) && (TREE_TYPE (rhs1) == TREE_TYPE (rhs2) ! || (TYPE_MAIN_VARIANT (TREE_TYPE (rhs1)) ! == TYPE_MAIN_VARIANT (TREE_TYPE (rhs2)))) && operand_equal_p (rhs1, rhs2, 0)) { vuse_optype ops1 = STMT_VUSE_OPS (s1); --- 3090,3097 ---- same VUSE operands. */ if (TREE_CODE (rhs1) == TREE_CODE (rhs2) && (TREE_TYPE (rhs1) == TREE_TYPE (rhs2) ! || ((*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (TREE_TYPE (rhs1)), ! TYPE_MAIN_VARIANT (TREE_TYPE (rhs2))))) && operand_equal_p (rhs1, rhs2, 0)) { vuse_optype ops1 = STMT_VUSE_OPS (s1); Index: tree-ssa-phiopt.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-phiopt.c,v retrieving revision 1.1.2.8 diff -u -d -b -w -c -3 -p -r1.1.2.8 tree-ssa-phiopt.c cvs server: conflicting specifications of output style *** tree-ssa-phiopt.c 4 Mar 2004 05:08:32 -0000 1.1.2.8 --- tree-ssa-phiopt.c 11 Mar 2004 23:43:38 -0000 *************** Software Foundation, 59 Temple Place - S *** 33,38 **** --- 33,39 ---- #include "tree-flow.h" #include "tree-pass.h" #include "tree-dump.h" + #include "langhooks.h" static void tree_ssa_phiopt (void); static bool conditional_replacement (basic_block bb, tree phi, tree arg0, *************** conditional_replacement (basic_block bb, *** 177,191 **** cond = COND_EXPR_COND (last_stmt (cond_block)); result = PHI_RESULT (phi); if (TREE_CODE (cond) != SSA_NAME ! && (TYPE_MAIN_VARIANT (TREE_TYPE (cond)) ! != TYPE_MAIN_VARIANT (TREE_TYPE (result)))) return false; /* If the condition was a naked SSA_NAME and the type is not the same as the type of the result, then convert the type of the condition. */ ! if (TYPE_MAIN_VARIANT (TREE_TYPE (cond)) ! != TYPE_MAIN_VARIANT (TREE_TYPE (result))) cond = convert (TREE_TYPE (result), cond); /* We need to know which is the true edge and which is the false --- 178,192 ---- cond = COND_EXPR_COND (last_stmt (cond_block)); result = PHI_RESULT (phi); if (TREE_CODE (cond) != SSA_NAME ! && !((*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (TREE_TYPE (cond)), ! TYPE_MAIN_VARIANT (TREE_TYPE (result))))) return false; /* If the condition was a naked SSA_NAME and the type is not the same as the type of the result, then convert the type of the condition. */ ! if (!(*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (TREE_TYPE (cond)), ! TYPE_MAIN_VARIANT (TREE_TYPE (result)))) cond = convert (TREE_TYPE (result), cond); /* We need to know which is the true edge and which is the false Index: tree-ssa.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v retrieving revision 1.1.4.208 diff -u -d -b -w -c -3 -p -r1.1.4.208 tree-ssa.c cvs server: conflicting specifications of output style *** tree-ssa.c 3 Mar 2004 13:11:54 -0000 1.1.4.208 --- tree-ssa.c 11 Mar 2004 23:43:38 -0000 *************** tree_ssa_useless_type_conversion_1 (tree *** 3641,3647 **** strip the type conversion and enter the equivalence into the table. */ if (inner_type == outer_type ! || TYPE_MAIN_VARIANT (inner_type) == TYPE_MAIN_VARIANT (outer_type)) return true; /* If both types are pointers and the outer type is a (void *), then --- 3641,3648 ---- strip the type conversion and enter the equivalence into the table. */ if (inner_type == outer_type ! || ((*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (inner_type), ! TYPE_MAIN_VARIANT (outer_type)))) return true; /* If both types are pointers and the outer type is a (void *), then *************** tree_ssa_useless_type_conversion_1 (tree *** 3659,3666 **** so strip conversions that just switch between them. */ else if (POINTER_TYPE_P (inner_type) && POINTER_TYPE_P (outer_type) ! && (TYPE_MAIN_VARIANT (TREE_TYPE (inner_type)) ! == TYPE_MAIN_VARIANT (TREE_TYPE (outer_type)))) return true; /* If both the inner and outer types are integral types, then the --- 3660,3667 ---- so strip conversions that just switch between them. */ else if (POINTER_TYPE_P (inner_type) && POINTER_TYPE_P (outer_type) ! && ((*lang_hooks.types_eq_p)(TYPE_MAIN_VARIANT (inner_type), ! TYPE_MAIN_VARIANT (outer_type)))) return true; /* If both the inner and outer types are integral types, then the Index: tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree.h,v retrieving revision 1.342.2.177 diff -u -d -b -w -c -3 -p -r1.342.2.177 tree.h cvs server: conflicting specifications of output style *** tree.h 8 Mar 2004 18:05:42 -0000 1.342.2.177 --- tree.h 11 Mar 2004 23:43:38 -0000 *************** extern GTY(()) tree current_function_dec *** 3233,3238 **** --- 3233,3243 ---- /* Nonzero means a FUNC_BEGIN label was emitted. */ extern GTY(()) tree current_function_func_begin_label; + /* A DECL for the current file-scope context. When using IMA, this heads a + chain of FILE_DECLs; currently only C uses it. */ + + extern GTY(()) tree current_file_decl; + /* Nonzero means all ..._TYPE nodes should be allocated permanently. */ extern int all_types_permanent; Index: cp/cp-lang.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v retrieving revision 1.36.2.32 diff -u -d -b -w -c -3 -p -r1.36.2.32 cp-lang.c cvs server: conflicting specifications of output style *** cp/cp-lang.c 2 Mar 2004 18:42:42 -0000 1.36.2.32 --- cp/cp-lang.c 11 Mar 2004 23:43:38 -0000 *************** static bool cxx_warn_unused_global_decl *** 39,44 **** --- 39,45 ---- static tree cp_expr_size (tree); static size_t cp_tree_size (enum tree_code); static bool cp_var_mod_type_p (tree); + static int cxx_types_eq_p (tree, tree); static int cp_expand_decl (tree); static void cxx_initialize_diagnostics (diagnostic_context *); *************** static void cxx_initialize_diagnostics ( *** 181,186 **** --- 182,189 ---- #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR cxx_incomplete_type_error #undef LANG_HOOKS_TYPE_PROMOTES_TO #define LANG_HOOKS_TYPE_PROMOTES_TO cxx_type_promotes_to + #undef LANG_HOOKS_TYPES_EQ_P + #define LANG_HOOKS_TYPES_EQ_P cxx_types_eq_p #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE #define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type #undef LANG_HOOKS_GIMPLIFY_EXPR *************** cp_var_mod_type_p (tree type) *** 355,360 **** --- 358,368 ---- /* All other types are not variably modified. */ return false; + } + + static int cxx_types_eq_p (tree x, tree y) + { + return comptypes (x, y, 0); } /* Stub routine to tell people that this doesn't work yet. */