This is the mail archive of the gcc-bugs@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]

[Bug tree-optimization/16688] [3.5 regression] ICE in group_aliases, at tree-ssa-alias.c:1234


------- Additional Comments From dnovillo at redhat dot com  2004-07-23 20:40 -------
Subject: Re:  New: [3.5 regression] ICE in
	group_aliases, at tree-ssa-alias.c:1234


Fixes PR16688 and PR16689.  Once again our IL is not helping wrt types. 
I had to specifically check for types_compatible_p in
may_propagate_copy.

This was causing the aliasing code to give out memory tags that had
different alias sets.  This is now explicitly checked in get_tmt_for.

Also, the copy renaming was causing SSA_NAMEs to have different type as
its underlying symbol.  We now block coalescing when two names don't
have compatible types and also make sure that we update the type of the
SSA_NAME when we change its symbol.

The patch also fixes a bug in alias grouping, where it would mistakenly
treat type tags as regular variables.  This particular failure is hard
to reproduce.  The original case in PR 16688 triggers it, but the
minimized case has a syntax error.

The other failures are caught in a regular bootstrap with checking
enabled.

Bootstrap on x86, x86-64, alpha and ppc still in progress.  Will commit
once they finish.

Gerald, Wolfgang, could you please check that it fixes the problem?


