Richard Henderson <richard.hender...@linaro.org> writes:
> Calls are special in that they have a variable number > of arguments, and need to be able to clobber globals. > > Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > --- > tcg/optimize.c | 63 ++++++++++++++++++++++++++++++++------------------ > 1 file changed, 41 insertions(+), 22 deletions(-) > > diff --git a/tcg/optimize.c b/tcg/optimize.c > index fad6f5de1f..74b9aa025a 100644 > --- a/tcg/optimize.c > +++ b/tcg/optimize.c > @@ -624,10 +624,42 @@ static void copy_propagate(OptContext *ctx, TCGOp *op, > } > } > > +static bool fold_call(OptContext *ctx, TCGOp *op) > +{ > + TCGContext *s = ctx->tcg; > + int nb_oargs = TCGOP_CALLO(op); > + int nb_iargs = TCGOP_CALLI(op); > + int flags, i; > + > + init_arguments(ctx, op, nb_oargs + nb_iargs); > + copy_propagate(ctx, op, nb_oargs, nb_iargs); > + > + /* If the function reads or writes globals, reset temp data. */ > + flags = tcg_call_flags(op); > + if (!(flags & (TCG_CALL_NO_READ_GLOBALS | TCG_CALL_NO_WRITE_GLOBALS))) { > + int nb_globals = s->nb_globals; Aren't we missing a trick here? If the helper is going to read global registers we need to ensure any temps holding their data is written but we don't need to throw the existing temps away if the helper is TCG_CALL_NO_WRITE_GLOBALS? I guess we have to handle the case of temps that are about to get smahed by the call though.... Otherwise: Reviewed-by: Alex Bennée <alex.ben...@linaro.org> -- Alex Bennée