From: Jason Merrill Date: Thu, 17 Oct 2019 19:09:53 +0000 (-0400) Subject: cp-gimplify.c (cp_gimplify_expr): Use get_initialized_tmp_var. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8e5993e236a50ffc161dd45d1ef3ab86133e3363;p=gcc.git cp-gimplify.c (cp_gimplify_expr): Use get_initialized_tmp_var. * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0f3720194bd..99a6b00bbc8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-10-17 Jason Merrill + + * 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 * tree-vectorizer.h (_stmt_vec_info::cond_reduc_code): Remove. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 09fe6b1531c..d5c7e13f64d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-10-17 Jason Merrill + + * cp-gimplify.c (cp_gimplify_expr): Use get_initialized_tmp_var. + (gimplify_to_rvalue): Remove default NULL argument. + 2019-10-17 Nathan Sidwell * decl.c (builtin_function_1): Merge into ... diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 0ab0438f601..9fc60c964e0 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -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; diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 836706961f3..914bb8eb8d6 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -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 diff --git a/gcc/gimplify.h b/gcc/gimplify.h index 1070006374a..6c997a769cd 100644 --- a/gcc/gimplify.h +++ b/gcc/gimplify.h @@ -57,7 +57,7 @@ extern gbind *gimple_current_bind_expr (void); extern vec 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); diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 54450381378..fee4cc271cd 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -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. */