From 4daa84ed2a9028184afdae2e876fbbe0b3781c1b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 8 Mar 2024 09:03:52 +0900 Subject: [PATCH] [qfcc] Force @return to be live The change to not split basic blocks on function calls resulted in the @return def not being live and thus getting dropped when optimizing. Marking the def as not local forces flow and dags to treat it as global and thus forced it to be live. --- tools/qfcc/source/statements.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/qfcc/source/statements.c b/tools/qfcc/source/statements.c index f8adce2b5..8261772ec 100644 --- a/tools/qfcc/source/statements.c +++ b/tools/qfcc/source/statements.c @@ -1505,7 +1505,11 @@ statement_return (sblock_t *sblock, const expr_t *e) // FIXME hard-coded reg, and assumes 3 is free #define REG 3 const expr_t *with = new_with_expr (11, REG, new_short_expr (0)); - def_t *ret_ptr = new_def (0, 0, 0, sc_local); + def_t *ret_ptr = new_def ("@return", 0, 0, sc_local); + // @return is neither global nor local, but making it not + // local causes flow (and dags) to treat it as global and thus + // it is live. + ret_ptr->local = 0; operand_t *ret_op = def_operand (ret_ptr, &type_void, e); ret_ptr->reg = REG; sblock = statement_single (sblock, with);