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] Fix PR54781


The following patch properly constrains inputs to refs_may_alias_p
as coming from the RTL oracle.  Instead of disallowing stuff this
just leaves things through that it can handle (thus it should be
more failsafe).  The patch also removes some dead code.

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Thanks,
Richard.

2012-12-17  Richard Biener  <rguenther@suse.de>

	PR middle-end/54781
	* alias.c (ao_ref_from_mem): More appropriately constrain the
	base object we feed to the tree oracle.  Remove dead code.

Index: gcc/alias.c
===================================================================
*** gcc/alias.c	(revision 194552)
--- gcc/alias.c	(working copy)
*************** ao_ref_from_mem (ao_ref *ref, const_rtx
*** 283,309 ****
    if (base == NULL_TREE)
      return false;
  
!   /* The tree oracle doesn't like to have these.  */
!   if (TREE_CODE (base) == FUNCTION_DECL
!       || TREE_CODE (base) == LABEL_DECL)
!     return false;
! 
!   /* If this is a pointer dereference of a non-SSA_NAME punt.
!      ???  We could replace it with a pointer to anything.  */
!   if ((INDIRECT_REF_P (base)
!        || TREE_CODE (base) == MEM_REF)
!       && TREE_CODE (TREE_OPERAND (base, 0)) != SSA_NAME)
!     return false;
!   if (TREE_CODE (base) == TARGET_MEM_REF
!       && TMR_BASE (base)
!       && TREE_CODE (TMR_BASE (base)) != SSA_NAME)
      return false;
  
    /* If this is a reference based on a partitioned decl replace the
!      base with an INDIRECT_REF of the pointer representative we
       created during stack slot partitioning.  */
    if (TREE_CODE (base) == VAR_DECL
!       && ! TREE_STATIC (base)
        && cfun->gimple_df->decls_to_pointers != NULL)
      {
        void *namep;
--- 283,302 ----
    if (base == NULL_TREE)
      return false;
  
!   /* The tree oracle doesn't like bases that are neither decls
!      nor indirect references of SSA names.  */
!   if (!DECL_P (base)
!       && (TREE_CODE (base) != MEM_REF
! 	  || TREE_CODE (TREE_OPERAND (base, 0)) != SSA_NAME)
!       && (TREE_CODE (base) != TARGET_MEM_REF
! 	  || TREE_CODE (TMR_BASE (base)) != SSA_NAME))
      return false;
  
    /* If this is a reference based on a partitioned decl replace the
!      base with a MEM_REF of the pointer representative we
       created during stack slot partitioning.  */
    if (TREE_CODE (base) == VAR_DECL
!       && ! is_global_var (base)
        && cfun->gimple_df->decls_to_pointers != NULL)
      {
        void *namep;
*************** ao_ref_from_mem (ao_ref *ref, const_rtx
*** 311,328 ****
        if (namep)
  	ref->base = build_simple_mem_ref (*(tree *)namep);
      }
-   else if (TREE_CODE (base) == TARGET_MEM_REF
- 	   && TREE_CODE (TMR_BASE (base)) == ADDR_EXPR
- 	   && TREE_CODE (TREE_OPERAND (TMR_BASE (base), 0)) == VAR_DECL
- 	   && ! TREE_STATIC (TREE_OPERAND (TMR_BASE (base), 0))
- 	   && cfun->gimple_df->decls_to_pointers != NULL)
-     {
-       void *namep;
-       namep = pointer_map_contains (cfun->gimple_df->decls_to_pointers,
- 				    TREE_OPERAND (TMR_BASE (base), 0));
-       if (namep)
- 	ref->base = build_simple_mem_ref (*(tree *)namep);
-     }
  
    ref->ref_alias_set = MEM_ALIAS_SET (mem);
  
--- 304,309 ----


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