[Mono-dev] [PATCH]: Fix double-insn emit bug on Sparc.

Zoltan Varga vargaz at gmail.com
Mon Nov 12 19:00:48 EST 2007


Hey,

This patch is now in SVN.

    Zoltan

On Nov 13, 2007 12:46 AM, David Miller <davem at davemloft.net> wrote:
>
> While rewriting the instruction list handling I discovered
> some cases on the sparc instruction selecter that would
> accidently emit an instruction twice.
>
> This worked silently because these instructions nearly always appear
> at the begininng of a basic block and by accident a double emit of the
> first instruction works because of the existing instruction list
> implementation.
>
> I audited other code for similar cases of the form:
>
>         MONO_EMIT_* (X, Y ...
>         mono_bblock_add_inst(X->cbb, Y);
>
> but could not find any.  It's worth a second check if someone
> is so inclined.
>
> 2007-11-12  David S. Miller  <davem at davemloft.net>
>
>         * inssel-sparc.brg: Fix double instruction emit.
>
> --- mono/mini/inssel-sparc.brg  (revision 89301)
> +++ mono/mini/inssel-sparc.brg  (working copy)
> @@ -570,13 +570,11 @@
>  stmt: CEE_STIND_I4 (OP_REGVAR, CEE_LDIND_I4(base)) {
>         MONO_EMIT_LOAD_MEMBASE (s, tree, state->left->tree->dreg, state->right->left->tree->inst_basereg,
>                                 state->right->left->tree->inst_offset);
> -       mono_bblock_add_inst (s->cbb, tree);
>  }
>
>  stmt: CEE_STIND_REF (OP_REGVAR, CEE_LDIND_REF(base)) {
>         MONO_EMIT_LOAD_MEMBASE (s, tree, state->left->tree->dreg, state->right->left->tree->inst_basereg,
>                                 state->right->left->tree->inst_offset);
> -       mono_bblock_add_inst (s->cbb, tree);
>  }
>
>  stmt: OP_SETRET (CEE_LDIND_I1(base)),
> @@ -589,7 +587,6 @@
>  stmt: OP_SETRET (CEE_LDIND_U4(base)) {
>         MONO_EMIT_LOAD_MEMBASE_OP (s, tree, ldind_to_load_membase (state->left->tree->opcode),
>                 sparc_i0, state->left->left->tree->inst_basereg, state->left->left->tree->inst_offset);
> -       mono_bblock_add_inst (s->cbb, tree);
>  }
>
>  stmt: OP_SETRET (CEE_LDIND_I4(OP_REGVAR)) {
> @@ -624,7 +621,6 @@
>         int dreg = mono_regstate_next_int (s->rs);
>         MONO_EMIT_LOAD_MEMBASE (s, tree, dreg, state->left->left->tree->inst_basereg,
>                                 state->left->left->tree->inst_offset);
> -       mono_bblock_add_inst (s->cbb, tree);
>
>         mono_call_inst_add_outarg_reg (s, call, dreg, tree->backend.reg3, FALSE);
>  }
> @@ -635,7 +631,6 @@
>         int dreg = mono_regstate_next_int (s->rs);
>         MONO_EMIT_LOAD_MEMBASE_OP (s, tree, OP_LOADI4_MEMBASE, dreg, state->left->left->tree->inst_basereg,
>                                 state->left->left->tree->inst_offset);
> -       mono_bblock_add_inst (s->cbb, tree);
>
>         mono_call_inst_add_outarg_reg (s, call, dreg, tree->backend.reg3, FALSE);
>  }
> @@ -647,8 +642,8 @@
>                 tree->opcode = OP_MOVE;
>                 tree->sreg1 = state->left->tree->inst_basereg;
>                 tree->dreg = state->reg1;
> +               mono_bblock_add_inst (s->cbb, tree);
>         }
> -       mono_bblock_add_inst (s->cbb, tree);
>  }
>
>  lreg: OP_LNEG (lreg) "3" {
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>



More information about the Mono-devel-list mailing list