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][alias-improvements] Make is_dereferenced private


Keeping is_dereferenced in the SSA_NAME_PTR_INFO struct is not necessary
(and this information can become stale anyway).  Thus the following
patch makes it local to tree-ssa-structalias.c.

This makes followup patches that delay pruning easier and not touch
all the testcases as this one.

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

Richard.

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

	* tree-flow.h (struct ptr_info_def): Remove is_dereferenced member.
	* tree-ssa-alias.c (dump_points_to_info_for): Do not dump it.
	* tree-ssa-structalias.c (find_what_var_points_to): Adjust
	comment.  Take is_dereferenced parameter.
	(compute_points_to_sets): Compute whether a ptr is dereferenced
	in a local sbitmap.

	* gcc.dg/torture/pr39074-2.c: Adjust.
	* gcc.dg/torture/pta-callused-1.c: Likewise.
	* gcc.dg/torture/pta-ptrarith-3.c: Likewise.
	* gcc.dg/torture/pta-structcopy-1.c: Likewise.
	* gcc.dg/torture/ssa-pta-fn-1.c: Likewise.
	* gcc.dg/tree-ssa/alias-19.c: Likewise.
	* gcc.dg/tree-ssa/pta-ptrarith-1.c: Likewise.
	* gcc.dg/tree-ssa/pta-ptrarith-2.c: Likewise.
	* gcc.dg/torture/pr39074.c: Likewise.

