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]

Re: [PATCH] Fix PTA with lots of SFTs


On Wed, 14 Nov 2007, Richard Guenther wrote:

> On Wed, 14 Nov 2007, Daniel Berlin wrote:
> 
> > On 11/14/07, Richard Guenther <rguenther@suse.de> wrote:
> > >
> > > The difference is ultimatively because points-to and operand scanning
> > > disagree about whether they did field-sensitive analysis.
> > >
> > 
> > When PTA doesn't do field sensitive analysis, it should have chosen to
> > say the entire variable is pointed-to, because that is all it creates
> > in the way of variable info.
> > 
> > This should end up translating into all the SFT's in set_uids_in_ptset.
> > 
> > That this is not happening is going to cause bugs elsewhere (in
> > particular, when we collapse C++ variables because of weird front end
> > issues), and your fix won't fix those.
> > 
> > Hmmm.
> > I see what is happening.
> > 
> > This is a bug in set_uids_in_ptset. It's not taking into account that
> > their may be more than one sft per var when
> > MAX_FIELDS_FOR_FIELD_SENSITIVE is hit. It assumes if the variable has
> > subvars, that we built separate vars for it (same problem you
> > mentioned, different place).
> > 
> > I think the right way to fix this is to take into account the size of
> > the varinfo here:
> > 
> >   if (var_can_have_subvars (vi->decl)
> >               && get_subvars_for_var (vi->decl))
> >             {
> >               /* If VI->DECL is an aggregate for which we created
> >                  SFTs, add the SFT corresponding to VI->OFFSET.  */
> >               tree sft = get_subvar_at (vi->decl, vi->offset);
> > 
> > 
> > and make it into a loop so it gets all the subvars until it hits the
> > size of the variable.
> 
> Yes, I think that makes sense.  Though it probably also makes sense
> to limit the number of SFTs we create for structures, so I'll check the
> above on top of this patch.  (otherwise in case we didn't do 
> field-sensitive analysis but created SFTs we'd always create large 
> points-to sets)

This is what I'll apply shortly.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2007-11-15  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-alias.c (create_overlap_variables_for): Make sure
	to only create SFTs if we also create variable infos for PTA.
	* tree-ssa-structalias.c (set_uids_in_ptset): Add all overlapping
	SFTs.

Index: tree-ssa-alias.c
===================================================================
*** tree-ssa-alias.c	(revision 130174)
--- tree-ssa-alias.c	(working copy)
*************** create_overlap_variables_for (tree var)
*** 3833,3840 ****
      return;
  
    push_fields_onto_fieldstack (TREE_TYPE (var), &fieldstack, 0, NULL,
! 			       TREE_TYPE (var), 0);
!   if (VEC_length (fieldoff_s, fieldstack) != 0)
      {
        subvar_t *subvars;
        fieldoff_s *fo;
--- 3834,3844 ----
      return;
  
    push_fields_onto_fieldstack (TREE_TYPE (var), &fieldstack, 0, NULL,
! 			       TREE_TYPE (var), 0);
!   /* Make sure to not create SFTs for structs we won't generate variable
!      infos for.  See tree-ssa-structalias.c:create_variable_info_for ().  */
!   if (VEC_length (fieldoff_s, fieldstack) != 0
!       && VEC_length (fieldoff_s, fieldstack) <= MAX_FIELDS_FOR_FIELD_SENSITIVE)
      {
        subvar_t *subvars;
        fieldoff_s *fo;

Index: tree-ssa-structalias.c
===================================================================
*** tree-ssa-structalias.c	(revision 130195)
--- tree-ssa-structalias.c	(working copy)
*************** set_uids_in_ptset (tree ptr, bitmap into
*** 4749,4763 ****
  	       || TREE_CODE (vi->decl) == PARM_DECL
  	       || TREE_CODE (vi->decl) == RESULT_DECL)
  	{
  	  if (var_can_have_subvars (vi->decl)
! 	      && get_subvars_for_var (vi->decl))
  	    {
  	      /* If VI->DECL is an aggregate for which we created
! 		 SFTs, add the SFT corresponding to VI->OFFSET.  */
! 	      tree sft = get_subvar_at (vi->decl, vi->offset);
  	      gcc_assert (sft);
! 	      if (sft)
  		{
  		  var_alias_set = get_alias_set (sft);
  		  if (no_tbaa_pruning
  		      || (!is_derefed && !vi->directly_dereferenced)
--- 4749,4772 ----
  	       || TREE_CODE (vi->decl) == PARM_DECL
  	       || TREE_CODE (vi->decl) == RESULT_DECL)
  	{
+ 	  subvar_t sv;
  	  if (var_can_have_subvars (vi->decl)
! 	      && (sv = get_subvars_for_var (vi->decl)))
  	    {
  	      /* If VI->DECL is an aggregate for which we created
! 		 SFTs, add the SFT corresponding to VI->OFFSET.
! 		 If we didn't do field-sensitive PTA we need to to
! 		 add all overlapping SFTs.  */
! 	      unsigned int j;
! 	      tree sft = get_first_overlapping_subvar (sv, vi->offset,
! 						       vi->size, &j);
  	      gcc_assert (sft);
! 	      for (; VEC_iterate (tree, sv, j, sft); ++j)
  		{
+ 		  if (SFT_OFFSET (sft) > vi->offset
+ 		      && vi->size <= SFT_OFFSET (sft) - vi->offset)
+ 		    break;
+ 
  		  var_alias_set = get_alias_set (sft);
  		  if (no_tbaa_pruning
  		      || (!is_derefed && !vi->directly_dereferenced)


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