mirror of
https://github.com/danog/ir.git
synced 2024-11-26 20:34:53 +01:00
Avoid memory allocation for empty arguments list
This commit is contained in:
parent
4060f9ca23
commit
cb64f578eb
@ -3347,6 +3347,11 @@ static int32_t ir_emit_arguments(ir_ctx *ctx, ir_ref def, ir_insn *insn, ir_reg
|
||||
bool has_mem_const_args = 0;
|
||||
ir_reg tmp_fp_reg = IR_REG_FP_LAST; /* Temporary register for FP loads and swap */
|
||||
|
||||
n = ir_input_edges_count(ctx, insn);
|
||||
if (n < 3) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (insn->op == IR_CALL && (ctx->flags & IR_PREALLOCATED_STACK)) {
|
||||
// TODO: support for preallocated stack
|
||||
used_stack = 0;
|
||||
@ -3360,7 +3365,6 @@ static int32_t ir_emit_arguments(ir_ctx *ctx, ir_ref def, ir_insn *insn, ir_reg
|
||||
|
||||
/* 1. move all arguments that should be passed through stack
|
||||
* and collect arguments that should be passed through registers */
|
||||
n = ir_input_edges_count(ctx, insn);
|
||||
copies = ir_mem_malloc((n - 2) * sizeof(ir_copy));
|
||||
for (j = 3; j <= n; j++) {
|
||||
arg = insn->ops[j];
|
||||
|
@ -4975,6 +4975,11 @@ static int32_t ir_emit_arguments(ir_ctx *ctx, ir_ref def, ir_insn *insn, ir_reg
|
||||
bool has_mem_const_args = 0;
|
||||
ir_reg tmp_fp_reg = IR_REG_FP_LAST; /* Temporary register for FP loads and swap */
|
||||
|
||||
n = ir_input_edges_count(ctx, insn);
|
||||
if (n < 3) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (insn->op == IR_CALL && (ctx->flags & IR_PREALLOCATED_STACK)) {
|
||||
// TODO: support for preallocated stack
|
||||
used_stack = 0;
|
||||
@ -4988,7 +4993,6 @@ static int32_t ir_emit_arguments(ir_ctx *ctx, ir_ref def, ir_insn *insn, ir_reg
|
||||
|
||||
/* 1. move all arguments that should be passed through stack
|
||||
* and collect arguments that should be passed through registers */
|
||||
n = ir_input_edges_count(ctx, insn);
|
||||
copies = ir_mem_malloc((n - 2) * sizeof(ir_copy));
|
||||
for (j = 3; j <= n; j++) {
|
||||
arg = insn->ops[j];
|
||||
|
Loading…
Reference in New Issue
Block a user