public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][alias-improvements] PTA oracle cleanups
@ 2009-03-19 13:14 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2009-03-19 13:14 UTC (permalink / raw)
  To: gcc-patches


This is the first patch to work into the direction of separating oracle
interfaces for queries (not) including TBAA results.  Simply some 
renaming, all existing queries use TBAA if enabled.

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

Richard.

2009-03-19  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-alias.c (may_point_to_global_var): Rename to ...
	(ptr_deref_may_alias_global_p): ... this.
	(may_point_to_decl): Rename to ...
	(ptr_deref_may_alias_decl_p): ... this.
	(may_point_to_same_object): Rename to ...
	(ptr_derefs_may_alias_p): ... this.
	(refs_may_alias_p_1): Adjust.
	* tree-ssa-alias.h (may_point_to_global_var): Rename to ...
	(ptr_deref_may_alias_global_p): ... this.
	* tree-ssa-sink.c (is_hidden_global_store): Adjust.
	* tree-flow.h (struct ptr_info_def): Adjust comment.
	* tree-ssa-structalias.c (pt_solution_empty_p): Simplify.
	(pt_solution_includes_global): Likewise.
	(pt_solution_includes_1): Likewise.
	(pt_solutions_intersect_1): Likewise.
	(compute_points_to_sets): Clear ESCAPED in ESCAPED solution.

Index: gcc/tree-ssa-alias.c
===================================================================
*** gcc/tree-ssa-alias.c.orig	2009-03-19 12:27:54.000000000 +0100
--- gcc/tree-ssa-alias.c	2009-03-19 14:06:24.000000000 +0100
*************** along with GCC; see the file COPYING3.
*** 90,99 ****
  
       This function tries to disambiguate two reference trees.
  
!    bool may_point_to_global_var (tree)
  
!      This function queries if a pointer variable may point to global
!      memory.
  
     More low-level disambiguators are available and documented in
     this file.  Low-level disambiguators dealing with points-to
--- 90,99 ----
  
       This function tries to disambiguate two reference trees.
  
!    bool ptr_deref_may_alias_global_p (tree)
  
!      This function queries if dereferencing a pointer variable may
!      alias global memory.
  
     More low-level disambiguators are available and documented in
     this file.  Low-level disambiguators dealing with points-to
*************** dump_alias_stats (FILE *s)
*** 137,146 ****
  }
  
  
! /* Return true, if PTR may point to a global variable.  */
  
  bool
! may_point_to_global_var (tree ptr)
  {
    struct ptr_info_def *pi;
  
--- 137,146 ----
  }
  
  
! /* Return true, if dereferencing PTR may alias with a global variable.  */
  
  bool
! ptr_deref_may_alias_global_p (tree ptr)
  {
    struct ptr_info_def *pi;
  
*************** may_point_to_global_var (tree ptr)
*** 159,168 ****
    return pt_solution_includes_global (&pi->pt);
  }
  
! /* Return true if PTR may point to DECL.  */
  
  static bool
! may_point_to_decl (tree ptr, tree decl)
  {
    struct ptr_info_def *pi;
  
--- 159,168 ----
    return pt_solution_includes_global (&pi->pt);
  }
  
! /* Return true if dereferencing PTR may alias DECL.  */
  
  static bool
! ptr_deref_may_alias_decl_p (tree ptr, tree decl)
  {
    struct ptr_info_def *pi;
  
*************** may_point_to_decl (tree ptr, tree decl)
*** 191,200 ****
    return pt_solution_includes (&pi->pt, decl);
  }
  
! /* Return true if PTR1 and PTR2 may point to the same memory object.  */
  
  static bool
! may_point_to_same_object (tree ptr1, tree ptr2)
  {
    struct ptr_info_def *pi1, *pi2;
  
--- 191,200 ----
    return pt_solution_includes (&pi->pt, decl);
  }
  
! /* Return true if dereferenced PTR1 and PTR2 may alias.  */
  
  static bool
