View | Details | Raw Unified | Return to bug 33136 | Differences between
and this patch

Collapse All | Expand All

(-)gcc/tree-ssa-alias.c.jj (-30 / +27 lines)
Lines 2802-2851 may_alias_p (tree ptr, alias_set_type me Link Here
2802
	 types involved.  */
2802
	 types involved.  */
2803
      if (mem_alias_set != 0 && var_alias_set != 0)
2803
      if (mem_alias_set != 0 && var_alias_set != 0)
2804
	{
2804
	{
2805
	  tree ptr_type = TREE_TYPE (ptr);
2806
	  tree var_type = TREE_TYPE (var);
2805
	  tree var_type = TREE_TYPE (var);
2807
      
2806
      
2808
	  /* The star count is -1 if the type at the end of the
2807
	  /* The star count is -1 if the type at the end of the
2809
	     pointer_to chain is not a record or union type. */ 
2808
	     pointer_to chain is not a record or union type.
2809
	     If star count is bigger than 0, VAR is a pointer
2810
	     to a record or union or pointer to pointer, etc.
2811
	     For
2812
	       struct A *var;
2813
	       struct A **ptr;
2814
	     may_alias_p query it only matters if &var was seen or
2815
	     not, ipa type escape analysis of the fields doesn't
2816
	     give useful information - this is the same as if
2817
	     instead of struct A void or int was used.  */
2810
	  if ((!alias_set_only) && 
2818
	  if ((!alias_set_only) && 
2811
	      ipa_type_escape_star_count_of_interesting_type (var_type) >= 0)
2819
	      ipa_type_escape_star_count_of_interesting_type (var_type) == 0)
2812
	    {
2820
	    {
2813
	      int ptr_star_count = 0;
2821
	      tree pointed_type = TREE_TYPE (TREE_TYPE (ptr));
2814
	  
2822
2815
	      /* ipa_type_escape_star_count_of_interesting_type is a
2823
	      /* For
2816
		 little too restrictive for the pointer type, need to
2824
		 struct A var;
2817
		 allow pointers to primitive types as long as those
2825
		 struct A *ptr;
2818
		 types cannot be pointers to everything.  */
2826
		 ipa type escape analysis isn't useful, presence
2819
	      while (POINTER_TYPE_P (ptr_type))
2827
		 of &var is enough to cause ptr to point to var.
2820
		{
2828
		 If ptr on the other side points to some type among
2821
		  /* Strip the *s off.  */ 
2829
		 struct A's fields (fields of fields etc.), then
2822
		  ptr_type = TREE_TYPE (ptr_type);
2830
		 ipa_type_escape_field_does_not_clobber_p should
2823
		  ptr_star_count++;
2831
		 be used.  E.g.
2824
		}
2832
		 struct A { int a; float f; } var;
2825
	  
2833
		 float *ptr;  */
2826
	      /* There does not appear to be a better test to see if
2834
	      if (TYPE_MAIN_VARIANT (var_type)
2827
		 the pointer type was one of the pointer to everything
2835
		  != TYPE_MAIN_VARIANT (pointed_type))
2828
		 types.  */
2829
	      if (ptr_star_count > 0)
2830
		{
2836
		{
2831
		  alias_stats.structnoaddress_queries++;
2837
		  alias_stats.structnoaddress_queries++;
2832
		  if (ipa_type_escape_field_does_not_clobber_p (var_type, 
2838
		  if (ipa_type_escape_field_does_not_clobber_p (var_type, 
2833
								TREE_TYPE (ptr)))
2839
								pointed_type))
2834
		    {
2840
		    {
2835
		      alias_stats.structnoaddress_resolved++;
2841
		      alias_stats.structnoaddress_resolved++;
2836
		      alias_stats.alias_noalias++;
2842
		      alias_stats.alias_noalias++;
2837
		      return false;
2843
		      return false;
2838
		    }
2844
		    }
2839
		}
2845
		}
2840
	      else if (ptr_star_count == 0)
2841
		{
2842
		  /* If PTR_TYPE was not really a pointer to type, it cannot 
2843
		     alias.  */ 
2844
		  alias_stats.structnoaddress_queries++;
2845
		  alias_stats.structnoaddress_resolved++;
2846
		  alias_stats.alias_noalias++;
2847
		  return false;
2848
		}
2849
	    }
2846
	    }
2850
	}
2847
	}
2851
    }
2848
    }
(-)gcc/ipa-type-escape.c.jj (+15 lines)
Lines 1704-1709 analyze_function (struct cgraph_node *fn Link Here
1704
    FOR_EACH_BB_FN (this_block, this_cfun)
1704
    FOR_EACH_BB_FN (this_block, this_cfun)
1705
      {
1705
      {
1706
	block_stmt_iterator bsi;
1706
	block_stmt_iterator bsi;
1707
	tree phi, op;
1708
	use_operand_p use;
1709
	ssa_op_iter iter;
1710
1711
	/* Find the addresses taken in phi node arguments.  */
1712
	for (phi = phi_nodes (this_block); phi; phi = PHI_CHAIN (phi))
1713
	  {
1714
	    FOR_EACH_PHI_ARG (use, phi, iter, SSA_OP_USE)
1715
	      {
1716
		op = USE_FROM_PTR (use);
1717
		if (TREE_CODE (op) == ADDR_EXPR)
1718
		  check_rhs_var (op);
1719
	      }
1720
	  }
1721
1707
	for (bsi = bsi_start (this_block); !bsi_end_p (bsi); bsi_next (&bsi))
1722
	for (bsi = bsi_start (this_block); !bsi_end_p (bsi); bsi_next (&bsi))
1708
	  walk_tree (bsi_stmt_ptr (bsi), scan_for_refs, 
1723
	  walk_tree (bsi_stmt_ptr (bsi), scan_for_refs, 
1709
		     fn, visited_nodes);
1724
		     fn, visited_nodes);
(-)gcc/testsuite/gcc.c-torture/execute/20070824-1.c.jj (+24 lines)
Line 0 Link Here
1
/* PR tree-optimization/33136 */
2
3
extern void abort (void);
4
5
struct S
6
{
7
  struct S *a;
8
  int b;
9
};
10
11
int
12
main (void)
13
{
14
  struct S *s = (struct S *) 0, **p, *n;
15
  for (p = &s; *p; p = &(*p)->a);
16
  n = (struct S *) __builtin_alloca (sizeof (*n));
17
  n->a = *p;
18
  n->b = 1;
19
  *p = n;
20
21
  if (!s)
22
    abort ();
23
  return 0;
24
}

Return to bug 33136