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] Avoid escaping to non-pointer objects in PTA


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2010-04-21  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-structalias.c (do_ds_constraint): Avoid escaping
	to non-pointer objects.

	* gcc.dg/ipa/ipa-pta-11.c: Adjust.

Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c.orig	2010-04-20 15:55:42.000000000 +0200
--- gcc/tree-ssa-structalias.c	2010-04-21 11:32:31.000000000 +0200
*************** do_ds_constraint (constraint_t c, bitmap
*** 1746,1751 ****
--- 1746,1752 ----
    unsigned int j;
    bitmap_iterator bi;
    HOST_WIDE_INT loff = c->lhs.offset;
+   bool escaped_p = false;
  
    /* Our IL does not allow this.  */
    gcc_assert (c->rhs.offset == 0);
*************** do_ds_constraint (constraint_t c, bitmap
*** 1792,1813 ****
        unsigned int t;
        HOST_WIDE_INT fieldoffset = v->offset + loff;
  
-       /* If v is a global variable then this is an escape point.  */
-       if (v->is_global_var)
- 	{
- 	  t = find (escaped_id);
- 	  if (add_graph_edge (graph, t, rhs)
- 	      && bitmap_ior_into (get_varinfo (t)->solution, sol)
- 	      && !TEST_BIT (changed, t))
- 	    {
- 	      SET_BIT (changed, t);
- 	      changed_count++;
- 	    }
- 	}
- 
-       if (v->is_special_var)
- 	continue;
- 
        if (v->is_full_var)
  	fieldoffset = v->offset;
        else if (loff != 0)
--- 1793,1798 ----
*************** do_ds_constraint (constraint_t c, bitmap
*** 1820,1825 ****
--- 1805,1829 ----
  	{
  	  if (v->may_have_pointers)
  	    {
+ 	      /* If v is a global variable then this is an escape point.  */
+ 	      if (v->is_global_var
+ 		  && !escaped_p)
+ 		{
+ 		  t = find (escaped_id);
+ 		  if (add_graph_edge (graph, t, rhs)
+ 		      && bitmap_ior_into (get_varinfo (t)->solution, sol)
+ 		      && !TEST_BIT (changed, t))
+ 		    {
+ 		      SET_BIT (changed, t);
+ 		      changed_count++;
+ 		    }
+ 		  /* Enough to let rhs escape once.  */
+ 		  escaped_p = true;
+ 		}
+ 
+ 	      if (v->is_special_var)
+ 		break;
+ 
  	      t = find (v->id);
  	      if (add_graph_edge (graph, t, rhs)
  		  && bitmap_ior_into (get_varinfo (t)->solution, sol)
Index: gcc/testsuite/gcc.dg/ipa/ipa-pta-11.c
===================================================================
*** gcc/testsuite/gcc.dg/ipa/ipa-pta-11.c.orig	2010-04-15 15:14:05.000000000 +0200
--- gcc/testsuite/gcc.dg/ipa/ipa-pta-11.c	2010-04-21 11:33:42.000000000 +0200
*************** int main()
*** 29,33 ****
  /* It isn't clear if the escape if l is strictly necessary, if it were
     we should have i, r and s in ESCAPED as well.  */
  
! /* { dg-final { scan-ipa-dump "ESCAPED = { ESCAPED NONLOCAL l k }" "pta" } } */
  /* { dg-final { cleanup-ipa-dump "pta" } } */
--- 29,33 ----
  /* It isn't clear if the escape if l is strictly necessary, if it were
     we should have i, r and s in ESCAPED as well.  */
  
! /* { dg-final { scan-ipa-dump "ESCAPED = { l k }" "pta" } } */
  /* { dg-final { cleanup-ipa-dump "pta" } } */


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