OSDN Git Service

2011-09-06 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Sep 2011 15:56:20 +0000 (15:56 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Sep 2011 15:56:20 +0000 (15:56 +0000)
PR tree-optimization/47025
* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): BUILT_IN_VA_END
uses nothing.
(call_may_clobber_ref_p_1): BUILT_IN_VA_END is a barrier like
BUILT_IN_FREE.
(stmt_kills_ref_p_1): BUILT_IN_VA_END kills what its argument
definitely points to.
* tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
BUILT_IN_VA_START doesn't let its va_list argument escape.
* tree-ssa-dce.c (propagate_necessity): BUILT_IN_VA_END does
not make any previous stores necessary.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178601 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-ssa-alias.c
gcc/tree-ssa-dce.c
gcc/tree-ssa-structalias.c

index 65d8113..f867f97 100644 (file)
@@ -1,3 +1,17 @@
+2011-09-06  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47025
+       * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): BUILT_IN_VA_END
+       uses nothing.
+       (call_may_clobber_ref_p_1): BUILT_IN_VA_END is a barrier like
+       BUILT_IN_FREE.
+       (stmt_kills_ref_p_1): BUILT_IN_VA_END kills what its argument
+       definitely points to.
+       * tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
+       BUILT_IN_VA_START doesn't let its va_list argument escape.
+       * tree-ssa-dce.c (propagate_necessity): BUILT_IN_VA_END does
+       not make any previous stores necessary.
+
 2011-09-06  Martin Jambor  <mjambor@suse.cz>
 
        * ipa-inline.h (struct inline_summary): Move versionable flag...
index bac1181..10c529b 100644 (file)
@@ -1254,6 +1254,7 @@ ref_maybe_used_by_call_p_1 (gimple call, ao_ref *ref)
        case BUILT_IN_SINCOSF:
        case BUILT_IN_SINCOSL:
        case BUILT_IN_ASSUME_ALIGNED:
+       case BUILT_IN_VA_END:
          return false;
        /* __sync_* builtins and some OpenMP builtins act as threading
           barriers.  */
@@ -1518,6 +1519,7 @@ call_may_clobber_ref_p_1 (gimple call, ao_ref *ref)
           the call has to serve as a barrier for moving loads and stores
           across it.  */
        case BUILT_IN_FREE:
+       case BUILT_IN_VA_END:
          {
            tree ptr = gimple_call_arg (call, 0);
            return ptr_deref_may_alias_ref_p_1 (ptr, ref);
@@ -1763,10 +1765,23 @@ stmt_kills_ref_p_1 (gimple stmt, ao_ref *ref)
                              / BITS_PER_UNIT)))
                    return true;
                }
+             break;
+           }
+
+         case BUILT_IN_VA_END:
+           {
+             tree ptr = gimple_call_arg (stmt, 0);
+             if (TREE_CODE (ptr) == ADDR_EXPR)
+               {
+                 tree base = ao_ref_base (ref);
+                 if (TREE_OPERAND (ptr, 0) == base)
+                   return true;
+               }
+             break;
            }
+
          default:;
          }
-
     }
   return false;
 }
index bf69bbf..c9ad311 100644 (file)
@@ -836,6 +836,7 @@ propagate_necessity (struct edge_list *el)
                      || DECL_FUNCTION_CODE (callee) == BUILT_IN_MALLOC
                      || DECL_FUNCTION_CODE (callee) == BUILT_IN_CALLOC
                      || DECL_FUNCTION_CODE (callee) == BUILT_IN_FREE
+                     || DECL_FUNCTION_CODE (callee) == BUILT_IN_VA_END
                      || DECL_FUNCTION_CODE (callee) == BUILT_IN_ALLOCA
                      || DECL_FUNCTION_CODE (callee) == BUILT_IN_STACK_SAVE
                      || DECL_FUNCTION_CODE (callee) == BUILT_IN_STACK_RESTORE
index d69f14c..edfbd64 100644 (file)
@@ -4187,27 +4187,32 @@ find_func_aliases_for_builtin_call (gimple t)
         mode as well.  */
       case BUILT_IN_VA_START:
        {
+         tree valist = gimple_call_arg (t, 0);
+         struct constraint_expr rhs, *lhsp;
+         unsigned i;
+         get_constraint_for (valist, &lhsc);
+         do_deref (&lhsc);
+         /* The va_list gets access to pointers in variadic
+            arguments.  Which we know in the case of IPA analysis
+            and otherwise are just all nonlocal variables.  */
          if (in_ipa_mode)
            {
-             tree valist = gimple_call_arg (t, 0);
-             struct constraint_expr rhs, *lhsp;
-             unsigned i;
-             /* The va_list gets access to pointers in variadic
-                arguments.  */
              fi = lookup_vi_for_tree (cfun->decl);
-             gcc_assert (fi != NULL);
-             get_constraint_for (valist, &lhsc);
-             do_deref (&lhsc);
              rhs = get_function_part_constraint (fi, ~0);
              rhs.type = ADDRESSOF;
-             FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
-                 process_constraint (new_constraint (*lhsp, rhs));
-             VEC_free (ce_s, heap, lhsc);
-             /* va_list is clobbered.  */
-             make_constraint_to (get_call_clobber_vi (t)->id, valist);
-             return true;
            }
-         break;
+         else
+           {
+             rhs.var = nonlocal_id;
+             rhs.type = ADDRESSOF;
+             rhs.offset = 0;
+           }
+         FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
+           process_constraint (new_constraint (*lhsp, rhs));
+         VEC_free (ce_s, heap, lhsc);
+         /* va_list is clobbered.  */
+         make_constraint_to (get_call_clobber_vi (t)->id, valist);
+         return true;
        }
       /* va_end doesn't have any effect that matters.  */
       case BUILT_IN_VA_END: