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] Clean up after last PTA patch


The PTA patch that cleaned up the escapes through indirect writes
allows the is_escape_site helper to be removed easily.

Done so, bootstrapped and tested on x86_64-unknown-linux-gnu,
applied to trunk.

Richard.

2009-06-16  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-alias.c (is_escape_site): Remove.
	* tree-ssa-alias.h (enum escape_type): Remove.
	(is_escape_site): Likewise.
	* tree-ssa-structalias.c (find_func_aliases): Handle escapes
	via casts and asms without deferring to is_escape_site.

Index: trunk/gcc/tree-ssa-alias.c
===================================================================
*** trunk.orig/gcc/tree-ssa-alias.c	2009-06-05 10:25:18.000000000 +0200
--- trunk/gcc/tree-ssa-alias.c	2009-06-16 12:59:02.000000000 +0200
*************** ptr_derefs_may_alias_p (tree ptr1, tree
*** 232,313 ****
    return pt_solutions_intersect (&pi1->pt, &pi2->pt);
  }
  
- /* Return true if STMT is an "escape" site from the current function.  Escape
-    sites those statements which might expose the address of a variable
-    outside the current function.  STMT is an escape site iff:
- 
-    	1- STMT is a function call, or
- 	2- STMT is an __asm__ expression, or
- 	3- STMT is an assignment to a non-local variable, or
- 	4- STMT is a return statement.
- 
-    Return the type of escape site found, if we found one, or NO_ESCAPE
-    if none.  */
- 
- enum escape_type
- is_escape_site (gimple stmt)
- {
-   if (is_gimple_call (stmt))
-     {
-       if (gimple_call_flags (stmt) & (ECF_PURE | ECF_CONST))
- 	return ESCAPE_TO_PURE_CONST;
- 
-       return ESCAPE_TO_CALL;
-     }
-   else if (gimple_code (stmt) == GIMPLE_ASM)
-     return ESCAPE_TO_ASM;
-   else if (is_gimple_assign (stmt))
-     {
-       tree lhs = gimple_assign_lhs (stmt);
- 
-       /* Get to the base of _REF nodes.  */
-       if (TREE_CODE (lhs) != SSA_NAME)
- 	lhs = get_base_address (lhs);
- 
-       /* If we couldn't recognize the LHS of the assignment, assume that it
- 	 is a non-local store.  */
-       if (lhs == NULL_TREE)
- 	return ESCAPE_UNKNOWN;
- 
-       if (gimple_assign_cast_p (stmt))
- 	{
- 	  tree from = TREE_TYPE (gimple_assign_rhs1 (stmt));
- 	  tree to = TREE_TYPE (lhs);
- 
- 	  /* If the RHS is a conversion between a pointer and an integer, the
- 	     pointer escapes since we can't track the integer.  */
- 	  if (POINTER_TYPE_P (from) && !POINTER_TYPE_P (to))
- 	    return ESCAPE_BAD_CAST;
- 	}
- 
-       /* If the LHS is an SSA name, it can't possibly represent a non-local
- 	 memory store.  */
-       if (TREE_CODE (lhs) == SSA_NAME)
- 	return NO_ESCAPE;
- 
-       /* If the LHS is a non-global decl, it isn't a non-local memory store.
- 	 If the LHS escapes, the RHS escape is dealt with in the PTA solver.  */
-       if (DECL_P (lhs)
- 	  && !is_global_var (lhs))
- 	return NO_ESCAPE;
- 
-       /* FIXME: LHS is not an SSA_NAME.  Even if it's an assignment to a
- 	 local variables we cannot be sure if it will escape, because we
- 	 don't have information about objects not in SSA form.  Need to
- 	 implement something along the lines of
- 
- 	 J.-D. Choi, M. Gupta, M. J. Serrano, V. C. Sreedhar, and S. P.
- 	 Midkiff, ``Escape analysis for java,'' in Proceedings of the
- 	 Conference on Object-Oriented Programming Systems, Languages, and
- 	 Applications (OOPSLA), pp. 1-19, 1999.  */
-       return ESCAPE_STORED_IN_GLOBAL;
-     }
-   else if (gimple_code (stmt) == GIMPLE_RETURN)
-     return ESCAPE_TO_RETURN;
- 
-   return NO_ESCAPE;
- }
- 
  
  /* Dump alias information on FILE.  */
  
