From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:35823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLt0E-0005dh-Tl for qemu-devel@nongnu.org; Wed, 01 May 2019 13:26:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLt0D-0001gJ-ES for qemu-devel@nongnu.org; Wed, 01 May 2019 13:26:42 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:39490) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLt0D-0001e0-52 for qemu-devel@nongnu.org; Wed, 01 May 2019 13:26:41 -0400 Received: by mail-wm1-x341.google.com with SMTP id n25so7694254wmk.4 for ; Wed, 01 May 2019 10:26:41 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id v17sm4345537wmc.30.2019.05.01.10.26.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2019 10:26:38 -0700 (PDT) Received: from zen (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6CF881FF87 for ; Wed, 1 May 2019 18:26:38 +0100 (BST) References: <20190501050536.15580-1-richard.henderson@linaro.org> <20190501050536.15580-6-richard.henderson@linaro.org> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <20190501050536.15580-6-richard.henderson@linaro.org> Date: Wed, 01 May 2019 18:26:38 +0100 Message-ID: <87pnp25bn5.fsf@zen.linaroharston> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 05/29] tcg: Assert fixed_reg is read-only List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Richard Henderson writes: > The only fixed_reg is cpu_env, and it should not be modified > during any TB. Therefore code that tries to special-case moves > into a fixed_reg is dead. Remove it. > > Reviewed-by: David Hildenbrand > Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e > --- > tcg/tcg.c | 87 +++++++++++++++++++++++++------------------------------ > 1 file changed, 40 insertions(+), 47 deletions(-) > > diff --git a/tcg/tcg.c b/tcg/tcg.c > index f7bef51de8..70ca113c26 100644 > --- a/tcg/tcg.c > +++ b/tcg/tcg.c > @@ -3274,11 +3274,8 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, T= CGTemp *ots, > tcg_target_ulong val, TCGLifeData arg_= life, > TCGRegSet preferred_regs) > { > - if (ots->fixed_reg) { > - /* For fixed registers, we do not do any constant propagation. = */ > - tcg_out_movi(s, ots->type, ots->reg, val); > - return; > - } > + /* ENV should not be modified. */ > + tcg_debug_assert(!ots->fixed_reg); > > /* The movi is not explicitly generated here. */ > if (ots->val_type =3D=3D TEMP_VAL_REG) { > @@ -3314,6 +3311,9 @@ static void tcg_reg_alloc_mov(TCGContext *s, const = TCGOp *op) > ots =3D arg_temp(op->args[0]); > ts =3D arg_temp(op->args[1]); > > + /* ENV should not be modified. */ > + tcg_debug_assert(!ots->fixed_reg); > + > /* Note that otype !=3D itype for no-op truncation. */ > otype =3D ots->type; > itype =3D ts->type; > @@ -3338,7 +3338,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const = TCGOp *op) > } > > tcg_debug_assert(ts->val_type =3D=3D TEMP_VAL_REG); > - if (IS_DEAD_ARG(0) && !ots->fixed_reg) { > + if (IS_DEAD_ARG(0)) { > /* mov to a non-saved dead register makes no sense (even with > liveness analysis disabled). */ > tcg_debug_assert(NEED_SYNC_ARG(0)); > @@ -3351,7 +3351,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const = TCGOp *op) > } > temp_dead(s, ots); > } else { > - if (IS_DEAD_ARG(1) && !ts->fixed_reg && !ots->fixed_reg) { > + if (IS_DEAD_ARG(1) && !ts->fixed_reg) { > /* the mov can be suppressed */ > if (ots->val_type =3D=3D TEMP_VAL_REG) { > s->reg_to_temp[ots->reg] =3D NULL; > @@ -3504,6 +3504,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const = TCGOp *op) > arg =3D op->args[i]; > arg_ct =3D &def->args_ct[i]; > ts =3D arg_temp(arg); > + > + /* ENV should not be modified. */ > + tcg_debug_assert(!ts->fixed_reg); > + > if ((arg_ct->ct & TCG_CT_ALIAS) > && !const_args[arg_ct->alias_index]) { > reg =3D new_args[arg_ct->alias_index]; > @@ -3512,29 +3516,21 @@ static void tcg_reg_alloc_op(TCGContext *s, const= TCGOp *op) > i_allocated_regs | o_allocated_regs, > op->output_pref[k], ts->indirect_bas= e); > } else { > - /* if fixed register, we try to use it */ > - reg =3D ts->reg; > - if (ts->fixed_reg && > - tcg_regset_test_reg(arg_ct->u.regs, reg)) { > - goto oarg_end; > - } > reg =3D tcg_reg_alloc(s, arg_ct->u.regs, o_allocated_reg= s, > op->output_pref[k], ts->indirect_bas= e); > } > tcg_regset_set_reg(o_allocated_regs, reg); > - /* if a fixed register is used, then a move will be done aft= erwards */ > - if (!ts->fixed_reg) { > - if (ts->val_type =3D=3D TEMP_VAL_REG) { > - s->reg_to_temp[ts->reg] =3D NULL; > - } > - ts->val_type =3D TEMP_VAL_REG; > - ts->reg =3D reg; > - /* temp value is modified, so the value kept in memory is > - potentially not the same */ > - ts->mem_coherent =3D 0; > - s->reg_to_temp[reg] =3D ts; > + if (ts->val_type =3D=3D TEMP_VAL_REG) { > + s->reg_to_temp[ts->reg] =3D NULL; > } > - oarg_end: > + ts->val_type =3D TEMP_VAL_REG; > + ts->reg =3D reg; > + /* > + * Temp value is modified, so the value kept in memory is > + * potentially not the same. > + */ > + ts->mem_coherent =3D 0; > + s->reg_to_temp[reg] =3D ts; > new_args[i] =3D reg; > } > } > @@ -3550,10 +3546,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const= TCGOp *op) > /* move the outputs in the correct register if needed */ > for(i =3D 0; i < nb_oargs; i++) { > ts =3D arg_temp(op->args[i]); > - reg =3D new_args[i]; > - if (ts->fixed_reg && ts->reg !=3D reg) { > - tcg_out_mov(s, ts->type, ts->reg, reg); > - } > + > + /* ENV should not be modified. */ > + tcg_debug_assert(!ts->fixed_reg); > + > if (NEED_SYNC_ARG(i)) { > temp_sync(s, ts, o_allocated_regs, 0, IS_DEAD_ARG(i)); > } else if (IS_DEAD_ARG(i)) { > @@ -3674,26 +3670,23 @@ static void tcg_reg_alloc_call(TCGContext *s, TCG= Op *op) > for(i =3D 0; i < nb_oargs; i++) { > arg =3D op->args[i]; > ts =3D arg_temp(arg); > + > + /* ENV should not be modified. */ > + tcg_debug_assert(!ts->fixed_reg); > + > reg =3D tcg_target_call_oarg_regs[i]; > tcg_debug_assert(s->reg_to_temp[reg] =3D=3D NULL); > - > - if (ts->fixed_reg) { > - if (ts->reg !=3D reg) { > - tcg_out_mov(s, ts->type, ts->reg, reg); > - } > - } else { > - if (ts->val_type =3D=3D TEMP_VAL_REG) { > - s->reg_to_temp[ts->reg] =3D NULL; > - } > - ts->val_type =3D TEMP_VAL_REG; > - ts->reg =3D reg; > - ts->mem_coherent =3D 0; > - s->reg_to_temp[reg] =3D ts; > - if (NEED_SYNC_ARG(i)) { > - temp_sync(s, ts, allocated_regs, 0, IS_DEAD_ARG(i)); > - } else if (IS_DEAD_ARG(i)) { > - temp_dead(s, ts); > - } > + if (ts->val_type =3D=3D TEMP_VAL_REG) { > + s->reg_to_temp[ts->reg] =3D NULL; > + } > + ts->val_type =3D TEMP_VAL_REG; > + ts->reg =3D reg; > + ts->mem_coherent =3D 0; > + s->reg_to_temp[reg] =3D ts; > + if (NEED_SYNC_ARG(i)) { > + temp_sync(s, ts, allocated_regs, 0, IS_DEAD_ARG(i)); > + } else if (IS_DEAD_ARG(i)) { > + temp_dead(s, ts); > } > } > } -- Alex Benn=C3=A9e