cp-gimplify.c (cp_gimplify_expr): Use get_initialized_tmp_var.
authorJason Merrill <jason@redhat.com>
Thu, 17 Oct 2019 19:09:53 +0000 (15:09 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 17 Oct 2019 19:09:53 +0000 (15:09 -0400)
* cp-gimplify.c (cp_gimplify_expr): Use get_initialized_tmp_var.

The comment for get_formal_tmp_var says that it shouldn't be used for
expressions whose value might change between initialization and use, and in
this case we're creating a temporary precisely because the value might
change, so we should use get_initialized_tmp_var instead.

I also noticed that many callers of get_initialized_tmp_var pass NULL for
post_p, so it seems appropriate to make it a default argument.

gcc/
* gimplify.h (get_initialized_tmp_var): Add default argument to
post_p.
* gimplify.c (gimplify_self_mod_expr, gimplify_omp_atomic): Remove
NULL post_p argument.
* targhooks (std_gimplify_va_arg_expr): Likewise.

From-SVN: r277128

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/gimplify.c
gcc/gimplify.h
gcc/targhooks.c

index 0f3720194bd763dd85dc842744eedcfb3a355b09..99a6b00bbc81842b78417a20ca4700bb0a9fc006 100644 (file)
@@ -1,3 +1,11 @@
+2019-10-17  Jason Merrill  <jason@redhat.com>
+
+       * gimplify.h (get_initialized_tmp_var): Add default argument to
+       post_p.
+       * gimplify.c (gimplify_self_mod_expr, gimplify_omp_atomic): Remove
+       NULL post_p argument.
+       * targhooks (std_gimplify_va_arg_expr): Likewise.
+
 2019-10-17  Richard Biener  <rguenther@suse.de>
 
        * tree-vectorizer.h (_stmt_vec_info::cond_reduc_code): Remove.
index 09fe6b1531cb963d816be95c2867234387aecf42..d5c7e13f64d24ed4e65a16beab7dcfc86d345ebc 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-17  Jason Merrill  <jason@redhat.com>
+
+       * cp-gimplify.c (cp_gimplify_expr): Use get_initialized_tmp_var.
+       (gimplify_to_rvalue): Remove default NULL argument.
+
 2019-10-17  Nathan Sidwell  <nathan@acm.org>
 
        * decl.c (builtin_function_1): Merge into ...
index 0ab0438f60197a12d32b251ab567fe9797b8d7d8..9fc60c964e0f07c39befe8887089b6ac3c33d6d4 100644 (file)
@@ -650,7 +650,7 @@ gimplify_to_rvalue (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
   if (t == GS_ERROR)
     return GS_ERROR;
   else if (is_gimple_variable (*expr_p) && TREE_CODE (*expr_p) != SSA_NAME)
-    *expr_p = get_initialized_tmp_var (*expr_p, pre_p, NULL);
+    *expr_p = get_initialized_tmp_var (*expr_p, pre_p);
   return t;
 }
 
@@ -767,7 +767,7 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
                && (TREE_CODE (op1) == CALL_EXPR
                    || (SCALAR_TYPE_P (TREE_TYPE (op1))
                        && !TREE_CONSTANT (op1))))
-        TREE_OPERAND (*expr_p, 1) = get_formal_tmp_var (op1, pre_p);
+        TREE_OPERAND (*expr_p, 1) = get_initialized_tmp_var (op1, pre_p);
       }
       ret = GS_OK;
       break;
index 836706961f3e6552c15cdab13922643b6f16b814..914bb8eb8d699efe7be36a72b43a59f8fecd9dbc 100644 (file)
@@ -661,8 +661,9 @@ get_formal_tmp_var (tree val, gimple_seq *pre_p)
    are as in gimplify_expr.  */
 
 tree
-get_initialized_tmp_var (tree val, gimple_seq *pre_p, gimple_seq *post_p,
-                        bool allow_ssa)
+get_initialized_tmp_var (tree val, gimple_seq *pre_p,
+                        gimple_seq *post_p /* = NULL */,
+                        bool allow_ssa /* = true */)
 {
   return internal_get_tmp_var (val, pre_p, post_p, false, allow_ssa);
 }
@@ -3149,7 +3150,7 @@ gimplify_self_mod_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
       if (ret == GS_ERROR)
        return ret;
 
-      lhs = get_initialized_tmp_var (lhs, pre_p, NULL);
+      lhs = get_initialized_tmp_var (lhs, pre_p);
     }
 
   /* For POINTERs increment, use POINTER_PLUS_EXPR.  */
@@ -12688,7 +12689,7 @@ gimplify_omp_atomic (tree *expr_p, gimple_seq *pre_p)
          tree bitsize;
          tree tmp_store = tmp_load;
          if (TREE_CODE (*expr_p) == OMP_ATOMIC_CAPTURE_OLD)
-           tmp_store = get_initialized_tmp_var (tmp_load, pre_p, NULL);
+           tmp_store = get_initialized_tmp_var (tmp_load, pre_p);
          if (INTEGRAL_TYPE_P (TREE_TYPE (op1)))
            bitsize = bitsize_int (TYPE_PRECISION (TREE_TYPE (op1)));
          else
index 1070006374aeed35d15d9d16290cb751b1eac4bb..6c997a769cd9a0745e7945e8bce69575e9008ebb 100644 (file)
@@ -57,7 +57,7 @@ extern gbind *gimple_current_bind_expr (void);
 extern vec<gbind *> gimple_bind_expr_stack (void);
 extern void gimplify_and_add (tree, gimple_seq *);
 extern tree get_formal_tmp_var (tree, gimple_seq *);
-extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *,
+extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq * = NULL,
                                     bool = true);
 extern void declare_vars (tree, gimple *, bool);
 extern void gimple_add_tmp_var (tree);
index 5445038137885ae8d994444fb2695b4f4114c549..fee4cc271cd86a2206e18da2c2db24c5e04b0f4f 100644 (file)
@@ -2164,11 +2164,11 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
 
       real_part = std_gimplify_va_arg_expr (valist,
                                            TREE_TYPE (type), pre_p, NULL);
-      real_part = get_initialized_tmp_var (real_part, pre_p, NULL);
+      real_part = get_initialized_tmp_var (real_part, pre_p);
 
       imag_part = std_gimplify_va_arg_expr (unshare_expr (valist),
                                            TREE_TYPE (type), pre_p, NULL);
-      imag_part = get_initialized_tmp_var (imag_part, pre_p, NULL);
+      imag_part = get_initialized_tmp_var (imag_part, pre_p);
 
       return build2 (COMPLEX_EXPR, type, real_part, imag_part);
    }
@@ -2186,7 +2186,7 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
   boundary /= BITS_PER_UNIT;
 
   /* Hoist the valist value into a temporary for the moment.  */
-  valist_tmp = get_initialized_tmp_var (valist, pre_p, NULL);
+  valist_tmp = get_initialized_tmp_var (valist, pre_p);
 
   /* va_list pointer is aligned to PARM_BOUNDARY.  If argument actually
      requires greater alignment, we must perform dynamic alignment.  */