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]

[PATCH][LTO] Separate type fixup from comparison


This separates type fixup (completion of incomplete types) from
gimple_types_compatible_p.  This avoids performing fixups to
types that are not compatible with the one we are searching
or that will end up not as the canonical variant.

Which should make type completion more predictable (not completing
stuff that we happen to come along because of hash collisions for
example).  In practice I don't expect this to make a difference though.

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

Ok?

Thanks,
Richard.

2010-07-09  Richard Guenther  <rguenther@suse.de>

	* gimple.c (struct type_fixup_s): New struct and VEC type.
	(gimple_register_type_fixups): New static global.
	(gimple_queue_type_fixup): New function.
	(gimple_types_compatible_p): Queue type fixups instead of
	applying them here.
	(gimple_register_type): Apply queued fixups for the
	canonical type.  Empty the type fixup queue.

Index: gcc/gimple.c
===================================================================
*** gcc/gimple.c	(revision 162004)
--- gcc/gimple.c	(working copy)
*************** gimple_compare_field_offset (tree f1, tr
*** 3323,3328 ****
--- 3323,3348 ----
    return false;
  }
  
+ typedef struct type_fixup_s {
+     tree context;
+     tree *incomplete;
+     tree complete;
+ } type_fixup;
+ DEF_VEC_O(type_fixup);
+ DEF_VEC_ALLOC_O(type_fixup,heap);
+ 
+ static VEC(type_fixup, heap) *gimple_register_type_fixups = NULL;
+ 
+ static void
+ gimple_queue_type_fixup (tree context, tree *incomplete, tree complete)
+ {
+   type_fixup f;
+   f.context = context;
+   f.incomplete = incomplete;
+   f.complete = complete;
+   VEC_safe_push (type_fixup, heap, gimple_register_type_fixups, &f);
+ }
+ 
  /* Return 1 iff T1 and T2 are structurally identical.
     Otherwise, return 0.  */
  
*************** gimple_types_compatible_p (tree t1, tree
*** 3555,3563 ****
  	       in one unit and to complete ones in another.  So we
  	       probably should merge these types only with more context.  */
  	    if (COMPLETE_TYPE_P (TREE_TYPE (t2)))
! 	      TREE_TYPE (t1) = TREE_TYPE (t2);
  	    else
! 	      TREE_TYPE (t2) = TREE_TYPE (t1);
  	    goto same_types;
  	  }
  
--- 3575,3583 ----
  	       in one unit and to complete ones in another.  So we
  	       probably should merge these types only with more context.  */
  	    if (COMPLETE_TYPE_P (TREE_TYPE (t2)))
! 	      gimple_queue_type_fixup (t1, &TREE_TYPE (t1), TREE_TYPE (t2));
  	    else
! 	      gimple_queue_type_fixup (t2, &TREE_TYPE (t2), TREE_TYPE (t1));
  	    goto same_types;
  	  }
  
*************** gimple_register_type (tree t)
*** 4014,4024 ****
--- 4034,4047 ----
    if (gimple_types == NULL)
      gimple_types = htab_create (16381, gimple_type_hash, gimple_type_eq, 0);
  
+   gcc_assert (VEC_empty (type_fixup, gimple_register_type_fixups));
    slot = htab_find_slot (gimple_types, t, INSERT);
    if (*slot
        && *(tree *)slot != t)
      {
        tree new_type = (tree) *((tree *) slot);
+       unsigned i;
+       type_fixup *f;
  
        /* Do not merge types with different addressability.  */
        gcc_assert (TREE_ADDRESSABLE (t) == TREE_ADDRESSABLE (new_type));
*************** gimple_register_type (tree t)
*** 4070,4075 ****
--- 4093,4103 ----
  
        TYPE_CANONICAL (t) = new_type;
        t = new_type;
+ 
+       for (i = 0;
+ 	   VEC_iterate (type_fixup, gimple_register_type_fixups, i, f); ++i)
+ 	if (f->context == t)
+ 	  *(f->incomplete) = f->complete;
      }
    else
      {
*************** gimple_register_type (tree t)
*** 4077,4082 ****
--- 4105,4111 ----
        *slot = (void *) t;
      }
  
+   VEC_truncate (type_fixup, gimple_register_type_fixups, 0);
    return t;
  }
  


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