From 5f2fd3cac0befa927a6c212450acd15afe686747 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 5 Feb 2022 20:36:38 +0900 Subject: [PATCH] [qfcc] Skip over zero stack adjustment This is a very tiny optimization, but there's no point in adjust the stack if there's no actual adjustment. I didn't bother with it initially because I thought it wouldn't happen (and I was more interested in getting things working first), but it turns out that simple getters that result in a zero adjustment are quite common (70/535 in qwaq-app.dat). --- tools/qfcc/source/function.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/qfcc/source/function.c b/tools/qfcc/source/function.c index 42f757b9e..c2381d93b 100644 --- a/tools/qfcc/source/function.c +++ b/tools/qfcc/source/function.c @@ -801,7 +801,12 @@ build_code_function (symbol_t *fsym, expr_t *state_expr, expr_t *statements) dstatement_t *st = &pr.code->code[func->code]; if (st->op == OP_ADJSTK) { - st->b = -func->params_start; + if (func->params_start) { + st->b = -func->params_start; + } else { + // skip over adjstk so a zero adjustment doesn't get executed + func->code += 1; + } } merge_spaces (space, func->parameters->space, STACK_ALIGN); func->parameters->space = space;