... and in PTA (fixing some of the missing pt_null's).

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

Richard.

2016-10-20  Richard Biener  <rguent...@suse.de>

        * tree-ssa-alias.c (ptrs_compare_unequal): Remove code duplication.
        Handle decls possibly not bound.
        * tree-ssa-structalias.c (get_constraint_for_ssa_var): Add
        nothing_id for decls that might not be bound if we are interested
        for the address.
        (get_constraint_for_component_ref): Deal with that.

Index: gcc/tree-ssa-alias.c
===================================================================
--- gcc/tree-ssa-alias.c        (revision 241363)
+++ gcc/tree-ssa-alias.c        (working copy)
@@ -358,6 +358,13 @@ ptrs_compare_unequal (tree ptr1, tree pt
        ptr2 = TREE_OPERAND (tem, 0);
     }
 
+  /* Canonicalize ptr vs. object.  */
+  if (TREE_CODE (ptr1) == SSA_NAME && obj2)
+    {
+      std::swap (ptr1, ptr2);
+      std::swap (obj1, obj2);
+    }
+
   if (obj1 && obj2)
     /* Other code handles this correctly, no need to duplicate it here.  */;
   else if (obj1 && TREE_CODE (ptr2) == SSA_NAME)
@@ -368,15 +375,16 @@ ptrs_compare_unequal (tree ptr1, tree pt
         may be in fact obj1.  */
       if (!pi || pi->pt.vars_contains_restrict)
        return false;
+      if (VAR_P (obj1)
+         && (TREE_STATIC (obj1) || DECL_EXTERNAL (obj1)))
+       {
+         varpool_node *node = varpool_node::get (obj1);
+         /* If obj1 may bind to NULL give up (see below).  */
+         if (! node || ! node->nonzero_address ())
+           return false;
+       }
       return !pt_solution_includes (&pi->pt, obj1);
     }
-  else if (TREE_CODE (ptr1) == SSA_NAME && obj2)
-    {
-      struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr1);
-      if (!pi || pi->pt.vars_contains_restrict)
-       return false;
-      return !pt_solution_includes (&pi->pt, obj2);
-    }
 
   /* ???  We'd like to handle ptr1 != NULL and ptr1 != ptr2
      but those require pt.null to be conservatively correct.  */
Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c  (revision 241363)
+++ gcc/tree-ssa-structalias.c  (working copy)
@@ -2944,6 +2944,16 @@ get_constraint_for_ssa_var (tree t, vec<
          DECL_PT_UID (t) = DECL_UID (node->decl);
          t = node->decl;
        }
+
+      /* If this is decl may bind to NULL note that.  */
+      if (address_p
+         && (! node || ! node->nonzero_address ()))
+       {
+         cexpr.var = nothing_id;
+         cexpr.type = SCALAR;
+         cexpr.offset = 0;
+         results->safe_push (cexpr);
+       }
     }
 
   vi = get_vi_for_tree (t);
@@ -3213,6 +3223,12 @@ get_constraint_for_component_ref (tree t
   /* Pretend to take the address of the base, we'll take care of
      adding the required subset of sub-fields below.  */
   get_constraint_for_1 (t, results, true, lhs_p);
+  /* Strip off nothing_id.  */
+  if (results->length () == 2)
+    {
+      gcc_assert ((*results)[0].var == nothing_id);
+      results->unordered_remove (0);
+    }
   gcc_assert (results->length () == 1);
   struct constraint_expr &result = results->last ();
 

Reply via email to