aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2023-01-29 21:25:40 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2023-02-21 15:12:19 +0100
commit7e9dd9de169034810b92d47bf78284db731fa5da (patch)
tree6a4ab0d6e1969dad90e6845d1d06545a22a69be8 /gcc/d
parent8063de4a8cde958c34fbd2af4a25080709263c74 (diff)
downloadgcc-7e9dd9de169034810b92d47bf78284db731fa5da.zip
gcc-7e9dd9de169034810b92d47bf78284db731fa5da.tar.gz
gcc-7e9dd9de169034810b92d47bf78284db731fa5da.tar.bz2
d: Only handle the left-to-right evaluation of a call expression during gimplify
Removes an unnecessary rewriting of the front-end AST during lowering. gcc/d/ChangeLog: * d-codegen.cc (d_build_call): Remove front-end expansion of side-effects in a call expression. * d-gimplify.cc (d_gimplify_call_expr): Gimplify the callee before its arguments.
Diffstat (limited to 'gcc/d')
-rw-r--r--gcc/d/d-codegen.cc29
-rw-r--r--gcc/d/d-gimplify.cc9
2 files changed, 12 insertions, 26 deletions
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 920b45d..0e8e073 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -2172,7 +2172,6 @@ d_build_call (TypeFunction *tf, tree callable, tree object,
/* Build the argument list for the call. */
vec <tree, va_gc> *args = NULL;
- tree saved_args = NULL_TREE;
bool noreturn_call = false;
/* If this is a delegate call or a nested function being called as
@@ -2182,23 +2181,6 @@ d_build_call (TypeFunction *tf, tree callable, tree object,
if (arguments)
{
- /* First pass, evaluated expanded tuples in function arguments. */
- for (size_t i = 0; i < arguments->length; ++i)
- {
- Lagain:
- Expression *arg = (*arguments)[i];
- gcc_assert (arg->op != EXP::tuple);
-
- if (arg->op == EXP::comma)
- {
- CommaExp *ce = arg->isCommaExp ();
- tree tce = build_expr (ce->e1);
- saved_args = compound_expr (saved_args, tce);
- (*arguments)[i] = ce->e2;
- goto Lagain;
- }
- }
-
const size_t nparams = tf->parameterList.length ();
/* if _arguments[] is the first argument. */
const size_t varargs = tf->isDstyleVariadic ();
@@ -2257,17 +2239,12 @@ d_build_call (TypeFunction *tf, tree callable, tree object,
}
}
- /* Evaluate the callee before calling it. */
- if (TREE_SIDE_EFFECTS (callee))
- {
- callee = d_save_expr (callee);
- saved_args = compound_expr (callee, saved_args);
- }
-
/* If we saw a `noreturn` parameter, any unreachable argument evaluations
after it are discarded, as well as the function call itself. */
if (noreturn_call)
{
+ tree saved_args = NULL_TREE;
+
if (TREE_SIDE_EFFECTS (callee))
saved_args = compound_expr (callee, saved_args);
@@ -2297,7 +2274,7 @@ d_build_call (TypeFunction *tf, tree callable, tree object,
result = force_target_expr (result);
}
- return compound_expr (saved_args, result);
+ return result;
}
/* Build and return the correct call to fmod depending on TYPE.
diff --git a/gcc/d/d-gimplify.cc b/gcc/d/d-gimplify.cc
index 4072a3d..04cb631 100644
--- a/gcc/d/d-gimplify.cc
+++ b/gcc/d/d-gimplify.cc
@@ -162,6 +162,15 @@ d_gimplify_call_expr (tree *expr_p, gimple_seq *pre_p)
if (!has_side_effects)
return GS_UNHANDLED;
+ /* Evaluate the callee before calling it. */
+ tree new_call_fn = CALL_EXPR_FN (*expr_p);
+
+ if (gimplify_expr (&new_call_fn, pre_p, NULL,
+ is_gimple_call_addr, fb_rvalue) == GS_ERROR)
+ return GS_ERROR;
+
+ CALL_EXPR_FN (*expr_p) = new_call_fn;
+
/* Leave the last argument for gimplify_call_expr. */
for (int i = 0; i < nargs - 1; i++)
{