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 78E1AC134E6; Sun, 26 May 2024 12:36:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 78E1AC134E6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1716716204; bh=vCESNNi/MAm3vIXJYJPE1XwXAjTVoOYRE6UWFdlu6DU=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=y137ryPDkxB74tQW2fF6v3B2HDQvQ6SlP6t8RFcjEfOliknaL7qfnJ0bT8mPcVHZ/ aXz1KY9n3njJS/tZjLMtbiSrjm+YP+dO6Qj/EZScRsTsPk11Z7nbbCpIYJ4UUPA9tK QRnOhPwD/FGizl/+nkv7DEOlZSkQXg6HjpahnbrI= Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [95.163.41.89]) (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 1EDBC537CC0 for ; Sun, 26 May 2024 12:36:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1EDBC537CC0 Received: by smtp54.i.mail.ru with esmtpa (envelope-from ) id 1sBAIz-0000000CtjS-3qyB; Sun, 26 May 2024 12:36:42 +0300 Date: Sun, 26 May 2024 12:36:40 +0300 To: Sergey Kaplun Message-ID: References: <20240517132918.25926-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240517132918.25926-1-skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD92D983CBBFCCE46A6ACC269A17C3537C7FA4B0CD4230405D01313CFAB8367EF908E2BE116634AD74DB5C4F57A6D9AF2020771F2AEDB3B3FF7401B197E4163ACB2481785AF359FF013F253FDB7F52A2E4C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79961E86438F5BDAEEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C83F54BD885518138638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D858C16193BE6EA7F900C0BA8BBB556486DC91F767421DB77CCC7F00164DA146DAFE8445B8C89999728AA50765F790063793270F7220657A0A389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC821E93C0F2A571C7BF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947CD95D32202655EC452D242C3BD2E3F4C64AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3F820309483B11D81BA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CFED8438A78DFE0A9E1DD303D21008E298D5E8D9A59859A8B6957A4DEDD2346B4275ECD9A6C639B01B78DA827A17800CE7017391A6434C59DB731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5DABA87657476DDFC5002B1117B3ED6969FF311F0DD2C1FCD406406D89DD9EB8A823CB91A9FED034534781492E4B8EEADC24E78AA85F86F6CBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D343FB425EC7F4D4A4B315DF4C9C265DC3A54D96FBDC085C48E5909A15CBDB2DC63FD37DC69EE7AB1261D7E09C32AA3244C15178411992835804EB7DF677E51682D2B070DDF069A6076EA455F16B58544A2557BDE0DD54B3590965026E5D17F6739C77C69D99B9914278E50E1F0597A6FD5CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnJlDmFYFlmFvCDliTd4pRg== X-Mailru-Sender: 00097D31F91C944B27477D5EE6B524EB8FE7A5DA7CEFBB3A04DE63E6493D4605595A7C55E1ADC8BF9C25F03E2EE9BBC9D51284F0FE6F529ABC7555A253F5B200DF104D74F62EE79D27EC13EC74F6107F4198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Maintain chain invariant in DCE. 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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the patch! Please consider my comments below. On Fri, May 17, 2024 at 04:29:18PM UTC, Sergey Kaplun wrote: > From: Mike Pall > > Thanks to Peter Cawley. > > (cherry picked from commit f72c19e482b6f918b7cf42b0436e2b117d160a29) > > Instructions with strong guards that are sometimes emitted with a guard > and sometimes emitted without a guard (like HREFK, CONV, or SLOAD) may > be eliminated from the IR chain and replaced with the NOP IR. If the > next IR of the same kind on the trace is not eliminated, it may > reference the IR NOP instead of an instruction of the same type. This > may lead to the corresponding assertion failure in the `rec_check_ir()`. > > This patch unconditionally links the IRs during chain maintenance in > DCE. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#9924 > --- > > Be aware that the reproducer from the ticket does not lead to the > assertion failure (this is why it is omitted in the test). I suppose it > just illustrates the situation when the IR is left off the chain. > Although the reproducer is clumsy, I can't simplify it or make it less > tricky. Please, ideas are welcome :). The test doesn't reproduce before the patch on ARM64. Tested on M1 with the following flags: | -DCMAKE_BUILD_TYPE=Debug -DLUA_USE_ASSERT=ON \ | -DLUAJIT_ENABLE_CHECKHOOK=ON` > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1094-ir-chain-dce > Related Issues: > * https://github.com/tarantool/tarantool/issues/9924 > * https://github.com/LuaJIT/LuaJIT/issues/1094 > > src/lj_opt_dce.c | 2 +- > .../lj-1094-ir-chain-dce.test.lua | 51 +++++++++++++++++++ > 2 files changed, 52 insertions(+), 1 deletion(-) > create mode 100644 test/tarantool-tests/lj-1094-ir-chain-dce.test.lua > > diff --git a/src/lj_opt_dce.c b/src/lj_opt_dce.c > index 2417f324..6948179c 100644 > --- a/src/lj_opt_dce.c > +++ b/src/lj_opt_dce.c > @@ -44,7 +44,6 @@ static void dce_propagate(jit_State *J) > IRIns *ir = IR(ins); > if (irt_ismarked(ir->t)) { > irt_clearmark(ir->t); > - pchain[ir->o] = &ir->prev; > } else if (!ir_sideeff(ir)) { > *pchain[ir->o] = ir->prev; /* Reroute original instruction chain. */ > ir->t.irt = IRT_NIL; > @@ -53,6 +52,7 @@ static void dce_propagate(jit_State *J) > ir->prev = 0; > continue; > } > + pchain[ir->o] = &ir->prev; > if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); > if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); > } > diff --git a/test/tarantool-tests/lj-1094-ir-chain-dce.test.lua b/test/tarantool-tests/lj-1094-ir-chain-dce.test.lua > new file mode 100644 > index 00000000..3faae7d4 > --- /dev/null > +++ b/test/tarantool-tests/lj-1094-ir-chain-dce.test.lua