public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][1/n] LTO type merging cleanup
@ 2011-05-09 16:49 Richard Guenther
  2011-05-11 15:27 ` H.J. Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Guenther @ 2011-05-09 16:49 UTC (permalink / raw)
  To: gcc-patches


This makes gimple_types_compatible_p private to gimple.c again,
removing the need to call it from lto-symtab.c as we now merge
types early (and thus we can resort to the middle-end types_compatible_p
function).

Bootstrapped on x86_64-unknown-linux-gnu, testing and SPEC2k6 build
in progress.

Richard.

2011-05-09  Richard Guenther  <rguenther@suse.de>

	* lto-symtab.c (lto_cgraph_replace_node): Use types_compatible_p
	for diagnostics.
	(lto_symtab_merge): Likewise.  Do not register types here.
	(lto_symtab_merge_decls_2): Likewise.
	(lto_symtab_merge_decls_1): Likewise.
	* gimple.h (enum gtc_mode, gimple_types_compatible_p): Do not declare.
	* gimple.c (enum gtc_mode): Declare.
	(gimple_types_compatible_p): Make static.

Index: gcc/lto-symtab.c
===================================================================
*** gcc/lto-symtab.c	(revision 173560)
--- gcc/lto-symtab.c	(working copy)
*************** lto_cgraph_replace_node (struct cgraph_n
*** 243,250 ****
  
    /* Redirect all incoming edges.  */
    compatible_p
!     = gimple_types_compatible_p (TREE_TYPE (TREE_TYPE (prevailing_node->decl)),
! 				 TREE_TYPE (TREE_TYPE (node->decl)), GTC_DIAG);
    for (e = node->callers; e; e = next)
      {
        next = e->next_caller;
--- 243,250 ----
  
    /* Redirect all incoming edges.  */
    compatible_p
!     = types_compatible_p (TREE_TYPE (TREE_TYPE (prevailing_node->decl)),
! 			  TREE_TYPE (TREE_TYPE (node->decl)));
    for (e = node->callers; e; e = next)
      {
        next = e->next_caller;
*************** lto_symtab_merge (lto_symtab_entry_t pre
*** 360,367 ****
  
    if (TREE_CODE (decl) == FUNCTION_DECL)
      {
!       if (!gimple_types_compatible_p (TREE_TYPE (prevailing_decl),
! 				      TREE_TYPE (decl), GTC_DIAG))
  	/* If we don't have a merged type yet...sigh.  The linker
  	   wouldn't complain if the types were mismatched, so we
  	   probably shouldn't either.  Just use the type from
--- 360,367 ----
  
    if (TREE_CODE (decl) == FUNCTION_DECL)
      {
!       if (!types_compatible_p (TREE_TYPE (prevailing_decl),
! 			       TREE_TYPE (decl)))
  	/* If we don't have a merged type yet...sigh.  The linker
  	   wouldn't complain if the types were mismatched, so we
  	   probably shouldn't either.  Just use the type from
*************** lto_symtab_merge (lto_symtab_entry_t pre
*** 390,400 ****
    prevailing_type = TYPE_MAIN_VARIANT (TREE_TYPE (prevailing_decl));
    type = TYPE_MAIN_VARIANT (TREE_TYPE (decl));
  
!   /* We have to register and fetch canonical types here as the global
!      fixup process didn't yet run.  */
!   prevailing_type = gimple_register_type (prevailing_type);
!   type = gimple_register_type (type);
!   if (!gimple_types_compatible_p (prevailing_type, type, GTC_DIAG))
      {
        if (COMPLETE_TYPE_P (type))
  	return false;
--- 390,396 ----
    prevailing_type = TYPE_MAIN_VARIANT (TREE_TYPE (prevailing_decl));
    type = TYPE_MAIN_VARIANT (TREE_TYPE (decl));
  
!   if (!types_compatible_p (prevailing_type, type))
      {
        if (COMPLETE_TYPE_P (type))
  	return false;
*************** lto_symtab_merge (lto_symtab_entry_t pre
*** 419,427 ****
  	  if (TREE_CODE (tem1) != TREE_CODE (tem2))
  	    return false;
  
! 	  if (!gimple_types_compatible_p (gimple_register_type (tem1),
! 					  gimple_register_type (tem2),
! 					  GTC_DIAG))
  	    return false;
  	}
  
--- 415,421 ----
  	  if (TREE_CODE (tem1) != TREE_CODE (tem2))
  	    return false;
  
! 	  if (!types_compatible_p (tem1, tem2))
  	    return false;
  	}
  
*************** lto_symtab_merge_decls_2 (void **slot, b
*** 620,627 ****
    /* Diagnose all mismatched re-declarations.  */
    FOR_EACH_VEC_ELT (tree, mismatches, i, decl)
      {
!       if (!gimple_types_compatible_p (TREE_TYPE (prevailing->decl),
! 				      TREE_TYPE (decl), GTC_DIAG))
  	diagnosed_p |= warning_at (DECL_SOURCE_LOCATION (decl), 0,
  				   "type of %qD does not match original "
  				   "declaration", decl);
--- 614,620 ----
    /* Diagnose all mismatched re-declarations.  */
    FOR_EACH_VEC_ELT (tree, mismatches, i, decl)
      {
!       if (!types_compatible_p (TREE_TYPE (prevailing->decl), TREE_TYPE (decl)))
  	diagnosed_p |= warning_at (DECL_SOURCE_LOCATION (decl), 0,
  				   "type of %qD does not match original "
  				   "declaration", decl);
*************** lto_symtab_merge_decls_1 (void **slot, v
*** 744,753 ****
        inform (DECL_SOURCE_LOCATION (prevailing->decl),
  	      "previously declared here");
  
-   /* Register and adjust types of the entries.  */
-   for (e = (lto_symtab_entry_t) *slot; e; e = e->next)
-     TREE_TYPE (e->decl) = gimple_register_type (TREE_TYPE (e->decl));
- 
    /* Merge the chain to the single prevailing decl and diagnose
       mismatches.  */
    lto_symtab_merge_decls_2 (slot, diagnosed_p);
--- 737,742 ----
Index: gcc/gimple.h
===================================================================
*** gcc/gimple.h	(revision 173560)
--- gcc/gimple.h	(working copy)
*************** extern void recalculate_side_effects (tr
*** 965,972 ****
  extern bool gimple_compare_field_offset (tree, tree);
  extern tree gimple_register_type (tree);
  extern tree gimple_register_canonical_type (tree);
- enum gtc_mode { GTC_MERGE = 0, GTC_DIAG = 1 };
- extern bool gimple_types_compatible_p (tree, tree, enum gtc_mode);
  extern void print_gimple_types_stats (void);
  extern void free_gimple_type_tables (void);
  extern tree gimple_unsigned_type (tree);
--- 965,970 ----
Index: gcc/gimple.c
===================================================================
*** gcc/gimple.c	(revision 173560)
--- gcc/gimple.c	(working copy)
*************** gimple_call_copy_skip_args (gimple stmt,
*** 3208,3213 ****
--- 3208,3215 ----
  }
  
  
+ enum gtc_mode { GTC_MERGE = 0, GTC_DIAG = 1 };
+ 
  static hashval_t gimple_type_hash_1 (const void *, enum gtc_mode);
  
  /* Structure used to maintain a cache of some type pairs compared by
*************** pop:
*** 3908,3914 ****
     FOR_MERGING_P is true the an incomplete type and a complete type
     are considered different, otherwise they are considered compatible.  */
  
! bool
  gimple_types_compatible_p (tree t1, tree t2, enum gtc_mode mode)
  {
    VEC(type_pair_t, heap) *sccstack = NULL;
--- 3910,3916 ----
     FOR_MERGING_P is true the an incomplete type and a complete type
     are considered different, otherwise they are considered compatible.  */
  
! static bool
  gimple_types_compatible_p (tree t1, tree t2, enum gtc_mode mode)
  {
    VEC(type_pair_t, heap) *sccstack = NULL;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][1/n] LTO type merging cleanup
  2011-05-09 16:49 [PATCH][1/n] LTO type merging cleanup Richard Guenther
@ 2011-05-11 15:27 ` H.J. Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2011-05-11 15:27 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches

On Mon, May 9, 2011 at 8:15 AM, Richard Guenther <rguenther@suse.de> wrote:
>
> This makes gimple_types_compatible_p private to gimple.c again,
> removing the need to call it from lto-symtab.c as we now merge
> types early (and thus we can resort to the middle-end types_compatible_p
> function).
>
> Bootstrapped on x86_64-unknown-linux-gnu, testing and SPEC2k6 build
> in progress.
>

Given that one of LTO type merging cleanup patches breaks LTO bootstrap,
I think we should pause and fix LTO bootstrap before applying more patches.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-11 14:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-09 16:49 [PATCH][1/n] LTO type merging cleanup Richard Guenther
2011-05-11 15:27 ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).