From b1459ac816cbbd99ecee1ee7a85290cd080b9202 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 14 Mar 2020 01:24:13 +0900 Subject: [PATCH] [qfcc] Move return save temp into call block This fixes func-expr after the assignment rewrite. Now all tests pass when not optimizing (something not quite right in assignchain when optimizing). --- tools/qfcc/source/expr.c | 3 +++ tools/qfcc/source/expr_binary.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index c4408f6e2..85c07511b 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -1843,6 +1843,9 @@ build_function_call (expr_t *fexpr, const type_t *ftype, expr_t *params) if (e->type == ex_compound) { e = expr_file_line (initialized_temp_expr (arg_types[i], e), e); } + // FIXME this is target-specific info and should not be in the + // expression tree + // That, or always use a temp, since it should get optimized out if (has_function_call (e)) { expr_t *cast = cast_expr (arg_types[i], convert_vector (e)); expr_t *tmp = new_temp_def_expr (arg_types[i]); diff --git a/tools/qfcc/source/expr_binary.c b/tools/qfcc/source/expr_binary.c index 228112311..c2d446334 100644 --- a/tools/qfcc/source/expr_binary.c +++ b/tools/qfcc/source/expr_binary.c @@ -924,10 +924,14 @@ binary_expr (int op, expr_t *e1, expr_t *e2) convert_name (e1); e1 = convert_vector (e1); + // FIXME this is target-specific info and should not be in the + // expression tree if (e1->type == ex_block && e1->e.block.is_call && has_function_call (e2) && e1->e.block.result) { - e = new_temp_def_expr (get_type (e1->e.block.result)); - e1 = assign_expr (e, e1); + expr_t *tmp = new_temp_def_expr (get_type (e1->e.block.result)); + e = assign_expr (tmp, e1->e.block.result); + append_expr (e1, e); + e1->e.block.result = tmp; } if (e1->type == ex_error) return e1;