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][6/n] Alias housekeeping


This makes PTA handle OBJ_TYPE_REF (not sure why I thought we need
to give up).

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

Richard.

2011-04-29  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-structalias.c (get_fi_for_callee): Restructure.
	Handle OBJ_TYPE_REF.
	(find_func_aliases_for_call): Use it more consistently.

Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c	(revision 173067)
--- gcc/tree-ssa-structalias.c	(working copy)
*************** handle_pure_call (gimple stmt, VEC(ce_s,
*** 3925,3959 ****
  static varinfo_t
  get_fi_for_callee (gimple call)
  {
!   tree decl;
  
!   gcc_assert (!gimple_call_internal_p (call));
  
    /* If we can directly resolve the function being called, do so.
       Otherwise, it must be some sort of indirect expression that
       we should still be able to handle.  */
!   decl = gimple_call_fndecl (call);
    if (decl)
      return get_vi_for_tree (decl);
  
!   decl = gimple_call_fn (call);
!   /* The function can be either an SSA name pointer or,
!      worse, an OBJ_TYPE_REF.  In this case we have no
       clue and should be getting ANYFN (well, ANYTHING for now).  */
!   if (TREE_CODE (decl) == SSA_NAME)
!     {
!       if (TREE_CODE (decl) == SSA_NAME
! 	  && (TREE_CODE (SSA_NAME_VAR (decl)) == PARM_DECL
! 	      || TREE_CODE (SSA_NAME_VAR (decl)) == RESULT_DECL)
! 	  && SSA_NAME_IS_DEFAULT_DEF (decl))
! 	decl = SSA_NAME_VAR (decl);
!       return get_vi_for_tree (decl);
!     }
!   else if (TREE_CODE (decl) == INTEGER_CST
! 	   || TREE_CODE (decl) == OBJ_TYPE_REF)
      return get_varinfo (anything_id);
!   else
!     gcc_unreachable ();
  }
  
  /* Create constraints for the builtin call T.  Return true if the call
--- 3925,3953 ----
  static varinfo_t
  get_fi_for_callee (gimple call)
  {
!   tree decl, fn = gimple_call_fn (call);
  
!   if (fn && TREE_CODE (fn) == OBJ_TYPE_REF)
!     fn = OBJ_TYPE_REF_EXPR (fn);
  
    /* If we can directly resolve the function being called, do so.
       Otherwise, it must be some sort of indirect expression that
       we should still be able to handle.  */
!   decl = gimple_call_addr_fndecl (fn);
    if (decl)
      return get_vi_for_tree (decl);
  
!   /* If the function is anything other than a SSA name pointer we have no
       clue and should be getting ANYFN (well, ANYTHING for now).  */
!   if (!fn || TREE_CODE (fn) != SSA_NAME)
      return get_varinfo (anything_id);
! 
!   if ((TREE_CODE (SSA_NAME_VAR (fn)) == PARM_DECL
!        || TREE_CODE (SSA_NAME_VAR (fn)) == RESULT_DECL)
!       && SSA_NAME_IS_DEFAULT_DEF (fn))
!     fn = SSA_NAME_VAR (fn);
! 
!   return get_vi_for_tree (fn);
  }
  
  /* Create constraints for the builtin call T.  Return true if the call
*************** find_func_aliases_for_call (gimple t)
*** 4199,4209 ****
        && find_func_aliases_for_builtin_call (t))
      return;
  
    if (!in_ipa_mode
!       || gimple_call_internal_p (t)
!       || (fndecl
! 	  && (!(fi = lookup_vi_for_tree (fndecl))
! 	      || !fi->is_fn_info)))
      {
        VEC(ce_s, heap) *rhsc = NULL;
        int flags = gimple_call_flags (t);
--- 4193,4201 ----
        && find_func_aliases_for_builtin_call (t))
      return;
  
+   fi = get_fi_for_callee (t);
    if (!in_ipa_mode
!       || (fndecl && !fi->is_fn_info))
      {
        VEC(ce_s, heap) *rhsc = NULL;
        int flags = gimple_call_flags (t);
*************** find_func_aliases_for_call (gimple t)
*** 4231,4238 ****
        tree lhsop;
        unsigned j;
  
-       fi = get_fi_for_callee (t);
- 
        /* Assign all the passed arguments to the appropriate incoming
  	 parameters of the function.  */
        for (j = 0; j < gimple_call_num_args (t); j++)
--- 4223,4228 ----
*************** find_func_aliases_for_call (gimple t)
*** 4271,4277 ****
  	      VEC_free(ce_s, heap, tem);
  	    }
  	  FOR_EACH_VEC_ELT (ce_s, lhsc, j, lhsp)
! 	      process_constraint (new_constraint (*lhsp, rhs));
  	}
  
        /* If we pass the result decl by reference, honor that.  */
--- 4261,4267 ----
  	      VEC_free(ce_s, heap, tem);
  	    }
  	  FOR_EACH_VEC_ELT (ce_s, lhsc, j, lhsp)
! 	    process_constraint (new_constraint (*lhsp, rhs));
  	}
  
        /* If we pass the result decl by reference, honor that.  */
*************** find_func_aliases_for_call (gimple t)
*** 4286,4292 ****
  	  get_constraint_for_address_of (lhsop, &rhsc);
  	  lhs = get_function_part_constraint (fi, fi_result);
  	  FOR_EACH_VEC_ELT (ce_s, rhsc, j, rhsp)
! 	      process_constraint (new_constraint (lhs, *rhsp));
  	  VEC_free (ce_s, heap, rhsc);
  	}
  
--- 4276,4282 ----
  	  get_constraint_for_address_of (lhsop, &rhsc);
  	  lhs = get_function_part_constraint (fi, fi_result);
  	  FOR_EACH_VEC_ELT (ce_s, rhsc, j, rhsp)
! 	    process_constraint (new_constraint (lhs, *rhsp));
  	  VEC_free (ce_s, heap, rhsc);
  	}
  
*************** find_func_aliases_for_call (gimple t)
*** 4299,4305 ****
  	  get_constraint_for (gimple_call_chain (t), &rhsc);
  	  lhs = get_function_part_constraint (fi, fi_static_chain);
  	  FOR_EACH_VEC_ELT (ce_s, rhsc, j, rhsp)
! 	      process_constraint (new_constraint (lhs, *rhsp));
  	}
      }
  }
--- 4289,4295 ----
  	  get_constraint_for (gimple_call_chain (t), &rhsc);
  	  lhs = get_function_part_constraint (fi, fi_static_chain);
  	  FOR_EACH_VEC_ELT (ce_s, rhsc, j, rhsp)
! 	    process_constraint (new_constraint (lhs, *rhsp));
  	}
      }
  }


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