Remove ifn_va_arg ap fixup
authorTom de Vries <tom@codesourcery.com>
Tue, 28 Apr 2015 20:58:51 +0000 (20:58 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Tue, 28 Apr 2015 20:58:51 +0000 (20:58 +0000)
2015-04-28  Tom de Vries  <tom@codesourcery.com>

PR tree-optimization/65887
* gimplify.c (gimplify_modify_expr): Remove ifn_va_arg ap fixup.

* c-common.c (build_va_arg): Mark va_arg ap argument as addressable.

From-SVN: r222546

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/gimplify.c

index f8c94deceefd4ed81bd6722d0df39b61c1dc4795..8ba462b6e743191a8e8930480e4b9f8951ede3d5 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-28  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/65887
+       * gimplify.c (gimplify_modify_expr): Remove ifn_va_arg ap fixup.
+
 2015-04-28  Sandra Loosemore  <sandra@codesourcery.com>
 
        * doc/extend.texi (Declaring Attributes of Functions): Split into
index 161504ba0ccd477c52dc3fffcfbe88e50a23c7a0..217aafb2df5fa679ab4287e7ae8a461badc309b3 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-28  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/65887
+       * c-common.c (build_va_arg): Mark va_arg ap argument as addressable.
+
 2015-04-28  Eric Botcazou  <ebotcazou@adacore.com>
             Pierre-Marie de Rodat  <derodat@adacore.com>
 
index 9797e1701d3fc54d409943fea7e2a93f7897dbd7..30456c6a552cf446f330d3f0978383d36144c402 100644 (file)
@@ -5910,6 +5910,10 @@ set_compound_literal_name (tree decl)
 tree
 build_va_arg (location_t loc, tree expr, tree type)
 {
+  /* In gimplify_va_arg_expr we take the address of the ap argument, mark it
+     addressable now.  */
+  mark_addressable (expr);
+
   expr = build1 (VA_ARG_EXPR, type, expr);
   SET_EXPR_LOCATION (expr, loc);
   return expr;
index c68bd4747564b80a555538cc28f92bcc8c9538de..1d5341eec5b19028c7397a5f6a2f912a4c721620 100644 (file)
@@ -4569,7 +4569,6 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
   gimple assign;
   location_t loc = EXPR_LOCATION (*expr_p);
   gimple_stmt_iterator gsi;
-  tree ap = NULL_TREE, ap_copy = NULL_TREE;
 
   gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR
              || TREE_CODE (*expr_p) == INIT_EXPR);
@@ -4730,16 +4729,12 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
          enum internal_fn ifn = CALL_EXPR_IFN (*from_p);
          auto_vec<tree> vargs (nargs);
 
-         if (ifn == IFN_VA_ARG)
-           ap = unshare_expr (CALL_EXPR_ARG (*from_p, 0));
          for (i = 0; i < nargs; i++)
            {
              gimplify_arg (&CALL_EXPR_ARG (*from_p, i), pre_p,
                            EXPR_LOCATION (*from_p));
              vargs.quick_push (CALL_EXPR_ARG (*from_p, i));
            }
-         if (ifn == IFN_VA_ARG)
-           ap_copy = CALL_EXPR_ARG (*from_p, 0);
          call_stmt = gimple_build_call_internal_vec (ifn, vargs);
          gimple_set_location (call_stmt, EXPR_LOCATION (*expr_p));
        }
@@ -4784,17 +4779,6 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
   gsi = gsi_last (*pre_p);
   maybe_fold_stmt (&gsi);
 
-  /* When gimplifying the &ap argument of va_arg, we might end up with
-       ap.1 = ap
-       va_arg (&ap.1, 0B)
-     We need to assign ap.1 back to ap, otherwise va_arg has no effect on
-     ap.  */
-  if (ap != NULL_TREE
-      && TREE_CODE (ap) == ADDR_EXPR
-      && TREE_CODE (ap_copy) == ADDR_EXPR
-      && !operand_equal_p (TREE_OPERAND (ap, 0), TREE_OPERAND (ap_copy, 0), 0))
-    gimplify_assign (TREE_OPERAND (ap, 0), TREE_OPERAND (ap_copy, 0), pre_p);
-
   if (want_value)
     {
       *expr_p = TREE_THIS_VOLATILE (*to_p) ? *from_p : unshare_expr (*to_p);