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] Repair TYPE_REF_CAN_ALIAS_ALL machinery


> ------------------------------------------------------------------------
> 
> Index: tree-ssa-alias.c
> ===================================================================
> --- tree-ssa-alias.c	(revision 113948)
> +++ tree-ssa-alias.c	(working copy)
> @@ -2060,15 +2060,24 @@ is_escape_site (tree stmt, struct alias_
>        if (lhs == NULL_TREE)
>  	return ESCAPE_UNKNOWN;
>  
> -      /* If the RHS is a conversion between a pointer and an integer, the
> -	 pointer escapes since we can't track the integer.  */
> -      if ((TREE_CODE (TREE_OPERAND (stmt, 1)) == NOP_EXPR
> -	   || TREE_CODE (TREE_OPERAND (stmt, 1)) == CONVERT_EXPR
> -	   || TREE_CODE (TREE_OPERAND (stmt, 1)) == VIEW_CONVERT_EXPR)
> -	  && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND
> -					(TREE_OPERAND (stmt, 1), 0)))
> -	  && !POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (stmt, 1))))
> -	return ESCAPE_BAD_CAST;
> +      if (TREE_CODE (TREE_OPERAND (stmt, 1)) == NOP_EXPR
> +	  || TREE_CODE (TREE_OPERAND (stmt, 1)) == CONVERT_EXPR
> +	  || TREE_CODE (TREE_OPERAND (stmt, 1)) == VIEW_CONVERT_EXPR)
> +	{
> +	  tree from = TREE_TYPE (TREE_OPERAND (TREE_OPERAND (stmt, 1), 0));
> +	  tree to = TREE_TYPE (TREE_OPERAND (stmt, 1));
> +
> +	  /* 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;
> +
> +	  /* Same if the RHS is a conversion between a regular pointer and a
> +	     ref-all pointer since we can't track the SMT of the former.  */
> +	  if (POINTER_TYPE_P (from) && !TYPE_REF_CAN_ALIAS_ALL (from)
> +	      && POINTER_TYPE_P (to) && TYPE_REF_CAN_ALIAS_ALL (to))
> +	    return ESCAPE_BAD_CAST;
> +	}
>  
>        /* If the LHS is an SSA name, it can't possibly represent a non-local
>  	 memory store.  */


The above part i have no problem with, however,


> Index: tree-ssa-operands.c
> ===================================================================
> --- tree-ssa-operands.c	(revision 113948)
> +++ tree-ssa-operands.c	(working copy)
> @@ -1404,6 +1404,28 @@ get_indirect_ref_operands (tree stmt, tr
>      {
>        struct ptr_info_def *pi = NULL;
>  
> +      /* If aliases have been computed already and the dereferenced
> +	 pointer is ref-all, add V_MAY_DEF or V_USE operands for all
> +	 the symbols that have been found to be call-clobbered.  */
> +      if (aliases_computed_p
> +	  && !bitmap_empty_p (call_clobbered_vars)
> +	  && !(flags & opf_no_vops)
> +	  && POINTER_TYPE_P (TREE_TYPE (ptr))
> +	  && TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (ptr)))
> +	{
> +	  unsigned int i;
> +	  bitmap_iterator bi;
> +
> +	  if (global_var)
> +	    add_stmt_operand (&global_var, s_ann, flags);
> +	  else
> +	    EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi)
> +	      {
> +	        tree var = referenced_var (i);
> +	        add_stmt_operand (&var, s_ann, flags);
> +	      }
> +	}
> +
>        /* If PTR has flow-sensitive points-to information, use it.  */
>        if (TREE_CODE (ptr) == SSA_NAME
>  	  && (pi = SSA_NAME_PTR_INFO (ptr)) != NULL
> 

Looks like a massive hack, for a number of reasons.
1. If it really can alias all variables, why are you only adding the
call clobbered ones, and not the addressable ones?
2. We already have machinery to deal with this for things like char,
without hacks like the above.
I suggest you find where we deal with that, and do the same.

As a general statement, we shouldn't need TYPE_REF_CAN_ALIAS_ALL, we
handle the same thing in other languages without it.  But i don't expect
you to fix that :).


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