! ptr_derefs_may_alias_p (tree ptr1, tree ptr2)
  {
    struct ptr_info_def *pi1, *pi2;
  
*************** refs_may_alias_p_1 (tree ref1, tree ref2
*** 511,517 ****
        if (max_size1 != -1
  	  && !ranges_overlap_p (0, offset1 + max_size1, offset2, max_size2))
  	return false;
!       if (!may_point_to_decl (TREE_OPERAND (base2, 0), base1))
  	return false;
      }
    else if (SSA_VAR_P (base2)
--- 511,517 ----
        if (max_size1 != -1
  	  && !ranges_overlap_p (0, offset1 + max_size1, offset2, max_size2))
  	return false;
!       if (!ptr_deref_may_alias_decl_p (TREE_OPERAND (base2, 0), base1))
  	return false;
      }
    else if (SSA_VAR_P (base2)
*************** refs_may_alias_p_1 (tree ref1, tree ref2
*** 520,526 ****
        if (max_size2 != -1
  	  && !ranges_overlap_p (offset1, max_size1, 0, offset2 + max_size2))
  	return false;
!       if (!may_point_to_decl (TREE_OPERAND (base1, 0), base2))
  	return false;
      }
  
--- 520,526 ----
        if (max_size2 != -1
  	  && !ranges_overlap_p (offset1, max_size1, 0, offset2 + max_size2))
  	return false;
!       if (!ptr_deref_may_alias_decl_p (TREE_OPERAND (base1, 0), base2))
  	return false;
      }
  
*************** refs_may_alias_p_1 (tree ref1, tree ref2
*** 533,540 ****
        if (operand_equal_p (TREE_OPERAND (base1, 0),
  			   TREE_OPERAND (base2, 0), 0))
  	return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
!       if (!may_point_to_same_object (TREE_OPERAND (base1, 0),
! 				     TREE_OPERAND (base2, 0)))
  	return false;
      }
  
--- 533,540 ----
        if (operand_equal_p (TREE_OPERAND (base1, 0),
  			   TREE_OPERAND (base2, 0), 0))
  	return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
!       if (!ptr_derefs_may_alias_p (TREE_OPERAND (base1, 0),
! 				   TREE_OPERAND (base2, 0)))
  	return false;
      }
  
Index: gcc/tree-ssa-alias.h
===================================================================
*** gcc/tree-ssa-alias.h.orig	2009-03-19 12:25:46.000000000 +0100
--- gcc/tree-ssa-alias.h	2009-03-19 14:06:24.000000000 +0100
*************** struct pt_solution GTY(())
*** 76,82 ****
  
  /* In tree-ssa-alias.c  */
  extern enum escape_type is_escape_site (gimple);
! extern bool may_point_to_global_var (tree);
  extern bool refs_may_alias_p (tree, tree);
  extern bool ref_maybe_used_by_stmt_p (gimple, tree);
  extern bool stmt_may_clobber_ref_p (gimple, tree);
--- 76,82 ----
  
  /* In tree-ssa-alias.c  */
  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 ref_maybe_used_by_stmt_p (gimple, tree);
  extern bool stmt_may_clobber_ref_p (gimple, tree);
Index: gcc/tree-ssa-sink.c
===================================================================
*** gcc/tree-ssa-sink.c.orig	2009-03-19 12:25:46.000000000 +0100
--- gcc/tree-ssa-sink.c	2009-03-19 12:28:11.000000000 +0100
*************** is_hidden_global_store (gimple stmt)
*** 191,197 ****
  
  	}
        else if (INDIRECT_REF_P (lhs))
! 	return may_point_to_global_var (TREE_OPERAND (lhs, 0));
        else
  	gcc_unreachable ();
      }
--- 191,197 ----
  
  	}
        else if (INDIRECT_REF_P (lhs))
! 	return ptr_deref_may_alias_global_p (TREE_OPERAND (lhs, 0));
        else
  	gcc_unreachable ();
      }
Index: gcc/tree-flow.h
===================================================================
*** gcc/tree-flow.h.orig	2009-03-19 12:27:54.000000000 +0100
--- gcc/tree-flow.h	2009-03-19 14:06:24.000000000 +0100
*************** struct ptr_info_def GTY(())
*** 129,135 ****
    /* Nonzero if this pointer is really dereferenced.  */
    unsigned int is_dereferenced : 1;
  
!   /* The points-to solution.  */
    struct pt_solution pt;
  };
  
--- 129,135 ----
    /* Nonzero if this pointer is really dereferenced.  */
    unsigned int is_dereferenced : 1;
  
!   /* The points-to solution, TBAA-pruned if the pointer is dereferenced.  */
    struct pt_solution pt;
  };
  
Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c.orig	2009-03-19 12:27:59.000000000 +0100
--- gcc/tree-ssa-structalias.c	2009-03-19 14:07:15.000000000 +0100
*************** pt_solution_empty_p (struct pt_solution
*** 4981,4989 ****
        && !bitmap_empty_p (pt->vars))
      return false;
  
