+ /* CALL optimization:
+ * If the value is a parameter-temp: 1 write, 1 read from a CALL
+ * and it's not "locked", write it to the OFS_PARM directly.
+ */
+ if (OPTS_OPTIMIZATION(OPTIM_CALL_STORES)) {
+ if (!v->locked && vec_size(v->reads) == 1 && vec_size(v->writes) == 1 &&
+ (v->reads[0]->opcode == VINSTR_NRCALL ||
+ (v->reads[0]->opcode >= INSTR_CALL0 && v->reads[0]->opcode <= INSTR_CALL8)
+ )
+ )
+ {
+ size_t param;
+ ir_instr *call = v->reads[0];
+ if (!vec_ir_value_find(call->params, v, ¶m)) {
+ irerror(call->context, "internal error: unlocked parameter %s not found", v->name);
+ goto error;
+ }
+
+ v->callparam = true;
+ if (param < 8)
+ ir_value_code_setaddr(v, OFS_PARM0 + 3*param);
+ else {
+ ir_value *ep;
+ param -= 8;
+ if (vec_size(self->owner->extparam_protos) <= param)
+ ep = ir_gen_extparam_proto(self->owner);
+ else
+ ep = self->owner->extparam_protos[param];
+ ir_instr_op(v->writes[0], 0, ep, true);
+ call->params[param+8] = ep;
+ }
+ continue;
+ }
+ }
+