--- 232,237 ----
Index: trunk/gcc/tree-ssa-alias.h
===================================================================
*** trunk.orig/gcc/tree-ssa-alias.h	2009-06-04 15:57:37.000000000 +0200
--- trunk/gcc/tree-ssa-alias.h	2009-06-16 12:59:50.000000000 +0200
***************
*** 24,49 ****
  #include "coretypes.h"
  
  
- /* The reasons a variable may escape a function.  */
- enum escape_type 
- {
-   NO_ESCAPE = 0,			/* Doesn't escape.  */
-   ESCAPE_STORED_IN_GLOBAL = 1 << 0,
-   ESCAPE_TO_ASM = 1 << 1,		/* Passed by address to an assembly
- 					   statement.  */
-   ESCAPE_TO_CALL = 1 << 2,		/* Escapes to a function call.  */
-   ESCAPE_BAD_CAST = 1 << 3,		/* Cast from pointer to integer */
-   ESCAPE_TO_RETURN = 1 << 4,		/* Returned from function.  */
-   ESCAPE_TO_PURE_CONST = 1 << 5,	/* Escapes to a pure or constant
- 					   function call.  */
-   ESCAPE_IS_GLOBAL = 1 << 6,		/* Is a global variable.  */
-   ESCAPE_IS_PARM = 1 << 7,		/* Is an incoming function argument.  */
-   ESCAPE_UNKNOWN = 1 << 8		/* We believe it escapes for
- 					   some reason not enumerated
- 					   above.  */
- };
- 
- 
  /* The points-to solution.
  
     The points-to solution is a union of pt_vars and the abstract
--- 24,29 ----
*************** typedef struct ao_ref_s
*** 107,113 ****
  extern void ao_ref_init (ao_ref *, tree);
  extern tree ao_ref_base (ao_ref *);
  extern alias_set_type ao_ref_alias_set (ao_ref *);
- extern enum escape_type is_escape_site (gimple);
  extern bool ptr_deref_may_alias_global_p (tree);
  extern bool refs_may_alias_p (tree, tree);
  extern bool refs_anti_dependent_p (tree, tree);
--- 87,92 ----
Index: trunk/gcc/tree-ssa-structalias.c
===================================================================
*** trunk.orig/gcc/tree-ssa-structalias.c	2009-06-16 12:25:18.000000000 +0200
--- trunk/gcc/tree-ssa-structalias.c	2009-06-16 13:01:33.000000000 +0200
*************** find_func_aliases (gimple origt)
*** 3561,3567 ****
    VEC(ce_s, heap) *lhsc = NULL;
    VEC(ce_s, heap) *rhsc = NULL;
    struct constraint_expr *c;
-   enum escape_type stmt_escape_type;
  
    /* Now build constraints expressions.  */
    if (gimple_code (t) == GIMPLE_PHI)
--- 3561,3566 ----
*************** find_func_aliases (gimple origt)
*** 3759,3774 ****
  	  && is_global_var (lhsop))
  	make_escape_constraint (rhsop);
      }
! 
!   stmt_escape_type = is_escape_site (t);
!   if (stmt_escape_type == ESCAPE_BAD_CAST)
      {
-       gcc_assert (is_gimple_assign (t));
-       gcc_assert (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (t))
- 		  || gimple_assign_rhs_code (t) == VIEW_CONVERT_EXPR);
        make_escape_constraint (gimple_assign_rhs1 (t));
      }
!   else if (stmt_escape_type == ESCAPE_TO_ASM)
      {
        unsigned i, noutputs;
        const char **oconstraints;
--- 3758,3772 ----
  	  && is_global_var (lhsop))
  	make_escape_constraint (rhsop);
      }
!   /* For conversions of pointers to non-pointers the pointer escapes.  */
!   else if (gimple_assign_cast_p (t)
! 	   && POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (t)))
! 	   && !POINTER_TYPE_P (TREE_TYPE (gimple_assign_lhs (t))))
      {
        make_escape_constraint (gimple_assign_rhs1 (t));
      }
!   /* Handle asms conservatively by adding escape constraints to everything.  */
!   else if (gimple_code (t) == GIMPLE_ASM)
      {
        unsigned i, noutputs;
        const char **oconstraints;


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