Be a little leniant with vector param stores.

qcc always used vector stores to load values into the function parameters,
but if the location of the value is too close to the end of the global data
block (the vector spans the end of the block), it would trigger the bounds
check code. Thus, allow such instructions without a murmer, so long as it
actually is a parameter write.
This commit is contained in:
Bill Currie 2011-08-16 12:10:05 +09:00
parent 53049e33eb
commit bb065bd233

View file

@ -1092,6 +1092,22 @@ check_branch (progs_t *pr, dstatement_t *st, opcode_t *op, short offset)
(long)(st - pr->pr_statements), op->opname); (long)(st - pr->pr_statements), op->opname);
} }
static int
is_vector_parameter_store (progs_t *pr, dstatement_t *st,
unsigned short operand)
{
int i;
if (st->op != OP_STORE_V)
return 0;
if (operand != st->a)
return 0;
for (i = 0; i < MAX_PARMS; i++)
if (st->b == pr->pr_params[i] - pr->pr_globals)
return 1;
return 0;
}
#define ISDENORM(x) ((x) && !((x) & 0x7f800000)) #define ISDENORM(x) ((x) && !((x) & 0x7f800000))
static inline void static inline void
@ -1113,8 +1129,11 @@ check_global (progs_t *pr, dstatement_t *st, opcode_t *op, etype_t type,
default: default:
if (operand + (unsigned) pr_type_size[type] if (operand + (unsigned) pr_type_size[type]
> pr->progs->numglobals) { > pr->progs->numglobals) {
msg = "out of bounds global index"; if (operand >= pr->progs->numglobals
goto error; || !is_vector_parameter_store (pr, st, operand)) {
msg = "out of bounds global index";
goto error;
}
} }
if (type != ev_float || !check_denorm) if (type != ev_float || !check_denorm)
break; break;