Thanks.  Diego.



	PR tree-optimization/16688
	PR tree-optimization/16689
	* tree-ssa-alias.c (setup_pointers_and_addressables): Remove
	unnecessary initialization of 'tag'.
	(get_tmt_for): Check that the new type tag has the same alias
	set as the pointed-to type.
	(group_aliases): Only regular variables need to be removed
	from the alias set of a name tag.
	* tree-ssa-copy.c (may_propagate_copy): Do not allow copy
	propagation if the two types are not compatible.
	(merge_alias_info): Rename from replace_ssa_names_ann.
	Add more checking.
	(replace_exp_1): If both arguments are SSA_NAMEs, check that
	the propagation can be done.
	Only call merge_alias_info on pointers.
	(propagate_value): Likewise.
	* tree-ssa-copyrename.c: Include langhooks.h.
	(copy_rename_partition_coalesce): Call replace_ssa_name_symbol
	to do the merging.
	Do not coalesce variables with incompatible types.
	(rename_ssa_copies): Call replace_ssa_name_symbol.
	* tree-ssa.c (verify_ssa_name): Verify that the SSA_NAME has
	the same type as the underlying _DECL.
	* tree-ssanames.c (replace_ssa_name_symbol): New function.
	* tree.h (replace_ssa_name_symbol): Declare.

Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.14
diff -d -c -p -r2.14 tree-ssa-alias.c
*** tree-ssa-alias.c	22 Jul 2004 16:39:48 -0000	2.14
--- tree-ssa-alias.c	23 Jul 2004 20:20:41 -0000
*************** group_aliases (struct alias_info *ai)
*** 1225,1231 ****
  	{
  	  tree alias = VARRAY_TREE (aliases, j);
  	  var_ann_t ann = var_ann (alias);
! 	  if (ann->may_aliases)
  	    {
  	      tree new_alias;
  
--- 1225,1232 ----
  	{
  	  tree alias = VARRAY_TREE (aliases, j);
  	  var_ann_t ann = var_ann (alias);
! 
! 	  if (ann->mem_tag_kind == NOT_A_TAG && ann->may_aliases)
  	    {
  	      tree new_alias;
  
*************** setup_pointers_and_addressables (struct 
*** 1370,1376 ****
  	  && (bitmap_bit_p (ai->dereferenced_ptrs_store, v_ann->uid)
  	      || bitmap_bit_p (ai->dereferenced_ptrs_load, v_ann->uid)))
  	{
! 	  tree tag = v_ann->type_mem_tag;
  	  var_ann_t t_ann;
  
  	  /* If pointer VAR still doesn't have a memory tag associated
--- 1371,1377 ----
  	  && (bitmap_bit_p (ai->dereferenced_ptrs_store, v_ann->uid)
  	      || bitmap_bit_p (ai->dereferenced_ptrs_load, v_ann->uid)))
  	{
! 	  tree tag;
  	  var_ann_t t_ann;
  
  	  /* If pointer VAR still doesn't have a memory tag associated
*************** get_tmt_for (tree ptr, struct alias_info
*** 2170,2175 ****
--- 2171,2184 ----
        ai->pointers[ai->num_pointers++] = alias_map;
      }
  
+ #if defined ENABLE_CHECKING
+   /* Make sure that the type tag has the same alias set as the
+      pointed-to type.  */
+   if (tag_set != get_alias_set (tag))
+     abort ();
+ #endif
+ 
+ 
    return tag;
  }
  
Index: tree-ssa-copy.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-copy.c,v
retrieving revision 2.10
diff -d -c -p -r2.10 tree-ssa-copy.c
*** tree-ssa-copy.c	7 Jul 2004 20:16:00 -0000	2.10
--- tree-ssa-copy.c	23 Jul 2004 20:20:41 -0000
*************** may_propagate_copy (tree dest, tree orig
*** 110,115 ****
--- 110,117 ----
        tree mt_orig = var_ann (SSA_NAME_VAR (orig))->type_mem_tag;
        if (mt_dest && mt_orig && mt_dest != mt_orig)
  	return false;
+       else if (!lang_hooks.types_compatible_p (type_d, type_o))
+ 	return false;
      }
  
    /* If the destination is a SSA_NAME for a virtual operand, then we have
*************** may_propagate_copy (tree dest, tree orig
*** 152,192 ****
    return true;
  }
  
- /* Given two SSA_NAMEs, replace the annotations for the one referred to by OP 
-    with VAR's annotations.
  
!    If OP is a pointer, copy the memory tag used originally by OP into
!    VAR.  This is needed in cases where VAR had never been dereferenced in the
!    program.
! 
!    If FOR_PROPAGATION is true, then perform additional checks to ensure
!    that const/copy propagation of var for OP is valid.  */
     
  static void
! replace_ssa_names_ann (tree op,
! 		   tree var,
! 		   bool for_propagation ATTRIBUTE_UNUSED)
  {
  #if defined ENABLE_CHECKING
!   if (for_propagation && !may_propagate_copy (op, var))
      abort ();
- #endif
  
!   /* If VAR doesn't have a memory tag, copy the one from the original
!      operand.  Also copy the dereferenced flags.  */
!   if (POINTER_TYPE_P (TREE_TYPE (op)))
!     {
!       var_ann_t new_ann = var_ann (SSA_NAME_VAR (var));
!       var_ann_t orig_ann = var_ann (SSA_NAME_VAR (op));
! 
!       if (new_ann->type_mem_tag == NULL_TREE)
! 	new_ann->type_mem_tag = orig_ann->type_mem_tag;
!       else if (orig_ann->type_mem_tag == NULL_TREE)
! 	orig_ann->type_mem_tag = new_ann->type_mem_tag;
!       else if (new_ann->type_mem_tag != orig_ann->type_mem_tag)
! 	abort ();
!     }
  
  }   
  
  
--- 154,193 ----
    return true;
  }
  
  
! /* Given two SSA_NAMEs pointers ORIG and NEW such that we are copy
!    propagating NEW into ORIG, consolidate aliasing information so that
!    they both share the same memory tags.  */
     
  static void
! merge_alias_info (tree orig, tree new)
  {
+   tree new_sym = SSA_NAME_VAR (new);
+   tree orig_sym = SSA_NAME_VAR (orig);
+   var_ann_t new_ann = var_ann (new_sym);
+   var_ann_t orig_ann = var_ann (orig_sym);
+ 
  #if defined ENABLE_CHECKING
!   if (!POINTER_TYPE_P (TREE_TYPE (orig))
!       || !POINTER_TYPE_P (TREE_TYPE (new))
!       || !lang_hooks.types_compatible_p (TREE_TYPE (orig), TREE_TYPE (new)))
      abort ();
  
!   /* If the pointed-to alias sets are different, these two pointers
!      would never have the same memory tag.  In this case, NEW should
!      not have been propagated into ORIG.  */
!   if (get_alias_set (TREE_TYPE (TREE_TYPE (new_sym)))
!       != get_alias_set (TREE_TYPE (TREE_TYPE (orig_sym))))
!     abort ();
! #endif
  
+   /* Merge type-based alias info.  */
+   if (new_ann->type_mem_tag == NULL_TREE)
+     new_ann->type_mem_tag = orig_ann->type_mem_tag;
+   else if (orig_ann->type_mem_tag == NULL_TREE)
+     orig_ann->type_mem_tag = new_ann->type_mem_tag;
+   else if (new_ann->type_mem_tag != orig_ann->type_mem_tag)
+     abort ();
  }   
  
  
*************** replace_ssa_names_ann (tree op,
*** 196,207 ****
     replacement is done to propagate a value or not.  */
  
  static void
! replace_exp_1 (use_operand_p op_p, tree val, bool for_propagation)
  {
    if (TREE_CODE (val) == SSA_NAME)
      {
!       if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME)
! 	replace_ssa_names_ann (USE_FROM_PTR (op_p), val, for_propagation);
        SET_USE (op_p, val);
      }
    else
--- 197,219 ----
     replacement is done to propagate a value or not.  */
  
  static void
! replace_exp_1 (use_operand_p op_p, tree val,
! 	       bool for_propagation ATTRIBUTE_UNUSED)
  {
+   tree op = USE_FROM_PTR (op_p);
+ 
+ #if defined ENABLE_CHECKING
+   if (for_propagation
+       && TREE_CODE (op) == SSA_NAME
+       && TREE_CODE (val) == SSA_NAME
+       && !may_propagate_copy (op, val))
+     abort ();
+ #endif
+ 
    if (TREE_CODE (val) == SSA_NAME)
      {
!       if (TREE_CODE (op) == SSA_NAME && POINTER_TYPE_P (TREE_TYPE (op)))
! 	merge_alias_info (op, val);
        SET_USE (op_p, val);
      }
    else
*************** propagate_value (use_operand_p op_p, tre
*** 233,242 ****
  void
  propagate_tree_value (tree *op_p, tree val)
  {
    if (TREE_CODE (val) == SSA_NAME)
      {
!       if (TREE_CODE (*op_p) == SSA_NAME)
! 	replace_ssa_names_ann (*op_p, val, true);
        *op_p = val;
      }
    else
--- 245,261 ----
  void
  propagate_tree_value (tree *op_p, tree val)
  {
+ #if defined ENABLE_CHECKING
+   if (TREE_CODE (val) == SSA_NAME
+       && TREE_CODE (*op_p) == SSA_NAME
+       && !may_propagate_copy (*op_p, val))
+     abort ();
+ #endif
+ 
    if (TREE_CODE (val) == SSA_NAME)
      {
!       if (TREE_CODE (*op_p) == SSA_NAME && POINTER_TYPE_P (TREE_TYPE (*op_p)))
! 	merge_alias_info (*op_p, val);
        *op_p = val;
      }
    else
Index: tree-ssa-copyrename.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-copyrename.c,v
retrieving revision 2.6
diff -d -c -p -r2.6 tree-ssa-copyrename.c
*** tree-ssa-copyrename.c	16 Jul 2004 20:40:24 -0000	2.6
--- tree-ssa-copyrename.c	23 Jul 2004 20:20:41 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 38,43 ****
--- 38,44 ----
  #include "tree-dump.h"
  #include "tree-ssa-live.h"
  #include "tree-pass.h"
+ #include "langhooks.h"
  
  extern void rename_ssa_copies (void);
  
*************** copy_rename_partition_coalesce (var_map 
*** 247,262 ****
  	gimp2 = false;
        }
  
    /* Merge the two partitions.  */
    p3 = partition_union (map->var_partition, p1, p2);
  
    /* Set the root variable of the partition to the better choice, if there is 
       one.  */
    if (!gimp2)
!     SSA_NAME_VAR (partition_to_var (map, p3)) = root2;
    else
      if (!gimp1)
!       SSA_NAME_VAR (partition_to_var (map, p3)) = root1;
  
    /* Update the various flag widgitry of the current base representative.  */
    ann3 = var_ann (SSA_NAME_VAR (partition_to_var (map, p3)));
--- 248,271 ----
  	gimp2 = false;
        }
  
+   /* Don't coalesce if the two variables aren't type compatible.  */
+   if (!lang_hooks.types_compatible_p (TREE_TYPE (root1), TREE_TYPE (root2)))
+     {
+       if (debug)
+ 	fprintf (debug, " : Incompatible types.  No coalesce.\n");
+       return;
+     }
+ 
    /* Merge the two partitions.  */
    p3 = partition_union (map->var_partition, p1, p2);
  
    /* Set the root variable of the partition to the better choice, if there is 
       one.  */
    if (!gimp2)
!     replace_ssa_name_symbol (partition_to_var (map, p3), root2);
    else
      if (!gimp1)
!       replace_ssa_name_symbol (partition_to_var (map, p3), root1);
  
    /* Update the various flag widgitry of the current base representative.  */
    ann3 = var_ann (SSA_NAME_VAR (partition_to_var (map, p3)));
*************** rename_ssa_copies (void)
*** 359,365 ****
  	      fprintf (debug, "\n");
  	    }
  	}
!       SSA_NAME_VAR (var) = SSA_NAME_VAR (part_var);
      }
  
    delete_var_map (map);
--- 368,374 ----
  	      fprintf (debug, "\n");
  	    }
  	}
!       replace_ssa_name_symbol (var, SSA_NAME_VAR (part_var));
      }
  
    delete_var_map (map);
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.22
diff -d -c -p -r2.22 tree-ssa.c
*** tree-ssa.c	22 Jul 2004 16:39:48 -0000	2.22
--- tree-ssa.c	23 Jul 2004 20:20:41 -0000
*************** verify_ssa_name (tree ssa_name, bool is_
*** 118,123 ****
--- 118,129 ----
        return true;
      }
  
+   if (TREE_TYPE (ssa_name) != TREE_TYPE (SSA_NAME_VAR (ssa_name)))
+     {
+       error ("Type mismatch between an SSA_NAME and its symbol.");
+       return true;
+     }
+ 
    if (SSA_NAME_IN_FREE_LIST (ssa_name))
      {
        error ("Found an SSA_NAME that had been released into the free pool");
Index: tree-ssanames.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssanames.c,v
retrieving revision 2.4
diff -d -c -p -r2.4 tree-ssanames.c
*** tree-ssanames.c	22 Jul 2004 16:39:49 -0000	2.4
--- tree-ssanames.c	23 Jul 2004 20:20:41 -0000
*************** release_defs (tree stmt)
*** 249,252 ****
--- 249,262 ----
      release_ssa_name (V_MUST_DEF_OP (v_must_defs, i));
  }
  
+ 
+ /* Replace the symbol associated with SSA_NAME with SYM.  */
+ 
+ void
+ replace_ssa_name_symbol (tree ssa_name, tree sym)
+ {
+   SSA_NAME_VAR (ssa_name) = sym;
+   TREE_TYPE (ssa_name) = TREE_TYPE (sym);
+ }
+ 
  #include "gt-tree-ssanames.h"
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.569
diff -d -c -p -r1.569 tree.h
*** tree.h	22 Jul 2004 16:39:49 -0000	1.569
--- tree.h	23 Jul 2004 20:20:42 -0000
*************** extern tree make_ssa_name (tree, tree);
*** 2648,2653 ****
--- 2648,2654 ----
  extern tree duplicate_ssa_name (tree, tree);
  extern void release_ssa_name (tree);
  extern void release_defs (tree);
+ extern void replace_ssa_name_symbol (tree, tree);
  
  #ifdef GATHER_STATISTICS
  extern void ssanames_print_statistics (void);




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16688


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