]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Ensure full init of IR_NOP instructions.
authorMike Pall <mike>
Mon, 12 Oct 2020 13:40:28 +0000 (15:40 +0200)
committerMike Pall <mike>
Mon, 12 Oct 2020 13:40:28 +0000 (15:40 +0200)
src/lj_asm.c
src/lj_ir.h
src/lj_opt_dce.c
src/lj_opt_mem.c

index 9b17421e927ce94c08c3f7712e67cc7371b51de3..60be4337d15117329169e49f63a58a0805852887 100644 (file)
@@ -1833,7 +1833,7 @@ void lj_asm_trace(jit_State *J, GCtrace *T)
 
   /* Ensure an initialized instruction beyond the last one for HIOP checks. */
   J->cur.nins = lj_ir_nextins(J);
-  J->cur.ir[J->cur.nins].o = IR_NOP;
+  lj_ir_nop(&J->cur.ir[J->cur.nins]);
 
   /* Setup initial state. Copy some fields to reduce indirections. */
   as->J = J;
index 3a154a053924142c0cc5e48742819d9ee9a87d42..ac51dc792c5891086373fd181d75d524340177e6 100644 (file)
@@ -548,4 +548,12 @@ static LJ_AINLINE int ir_sideeff(IRIns *ir)
 
 LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W);
 
+/* Replace IR instruction with NOP. */
+static LJ_AINLINE void lj_ir_nop(IRIns *ir)
+{
+  ir->ot = IRT(IR_NOP, IRT_NIL);
+  ir->op1 = ir->op2 = 0;
+  ir->prev = 0;
+}
+
 #endif
index a1df91ddcf01a56bc5dd5f432603bc945f1767a1..31e5badddffac286792a77ac32a9bce84f6662ef 100644 (file)
@@ -47,10 +47,7 @@ static void dce_propagate(jit_State *J)
       pchain[ir->o] = &ir->prev;
     } else if (!ir_sideeff(ir)) {
       *pchain[ir->o] = ir->prev;  /* Reroute original instruction chain. */
-      ir->t.irt = IRT_NIL;
-      ir->o = IR_NOP;  /* Replace instruction with NOP. */
-      ir->op1 = ir->op2 = 0;
-      ir->prev = 0;
+      lj_ir_nop(ir);
       continue;
     }
     if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t);
index 281f29ad6d022ec3867a72c75f427603e53e90b0..5659a056a343a2f47668eb3105e70b9e81ff00e8 100644 (file)
@@ -352,10 +352,7 @@ TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J)
            goto doemit;  /* No elimination possible. */
        /* Remove redundant store from chain and replace with NOP. */
        *refp = store->prev;
-       store->o = IR_NOP;
-       store->t.irt = IRT_NIL;
-       store->op1 = store->op2 = 0;
-       store->prev = 0;
+       lj_ir_nop(store);
        /* Now emit the new store instead. */
       }
       goto doemit;
@@ -456,10 +453,7 @@ TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J)
            goto doemit;  /* No elimination possible. */
        /* Remove redundant store from chain and replace with NOP. */
        *refp = store->prev;
-       store->o = IR_NOP;
-       store->t.irt = IRT_NIL;
-       store->op1 = store->op2 = 0;
-       store->prev = 0;
+       lj_ir_nop(store);
        if (ref+1 < J->cur.nins &&
            store[1].o == IR_OBAR && store[1].op1 == xref) {
          IRRef1 *bp = &J->chain[IR_OBAR];
@@ -468,10 +462,7 @@ TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J)
            bp = &obar->prev;
          /* Remove OBAR, too. */
          *bp = obar->prev;
-         obar->o = IR_NOP;
-         obar->t.irt = IRT_NIL;
-         obar->op1 = obar->op2 = 0;
-         obar->prev = 0;
+         lj_ir_nop(obar);
        }
        /* Now emit the new store instead. */
       }
@@ -562,10 +553,7 @@ TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J)
            goto doemit;  /* No elimination possible. */
        /* Remove redundant store from chain and replace with NOP. */
        *refp = store->prev;
-       store->o = IR_NOP;
-       store->t.irt = IRT_NIL;
-       store->op1 = store->op2 = 0;
-       store->prev = 0;
+       lj_ir_nop(store);
        /* Now emit the new store instead. */
       }
       goto doemit;
@@ -816,10 +804,7 @@ TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J)
            goto doemit;  /* No elimination possible. */
        /* Remove redundant store from chain and replace with NOP. */
        *refp = store->prev;
-       store->o = IR_NOP;
-       store->t.irt = IRT_NIL;
-       store->op1 = store->op2 = 0;
-       store->prev = 0;
+       lj_ir_nop(store);
        /* Now emit the new store instead. */
       }
       goto doemit;