fix sparc Call transform rule off-by-one error
authorMatthias Braun <matze@braunis.de>
Thu, 28 Jul 2011 10:41:21 +0000 (12:41 +0200)
committerMatthias Braun <matze@braunis.de>
Thu, 28 Jul 2011 10:41:26 +0000 (12:41 +0200)
ir/be/sparc/sparc_transform.c

index 7894cf1..7c071d0 100644 (file)
@@ -1623,7 +1623,8 @@ static ir_node *gen_Call(ir_node *node)
        calling_convention_t *cconv
                = sparc_decide_calling_convention(type, NULL);
        size_t           n_param_regs = cconv->n_param_regs;
-       unsigned         max_inputs   = 2 + n_param_regs;
+       /* param-regs + mem + stackpointer + callee */
+       unsigned         max_inputs   = 3 + n_param_regs;
        ir_node        **in           = ALLOCAN(ir_node*, max_inputs);
        const arch_register_req_t **in_req
                = OALLOCNZ(obst, const arch_register_req_t*, max_inputs);
@@ -1711,7 +1712,6 @@ static ir_node *gen_Call(ir_node *node)
                set_irn_pinned(str, op_pin_state_floats);
                sync_ins[sync_arity++] = str;
        }
-       assert(in_arity <= (int)max_inputs);
 
        /* construct memory input */
        if (sync_arity == 0) {
@@ -1729,6 +1729,7 @@ static ir_node *gen_Call(ir_node *node)
                in_req[in_arity] = sparc_reg_classes[CLASS_sparc_gp].class_req;
                ++in_arity;
        }
+       assert(in_arity <= (int)max_inputs);
 
        /* outputs:
         *  - memory