!   /* If this isn't already the escaped solution, check if that is empty.  */
    if (pt->escaped
-       && &cfun->gimple_df->escaped != pt
        && !pt_solution_empty_p (&cfun->gimple_df->escaped))
      return false;
  
--- 4981,4988 ----
        && !bitmap_empty_p (pt->vars))
      return false;
  
!   /* If the solution includes ESCAPED, check if that is empty.  */
    if (pt->escaped
        && !pt_solution_empty_p (&cfun->gimple_df->escaped))
      return false;
  
*************** pt_solution_includes_global (struct pt_s
*** 5000,5007 ****
        || pt->vars_contains_global)
      return true;
  
!   if (pt->escaped
!       && pt != &cfun->gimple_df->escaped)
      return pt_solution_includes_global (&cfun->gimple_df->escaped);
  
    return false;
--- 4999,5005 ----
        || pt->vars_contains_global)
      return true;
  
!   if (pt->escaped)
      return pt_solution_includes_global (&cfun->gimple_df->escaped);
  
    return false;
*************** pt_solution_includes_1 (struct pt_soluti
*** 5020,5031 ****
        && is_global_var (decl))
      return true;
  
!   if (bitmap_bit_p (pt->vars, DECL_UID (decl)))
      return true;
  
!   /* If this isn't already the escaped solution, union it with that.  */
    if (pt->escaped
-       && &cfun->gimple_df->escaped != pt
        && pt_solution_includes_1 (&cfun->gimple_df->escaped, decl))
      return true;
  
--- 5018,5029 ----
        && is_global_var (decl))
      return true;
  
!   if (pt->vars
!       && bitmap_bit_p (pt->vars, DECL_UID (decl)))
      return true;
  
!   /* If the solution includes ESCAPED, check it.  */
    if (pt->escaped
        && pt_solution_includes_1 (&cfun->gimple_df->escaped, decl))
      return true;
  
*************** pt_solutions_intersect_1 (struct pt_solu
*** 5062,5083 ****
      return true;
  
    /* Check the escaped solution if required.  */
!   if ((pt1->escaped || pt1 == &cfun->gimple_df->escaped
!        || pt2->escaped || pt2 == &cfun->gimple_df->escaped)
        && !pt_solution_empty_p (&cfun->gimple_df->escaped))
      {
        /* If both point to escaped memory and that solution
  	 is not empty they alias.  */
!       if ((pt1->escaped || pt1 == &cfun->gimple_df->escaped)
! 	  && (pt2->escaped || pt2 == &cfun->gimple_df->escaped))
  	return true;
  
        /* If either points to escaped memory see if the escaped solution
! 	 intersects.  */
!       if (((pt1->escaped || pt1 == &cfun->gimple_df->escaped)
! 	   && pt_solutions_intersect_1 (&cfun->gimple_df->escaped, pt1))
! 	  || ((pt2->escaped || pt2 == &cfun->gimple_df->escaped)
! 	      && pt_solutions_intersect_1 (&cfun->gimple_df->escaped, pt2)))
  	return true;
      }
  
--- 5060,5079 ----
      return true;
  
    /* Check the escaped solution if required.  */
!   if ((pt1->escaped || pt2->escaped)
        && !pt_solution_empty_p (&cfun->gimple_df->escaped))
      {
        /* If both point to escaped memory and that solution
  	 is not empty they alias.  */
!       if (pt1->escaped && pt2->escaped)
  	return true;
  
        /* If either points to escaped memory see if the escaped solution
! 	 intersects with the other.  */
!       if ((pt1->escaped
! 	   && pt_solutions_intersect_1 (&cfun->gimple_df->escaped, pt2))
! 	  || (pt2->escaped
! 	      && pt_solutions_intersect_1 (&cfun->gimple_df->escaped, pt1)))
  	return true;
      }
  
*************** compute_points_to_sets (void)
*** 5707,5712 ****
--- 5703,5713 ----
    find_what_var_points_to (var_escaped, &cfun->gimple_df->escaped, false);
    find_what_var_points_to (var_callused, &cfun->gimple_df->callused, false);
  
+   /* Make sure the ESCAPED solution (which is used as placeholder in
+      other solutions) does not reference itself.  This simplifies
+      points-to solution queries.  */
+   cfun->gimple_df->escaped.escaped = 0;
+ 
    timevar_pop (TV_TREE_PTA);
  
    have_alias_info = true;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-19 13:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-19 13:14 [PATCH][alias-improvements] PTA oracle cleanups Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).