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] Remove dubious PTA stuff, stregthen asserts


This removes some dubious constraint transformations and replaces them
by asserts, moving lhs &ANYTHING handling to a central place.

Bootstrapped and tested on x86_64-unknown-linux-gnu, installed on
the branch.  This exposes PR39331 which I'll fix via merging from
trunk after I install a patch there.

Richard.

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

	* tree-ssa-structalias.c (process_constraint): Deal with
	&ANYTHING on the lhs, reject all other ADDRESSOF constraints
	on the lhs.
	(get_constraint_for_component_ref): Assert that we don't get
	ADDRESSOF constraints from the base of the reference.
	Properly generate UNKNOWN_OFFSET for DEREF if needed.
	(do_structure_copy): Remove special casings, treat &ANYTHING
	on the lhs like DEREF.

Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c	(revision 144492)
--- gcc/tree-ssa-structalias.c	(working copy)
*************** process_constraint (constraint_t t)
*** 2737,2756 ****
    gcc_assert (rhs.var < VEC_length (varinfo_t, varmap));
    gcc_assert (lhs.var < VEC_length (varinfo_t, varmap));
  
!   /* ANYTHING == ANYTHING is pointless.  */
!   if (lhs.var == anything_id && rhs.var == anything_id)
!     return;
  
-   /* If we have &ANYTHING = something, convert to SOMETHING = &ANYTHING) */
-   else if (lhs.var == anything_id && lhs.type == ADDRESSOF)
-     {
-       rhs = t->lhs;
-       t->lhs = t->rhs;
-       t->rhs = rhs;
-       process_constraint (t);
-     }
    /* This can happen in our IR with things like n->a = *p */
!   else if (rhs.type == DEREF && lhs.type == DEREF && rhs.var != anything_id)
      {
        /* Split into tmp = *rhs, *lhs = tmp */
        tree rhsdecl = get_varinfo (rhs.var)->decl;
--- 2737,2754 ----
    gcc_assert (rhs.var < VEC_length (varinfo_t, varmap));
    gcc_assert (lhs.var < VEC_length (varinfo_t, varmap));
  
!   /* If we didn't get any useful constraint from the lhs we get
!      &ANYTHING as fallback from get_constraint_for.  Deal with
!      it here by turning it into *ANYTHING.  */
!   if (lhs.type == ADDRESSOF
!       && lhs.var == anything_id)
!     lhs.type = DEREF;
! 
!   /* ADDRESSOF on the lhs is invalid.  */
!   gcc_assert (lhs.type != ADDRESSOF);
  
    /* This can happen in our IR with things like n->a = *p */
!   if (rhs.type == DEREF && lhs.type == DEREF && rhs.var != anything_id)
      {
        /* Split into tmp = *rhs, *lhs = tmp */
        tree rhsdecl = get_varinfo (rhs.var)->decl;
*************** get_constraint_for_component_ref (tree t
*** 2966,2975 ****
    gcc_assert (VEC_length (ce_s, *results) == 1);
    result = VEC_last (ce_s, *results);
  
-   /* This can also happen due to weird offsetof type macros.  */
-   if (TREE_CODE (t) != ADDR_EXPR && result->type == ADDRESSOF)
-     result->type = SCALAR;
- 
    if (result->type == SCALAR
        && get_varinfo (result->var)->is_full_var)
      /* For single-field vars do not bother about the offset.  */
--- 2964,2969 ----
*************** get_constraint_for_component_ref (tree t
*** 3033,3047 ****
  	if (dump_file && (dump_flags & TDF_DETAILS))
  	  fprintf (dump_file, "Access to past the end of variable, ignoring\n");
      }
!   else if (bitmaxsize == -1)
      {
!       /* We can't handle DEREF constraints with unknown size, we'll
! 	 get the wrong answer.  Punt and return anything.  */
!       result->var = anything_id;
!       result->offset = 0;
      }
    else
!     result->offset = bitpos;
  }
  
  
--- 3027,3046 ----
  	if (dump_file && (dump_flags & TDF_DETAILS))
  	  fprintf (dump_file, "Access to past the end of variable, ignoring\n");
      }
!   else if (result->type == DEREF)
      {
!       /* If we do not know exactly where the access goes say so.  Note
! 	 that only for non-structure accesses we know that we access
! 	 at most one subfiled of any variable.  */
!       if (bitpos == -1
! 	  || bitsize != bitmaxsize
! 	  || AGGREGATE_TYPE_P (TREE_TYPE (orig_t)))
! 	result->offset = UNKNOWN_OFFSET;
!       else
! 	result->offset = bitpos;
      }
    else
!     gcc_unreachable ();
  }
  
  
*************** do_structure_copy (tree lhsop, tree rhso
*** 3221,3260 ****
    get_constraint_for (lhsop, &lhsc);
    get_constraint_for (rhsop, &rhsc);
    lhsp = VEC_index (ce_s, lhsc, 0);
-   /* If we didn't get any useful constraint from the lhs we get
-      &ANYTHING which isn't valid here.  Build
-        structcopydereftmp = &ANYTHING
-        *structcopydereftmp = rhs
-      for that instead.  */
-   if (lhsp->type == ADDRESSOF
-       && lhsp->var == anything_id)
-     {
-       struct constraint_expr tmp;
-       tree tmpvar;
-       gcc_assert (VEC_length (ce_s, lhsc) == 1);
-       tmpvar = create_tmp_var_raw (ptr_type_node,
- 				   "structcopydereftmp");
-       tmp.var = get_vi_for_tree (tmpvar)->id;
-       tmp.type = SCALAR;
-       tmp.offset = 0;
-       process_constraint (new_constraint (tmp, *lhsp));
-       lhsp->type = DEREF;
-       lhsp->var = tmp.var;
-       lhsp->offset = 0;
-     }
-   else if (lhsp->type == DEREF)
-     {
-       gcc_assert (VEC_length (ce_s, lhsc) == 1);
-       lhsp->offset = UNKNOWN_OFFSET;
-     }
    rhsp = VEC_index (ce_s, rhsc, 0);
-   if (rhsp->type == DEREF)
-     {
-       gcc_assert (VEC_length (ce_s, rhsc) == 1);
-       rhsp->offset = UNKNOWN_OFFSET;
-     }
- 
    if (lhsp->type == DEREF
        || rhsp->type == DEREF)
      {
        struct constraint_expr tmp;
--- 3220,3228 ----
    get_constraint_for (lhsop, &lhsc);
    get_constraint_for (rhsop, &rhsc);
    lhsp = VEC_index (ce_s, lhsc, 0);
    rhsp = VEC_index (ce_s, rhsc, 0);
    if (lhsp->type == DEREF
+       || (lhsp->type == ADDRESSOF && lhsp->var == anything_id)
        || rhsp->type == DEREF)
      {
        struct constraint_expr tmp;


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