Index: alias-improvements/gcc/tree-flow.h
===================================================================
*** alias-improvements.orig/gcc/tree-flow.h	2009-03-23 11:35:24.000000000 +0100
--- alias-improvements/gcc/tree-flow.h	2009-03-23 11:39:44.000000000 +0100
*************** typedef struct
*** 126,134 ****
  /* Aliasing information for SSA_NAMEs representing pointer variables.  */
  struct ptr_info_def GTY(())
  {
-   /* 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;
  };
--- 126,131 ----
Index: alias-improvements/gcc/tree-ssa-alias.c
===================================================================
*** alias-improvements.orig/gcc/tree-ssa-alias.c	2009-03-23 11:35:24.000000000 +0100
--- alias-improvements/gcc/tree-ssa-alias.c	2009-03-23 11:42:01.000000000 +0100
*************** dump_points_to_info_for (FILE *file, tre
*** 385,393 ****
  
    if (pi)
      {
-       if (pi->is_dereferenced)
- 	fprintf (file, ", is dereferenced");
- 
        if (pi->pt.anything)
  	fprintf (file, ", points-to anything");
  
--- 385,390 ----
Index: alias-improvements/gcc/tree-ssa-structalias.c
===================================================================
*** alias-improvements.orig/gcc/tree-ssa-structalias.c	2009-03-23 11:36:52.000000000 +0100
--- alias-improvements/gcc/tree-ssa-structalias.c	2009-03-23 11:51:34.000000000 +0100
*************** find_what_var_points_to (varinfo_t vi, s
*** 4839,4857 ****
    return pruned;
  }
  
! /* Given a pointer variable P, fill in its points-to set, or return
!    false if we can't.
!    Rather than return false for variables that point-to anything, we
!    instead find the corresponding SMT, and merge in its aliases.  In
!    addition to these aliases, we also set the bits for the SMT's
!    themselves and their subsets, as SMT's are still in use by
!    non-SSA_NAME's, and pruning may eliminate every one of their
!    aliases.  In such a case, if we did not include the right set of
!    SMT's in the points-to set of the variable, we'd end up with
!    statements that do not conflict but should.  */
  
  static void
! find_what_p_points_to (tree p)
  {
    struct ptr_info_def *pi;
    unsigned int pruned;
--- 4839,4849 ----
    return pruned;
  }
  
! /* Given a pointer variable P, fill in its points-to set.  Apply
!    type-based pruning if IS_DEREFERENCED is true.  */
  
  static void
! find_what_p_points_to (tree p, bool is_dereferenced)
  {
    struct ptr_info_def *pi;
    unsigned int pruned;
*************** find_what_p_points_to (tree p)
*** 4870,4881 ****
      return;
  
    pi = get_ptr_info (p);
!   pruned = find_what_var_points_to (vi, &pi->pt, pi->is_dereferenced);
  
    if (!(pi->pt.anything || pi->pt.nonlocal || pi->pt.escaped)
        && bitmap_empty_p (pi->pt.vars)
        && pruned > 0
!       && pi->is_dereferenced
        && warn_strict_aliasing > 0
        && !SSA_NAME_IS_DEFAULT_DEF (p))
      {
--- 4862,4873 ----
      return;
  
    pi = get_ptr_info (p);
!   pruned = find_what_var_points_to (vi, &pi->pt, is_dereferenced);
  
    if (!(pi->pt.anything || pi->pt.nonlocal || pi->pt.escaped)
        && bitmap_empty_p (pi->pt.vars)
        && pruned > 0
!       && is_dereferenced
        && warn_strict_aliasing > 0
        && !SSA_NAME_IS_DEFAULT_DEF (p))
      {
*************** compute_points_to_sets (void)
*** 5527,5532 ****
--- 5519,5525 ----
    struct scc_info *si;
    basic_block bb;
    unsigned i;
+   sbitmap dereferenced_ptrs;
  
    timevar_push (TV_TREE_PTA);
  
*************** compute_points_to_sets (void)
*** 5535,5551 ****
  
    intra_create_variable_infos ();
  
!   /* Reset the is_dereferenced flag for all SSA_NAME pointers as we
!      re-compute that in the following.  In theory this information
!      never becomes incorrect semantically, but better play safe.  */
!   for (i = 1; i < num_ssa_names; i++)
!     {
!       tree name = ssa_name (i);
!       if (name
! 	  && POINTER_TYPE_P (TREE_TYPE (name))
! 	  && SSA_NAME_PTR_INFO (name))
! 	SSA_NAME_PTR_INFO (name)->is_dereferenced = 0;
!     }
  
    /* Now walk all statements and derive aliases.  */
    FOR_EACH_BB (bb)
--- 5528,5537 ----
  
    intra_create_variable_infos ();
  
!   /* A bitmap of SSA_NAME pointers that are dereferenced.  This is
!      used to track which points-to sets may be TBAA pruned.  */
!   dereferenced_ptrs = sbitmap_alloc (num_ssa_names);
!   sbitmap_zero (dereferenced_ptrs);
  
    /* Now walk all statements and derive aliases.  */
    FOR_EACH_BB (bb)
*************** compute_points_to_sets (void)
*** 5571,5589 ****
  	  FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
  	    {
  	      unsigned num_uses, num_loads, num_stores;
- 	      struct ptr_info_def *pi;
  	      tree op = USE_FROM_PTR (use_p);
  
  	      if (!POINTER_TYPE_P (TREE_TYPE (op)))
  		continue;
  
- 	      pi = get_ptr_info (op);
- 
  	      /* Determine whether OP is a dereferenced pointer.  */
  	      count_uses_and_derefs (op, stmt,
  				     &num_uses, &num_loads, &num_stores);
  	      if (num_loads + num_stores > 0)
! 		pi->is_dereferenced = 1;
  	    }
  
  	  find_func_aliases (stmt);
--- 5557,5572 ----
  	  FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
  	    {
  	      unsigned num_uses, num_loads, num_stores;
  	      tree op = USE_FROM_PTR (use_p);
  
  	      if (!POINTER_TYPE_P (TREE_TYPE (op)))
  		continue;
  
  	      /* Determine whether OP is a dereferenced pointer.  */
  	      count_uses_and_derefs (op, stmt,
  				     &num_uses, &num_loads, &num_stores);
  	      if (num_loads + num_stores > 0)
! 		SET_BIT (dereferenced_ptrs, SSA_NAME_VERSION (op));
  	    }
  
  	  find_func_aliases (stmt);
*************** compute_points_to_sets (void)
*** 5649,5663 ****
    if (dump_file)
      dump_sa_points_to_info (dump_file);
  
-   /* Compute the points-to sets for pointer SSA_NAMEs.  */
-   for (i = 0; i < num_ssa_names; ++i)
-     {
-       tree ptr = ssa_name (i);
-       if (ptr
- 	  && POINTER_TYPE_P (TREE_TYPE (ptr)))
- 	find_what_p_points_to (ptr);
-     }
- 
    /* Compute the points-to sets for ESCAPED and CALLUSED used for
       call-clobber analysis.  */
    find_what_var_points_to (var_escaped, &cfun->gimple_df->escaped, false);
--- 5632,5637 ----
*************** compute_points_to_sets (void)
*** 5668,5673 ****
--- 5642,5658 ----
       points-to solution queries.  */
    cfun->gimple_df->escaped.escaped = 0;
  
+   /* Compute the points-to sets for pointer SSA_NAMEs.  */
+   for (i = 0; i < num_ssa_names; ++i)
+     {
+       tree ptr = ssa_name (i);
+       if (ptr
+ 	  && POINTER_TYPE_P (TREE_TYPE (ptr)))
+ 	find_what_p_points_to (ptr, TEST_BIT (dereferenced_ptrs,
+ 					      SSA_NAME_VERSION (ptr)));
+     }
+   sbitmap_free (dereferenced_ptrs);
+ 
    timevar_pop (TV_TREE_PTA);
  
    have_alias_info = true;
Index: alias-improvements/gcc/testsuite/gcc.dg/torture/pr39074-2.c
===================================================================
*** alias-improvements.orig/gcc/testsuite/gcc.dg/torture/pr39074-2.c	2009-02-06 10:11:48.000000000 +0100
--- alias-improvements/gcc/testsuite/gcc.dg/torture/pr39074-2.c	2009-03-23 12:01:41.000000000 +0100
*************** int main()
*** 30,34 ****
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "y.._., is dereferenced, points-to vars: { i }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
--- 30,34 ----
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "y.._., points-to vars: { i }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
Index: alias-improvements/gcc/testsuite/gcc.dg/torture/pta-callused-1.c
===================================================================
*** alias-improvements.orig/gcc/testsuite/gcc.dg/torture/pta-callused-1.c	2009-02-04 15:36:58.000000000 +0100
--- alias-improvements/gcc/testsuite/gcc.dg/torture/pta-callused-1.c	2009-03-23 12:01:35.000000000 +0100
*************** int main()
*** 21,25 ****
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "p.._., is dereferenced, points-to vars: { i j }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
--- 21,25 ----
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "p.._., points-to vars: { i j }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
Index: alias-improvements/gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c
===================================================================
*** alias-improvements.orig/gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c	2009-02-03 11:18:28.000000000 +0100
--- alias-improvements/gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c	2009-03-23 12:01:29.000000000 +0100
*************** int main()
*** 33,37 ****
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "q_., is dereferenced, points-to vars: { i j k }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
--- 33,37 ----
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "q_., points-to vars: { i j k }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
Index: alias-improvements/gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c
===================================================================
*** alias-improvements.orig/gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c	2009-02-25 14:08:03.000000000 +0100
--- alias-improvements/gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c	2009-03-23 12:01:48.000000000 +0100
*************** int main()
*** 30,34 ****
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "is dereferenced, points-to vars: { i }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
--- 30,34 ----
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "points-to vars: { i }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
Index: alias-improvements/gcc/testsuite/gcc.dg/torture/ssa-pta-fn-1.c
===================================================================
*** alias-improvements.orig/gcc/testsuite/gcc.dg/torture/ssa-pta-fn-1.c	2009-02-04 15:36:58.000000000 +0100
--- alias-improvements/gcc/testsuite/gcc.dg/torture/ssa-pta-fn-1.c	2009-03-23 12:01:24.000000000 +0100
*************** int main()
*** 55,61 ****
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "q_const_., is dereferenced, points-to non-local, points-to vars: { i }" "alias" } } */
! /* { dg-final { scan-tree-dump "q_pure_., is dereferenced, points-to non-local, points-to escaped, points-to vars: { i }" "alias" } } */
! /* { dg-final { scan-tree-dump "q_normal_., is dereferenced, points-to non-local, points-to escaped, points-to vars: { }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
--- 55,61 ----
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "q_const_., points-to non-local, points-to vars: { i }" "alias" } } */
! /* { dg-final { scan-tree-dump "q_pure_., points-to non-local, points-to escaped, points-to vars: { i }" "alias" } } */
! /* { dg-final { scan-tree-dump "q_normal_., points-to non-local, points-to escaped, points-to vars: { }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
Index: alias-improvements/gcc/testsuite/gcc.dg/tree-ssa/alias-19.c
===================================================================
*** alias-improvements.orig/gcc/testsuite/gcc.dg/tree-ssa/alias-19.c	2009-01-07 11:56:32.000000000 +0100
--- alias-improvements/gcc/testsuite/gcc.dg/tree-ssa/alias-19.c	2009-03-23 11:59:10.000000000 +0100
*************** int main()
*** 26,30 ****
  }
  
  /* { dg-final { scan-tree-dump "q_. = { a b }" "alias" } } */
! /* { dg-final { scan-tree-dump "q_., is dereferenced, points-to vars: { a b }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
--- 26,30 ----
  }
  
  /* { dg-final { scan-tree-dump "q_. = { a b }" "alias" } } */
! /* { dg-final { scan-tree-dump "q_., points-to vars: { a b }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
Index: alias-improvements/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-1.c
===================================================================
*** alias-improvements.orig/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-1.c	2009-02-03 11:18:28.000000000 +0100
--- alias-improvements/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-1.c	2009-03-23 11:59:18.000000000 +0100
*************** foo(int i, int j, int k, int off)
*** 22,26 ****
    return *q;
  }
  
! /* { dg-final { scan-tree-dump "q_., is dereferenced, points-to vars: { k }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
--- 22,26 ----
    return *q;
  }
  
! /* { dg-final { scan-tree-dump "q_., points-to vars: { k }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
Index: alias-improvements/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-2.c
===================================================================
*** alias-improvements.orig/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-2.c	2009-02-03 11:18:28.000000000 +0100
--- alias-improvements/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-2.c	2009-03-23 11:59:26.000000000 +0100
*************** foo(int i, int j, int k, int off)
*** 22,26 ****
    return *q;
  }
  
! /* { dg-final { scan-tree-dump "q_., is dereferenced, points-to vars: { i }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
--- 22,26 ----
    return *q;
  }
  
! /* { dg-final { scan-tree-dump "q_., points-to vars: { i }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
Index: alias-improvements/gcc/testsuite/gcc.dg/torture/pr39074.c
===================================================================
*** alias-improvements.orig/gcc/testsuite/gcc.dg/torture/pr39074.c	2009-02-06 10:11:48.000000000 +0100
--- alias-improvements/gcc/testsuite/gcc.dg/torture/pr39074.c	2009-03-23 12:16:45.000000000 +0100
*************** int main()
*** 27,31 ****
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "y.._., is dereferenced, points-to vars: { i }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */
--- 27,31 ----
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "y.._., points-to vars: { i }" "alias" } } */
  /* { dg-final { cleanup-tree-dump "alias" } } */


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