]> gcc.gnu.org Git - gcc.git/commitdiff
tree-sra.c (ptr_parm_has_direct_uses): Rewrite to be conservatively correct.
authorRichard Guenther <rguenther@suse.de>
Sun, 31 Jan 2010 19:54:32 +0000 (19:54 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Sun, 31 Jan 2010 19:54:32 +0000 (19:54 +0000)
2010-01-31  Richard Guenther  <rguenther@suse.de>

* tree-sra.c (ptr_parm_has_direct_uses): Rewrite to be
conservatively correct.

From-SVN: r156413

gcc/ChangeLog
gcc/tree-sra.c

index 54ed530f8075f35c57306cff3c85974e3f2e3828..366652ce10901ff39cc5fe3c02dd2d0c5b3ba272 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-31  Richard Guenther  <rguenther@suse.de>
+
+       * tree-sra.c (ptr_parm_has_direct_uses): Rewrite to be
+       conservatively correct.
+
 2010-01-31  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        PR target/42850
index 7c3373de9f6483371b2e7fec38517212a7840989..c0d3d3f8a5d83b4ae3c29f1145edd92b46371666 100644 (file)
@@ -2904,42 +2904,51 @@ ptr_parm_has_direct_uses (tree parm)
 
   FOR_EACH_IMM_USE_STMT (stmt, ui, name)
     {
-      if (gimple_assign_single_p (stmt))
+      int uses_ok = 0;
+      use_operand_p use_p;
+
+      if (is_gimple_debug (stmt))
+       continue;
+
+      /* Valid uses include dereferences on the lhs and the rhs.  */
+      if (gimple_has_lhs (stmt))
        {
-         tree rhs = gimple_assign_rhs1 (stmt);
-         if (rhs == name)
-           ret = true;
-         else if (TREE_CODE (rhs) == ADDR_EXPR)
-           {
-             do
-               {
-                 rhs = TREE_OPERAND (rhs, 0);
-               }
-             while (handled_component_p (rhs));
-             if (INDIRECT_REF_P (rhs) && TREE_OPERAND (rhs, 0) == name)
-               ret = true;
-           }
+         tree lhs = gimple_get_lhs (stmt);
+         while (handled_component_p (lhs))
+           lhs = TREE_OPERAND (lhs, 0);
+         if (INDIRECT_REF_P (lhs)
+             && TREE_OPERAND (lhs, 0) == name)
+           uses_ok++;
        }
-      else if (gimple_code (stmt) == GIMPLE_RETURN)
+      if (gimple_assign_single_p (stmt))
        {
-         tree t = gimple_return_retval (stmt);
-         if (t == name)
-           ret = true;
+         tree rhs = gimple_assign_rhs1 (stmt);
+         while (handled_component_p (rhs))
+           rhs = TREE_OPERAND (rhs, 0);
+         if (INDIRECT_REF_P (rhs)
+             && TREE_OPERAND (rhs, 0) == name)
+           uses_ok++;
        }
       else if (is_gimple_call (stmt))
        {
          unsigned i;
-         for (i = 0; i < gimple_call_num_args (stmt); i++)
+         for (i = 0; i < gimple_call_num_args (stmt); ++i)
            {
              tree arg = gimple_call_arg (stmt, i);
-             if (arg == name)
-               {
-                 ret = true;
-                 break;
-               }
+             while (handled_component_p (arg))
+               arg = TREE_OPERAND (arg, 0);
+             if (INDIRECT_REF_P (arg)
+                 && TREE_OPERAND (arg, 0) == name)
+               uses_ok++;
            }
        }
-      else if (!is_gimple_debug (stmt))
+
+      /* If the number of valid uses does not match the number of
+         uses in this stmt there is an unhandled use.  */
+      FOR_EACH_IMM_USE_ON_STMT (use_p, ui)
+       --uses_ok;
+
+      if (uses_ok != 0)
        ret = true;
 
       if (ret)
This page took 0.065118 seconds and 5 git commands to generate.