From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 9BD12E4FB79; Wed, 11 Dec 2024 16:22:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9BD12E4FB79 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1733923356; bh=V74ft6N0qjXwcyGVkelVnzhvrlPrm9x+za/Wv/TX0hM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ce91GCBJKPlWf/9GJzahmPe3ZyxatUDC6+4NB80YDxvm8jUgzHUT28+A9KeVdIpAn Wbn5khxmMsX0qkKQesb82jS1L5AZybPXhxbw3MAa11+RPuTqww+rBNEDULhalmoFhW x5LS2lX/UKDHJDUyiuSOWzxni9py1BiZoFZCJbVA= Received: from send36.i.mail.ru (send36.i.mail.ru [89.221.237.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id CD06AE4FB69 for ; Wed, 11 Dec 2024 16:22:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CD06AE4FB69 Received: by exim-smtp-598667c6b5-5zbpn with esmtpa (envelope-from ) id 1tLMfF-00000000FHh-36GB; Wed, 11 Dec 2024 16:22:06 +0300 To: Maksim Tiushev , Sergey Bronnikov Date: Wed, 11 Dec 2024 16:21:06 +0300 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD9B739379E53DE7095F44A8798952A5D7CB75CC4C1E9611CFF182A05F53808504009008F35F8AD720F3DE06ABAFEAF6705C51E8C87CF8F4B7B3AAC8CF8E4B5DCE0CDF3F5685B32E1CC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE73227F968F005A01AEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B6B039AA0E19584A8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8F43AB649139ABBE61A41E4132FFF3FB83D8CD0C119D20F7ECC7F00164DA146DAFE8445B8C89999728AA50765F7900637F3E38EE449E3E2AE389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC821E93C0F2A571C7BF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE33AC447995A7AD182BEBFE083D3B9BA73A03B725D353964B2FFDA4F57982C5F435872C767BF85DA227C277FBC8AE2E8B9149C560DC76099D75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A55B2B431B2B9DE0595002B1117B3ED696D2E841A28943CD61406406D89DD9EB8A823CB91A9FED034534781492E4B8EEAD528DE7AA5F2BD788C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF88FCD311586225A2BC2B5A9938C1C1231791ECC2EDAE2AC9612D05D337847D05FD9AF20B71F72F3AA0626FDB23E8EA705B66990594C773AC1E1DEA007741E9D7F67AF58E3C716EF0C226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojlzf/Y03FLloIGTlFQjLsnA== X-DA7885C5: BEBD653C6BADC7C6F255D290C0D534F9E834B95405D4B9D4BEF1F646990283797D934456E88B99A05B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F739381B31377CF4CA21998E4A08ED36FC93C7C8D3F15B84920A0FDCC085B298A0548E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH v5 luajit 1/3] Ensure full init of IR_NOP instructions. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Mike Pall (cherry picked from commit de6b1a11dd1a3349179084578c5d533be1c30234) Before this patch, Valgrind produces tons of warnings during the VMevent calls since the `IR_NOP` instruction isn't fully initialized. Hence, any parsing operations for it in handlers during `jit.dump()` leads to the "uninitialised value" error. This patch fixes the issue by the proper init of such IRs. Sergey Kaplun: * added the description for the problem Needed for tarantool/tarantool#3705 Part of tarantool/tarantool#10709 --- src/lj_asm.c | 2 +- src/lj_ir.h | 8 ++++++++ src/lj_opt_dce.c | 5 +---- src/lj_opt_mem.c | 25 +++++-------------------- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/lj_asm.c b/src/lj_asm.c index 5137d05c..f7540165 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c @@ -2377,7 +2377,7 @@ void lj_asm_trace(jit_State *J, GCtrace *T) /* Ensure an initialized instruction beyond the last one for HIOP checks. */ /* This also allows one RENAME to be added without reallocating curfinal. */ as->orignins = lj_ir_nextins(J); - J->cur.ir[as->orignins].o = IR_NOP; + lj_ir_nop(&J->cur.ir[as->orignins]); /* Setup initial state. Copy some fields to reduce indirections. */ as->J = J; diff --git a/src/lj_ir.h b/src/lj_ir.h index 27c66f63..46e7413e 100644 --- a/src/lj_ir.h +++ b/src/lj_ir.h @@ -587,4 +587,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 diff --git a/src/lj_opt_dce.c b/src/lj_opt_dce.c index 6948179c..41e36d99 100644 --- a/src/lj_opt_dce.c +++ b/src/lj_opt_dce.c @@ -46,10 +46,7 @@ static void dce_propagate(jit_State *J) irt_clearmark(ir->t); } 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; } pchain[ir->o] = &ir->prev; diff --git a/src/lj_opt_mem.c b/src/lj_opt_mem.c index c9f1216c..a6e9a072 100644 --- a/src/lj_opt_mem.c +++ b/src/lj_opt_mem.c @@ -375,10 +375,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; @@ -479,10 +476,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]; @@ -491,10 +485,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. */ } @@ -585,10 +576,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; @@ -839,10 +827,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; -- 2.47.0