From: Dale Weiler Date: Thu, 17 Oct 2013 08:45:24 +0000 (-0400) Subject: Ignore generating a return instruction in accumulated functions, eventually we'll... X-Git-Tag: 0.3.5~8 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=97217b55d11cd81d23c6691cb5e06059ae6ae927;p=xonotic%2Fgmqcc.git Ignore generating a return instruction in accumulated functions, eventually we'll have a way to merge these into one function but for now the RETURN is a waste. --- diff --git a/ast.c b/ast.c index cb4ad06..21a29ea 100644 --- a/ast.c +++ b/ast.c @@ -1879,6 +1879,8 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir) for (i = 0; i < vec_size(ec->params); i++) vec_push(call->params, (ast_expression*)ec->params[i]); vec_push(vec_last(self->blocks)->exprs, (ast_expression*)call); + + self->ir_func->flags |= IR_FLAG_ACCUMULATE; } for (i = 0; i < vec_size(self->blocks); ++i) { diff --git a/ir.c b/ir.c index 9967d7d..fbb79f2 100644 --- a/ir.c +++ b/ir.c @@ -1583,7 +1583,13 @@ bool ir_block_create_return(ir_block *self, lex_ctx_t ctx, ir_value *v) ir_instr *in; if (!ir_check_unreachable(self)) return false; + self->final = true; + + /* can eliminate the return instructions for accumulation */ + if (self->owner->flags & IR_FLAG_ACCUMULATE) + return true; + self->is_return = true; in = ir_instr_new(ctx, self, INSTR_RETURN); if (!in) diff --git a/ir.h b/ir.h index 3c236ea..507a231 100644 --- a/ir.h +++ b/ir.h @@ -232,6 +232,7 @@ typedef struct ir_function_s #define IR_FLAG_HAS_GOTO (1<<3) #define IR_FLAG_INCLUDE_DEF (1<<4) #define IR_FLAG_ERASEABLE (1<<5) +#define IR_FLAG_ACCUMULATE (1<<6) #define IR_FLAG_MASK_NO_OVERLAP (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED) #define IR_FLAG_MASK_NO_LOCAL_TEMPS (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED)