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 B228A93AB2B; Wed, 10 Jan 2024 11:58:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B228A93AB2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1704877118; bh=O4snnHGTUyfrqcSsXJie/I6JAp4+PIQcx2j2VX4YvEk=; 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=qGrM0WeBqxOpKplu54qTsFk52VMbdl8MwWdkhb3i8PFsfTyE6lpGWxzl5wwoubomq pHPk0QTpUvvI/jZf1Jgc74Beipmb2sboHxDWlOcRlFY2MvDIY8E4useHGMcMZrGLhK ziqISZi5EYu7ej1buPET2YPPmFNSnSDQxlR81neg= Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [95.163.41.87]) (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 D7FA693AB2B for ; Wed, 10 Jan 2024 11:57:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D7FA693AB2B Received: by smtp51.i.mail.ru with esmtpa (envelope-from ) id 1rNUPN-000cf9-0C; Wed, 10 Jan 2024 11:57:57 +0300 Date: Wed, 10 Jan 2024 08:51:51 +0000 To: Sergey Kaplun Message-ID: References: <20231128122112.16229-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231128122112.16229-1-skaplun@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9F008C97756F746CA8E02FB725DB7BE58AC4BA3EACCC2FC76182A05F538085040B182C535B7828AF0F16F671ECE6D1131436A34F56B14AD02E67D7CA7B4523638 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B264C8851FD8E810EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063769AE3176B9E099158638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D85208BBB9A698871B2AD912E1D56C27BB117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC3A703B70628EAD7BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEB28585415E75ADA9FCE65BE3358055BDD8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE3A816C540FC8EEC3003F1AB874ED89028C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947C1D471462564A2E192E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F616AD31D0D18CD5C156CCFE7AF13BCA4B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A55EC5D60B4D8B6750CD729382A5988D1F096BB258E19250E2F87CCE6106E1FC07E67D4AC08A07B9B0AD0E433DBF1FBFA3CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D343D50AEDB859DBAD9BB239ABA2F2A98CEB601D532A17048E814120C828EA2E6F94FA6C01AD2317A0E1D7E09C32AA3244C6D0FDD054CEE423327080331DF98F4FE95A9E0DC41E9A4CFBAD658CF5C8AB4025DA084F8E80FEBD376A4ED3E9341DC2FCD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojou3Ii6fsdvVV5UtaI5r4FA== X-Mailru-Sender: 2FEBA92C8E508479FE7B9A1DF348D531DF9CEB243B21FD9092D9F91532709FF48D41AC28E4E323C42326FE6F2A341ACE0FB9F97486540B4CD9E8847AB8CFED4D9ABF8A61C016C2CFB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Prevent CSE of a REF_BASE operand across IR_RETF. 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, I've checked the patchset into all long-term branches in tarantool/luajit and bumped a new version in master, release/2.11 and release/2.10. On 28.11.23, Sergey Kaplun via Tarantool-patches wrote: > From: Mike Pall > > Reported by XmiliaH. > > (cherry-picked from commit e73916d811710ab02a4dfe447d621c99f4e7186c) > > The RETF IR has a side effect: it shifts base when returning to a lower > frame, i.e., it affects `REF_BASE` IR (0000) (thus, we can say that this > IR is violating SSA form). So any optimization of IRs with `REF_BASE` as > an operand across RETF IR may lead to incorrect optimizations (see > details in the test file). > > This patch adds rules to the folding engine to prevent CSE across `IR_RETF` > for all possible IRs containing REF_BASE. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#9145 > --- > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-784-cse-ref-base-over-retf > Tarantool PR: https://github.com/tarantool/tarantool/pull/9421 > Related issues: > * https://github.com/LuaJIT/LuaJIT/issues/784 > * https://github.com/tarantool/tarantool/issues/9145 > > Interested reviewers can mention that only the `SUB any BASE` case is > tested. > The reason is that other cases are impossible to record in LuaJIT: > * EQ any BASE: EQ pgc REF_BASE IR for upvalues is emitted when > the open upvalue aliases a SSA slot, i.e., it belongs to the frame of > the currently executed function. In that case, if we want to emit RETF > IR, we need to leave this function. So we need to record the UCLO > bytecode, which is NIY in JIT. So, such a type of trace is impossible. > * SUB BASE any: SUB BASE fr is emitted for the recording of VARG > bytecode, in case varargs are undefined on trace. We need a vararg > function to call to create an additional frame. But returning to lower > frames from a vararg function isn't implemented in LuaJIT -- either > the trace recording is stopped or the error is rased and the trace > isn't compiled. Also, IINM, fr operands will always be different for > different frames, so there is no possible CSE here. > > So, these cases are needed to prevent any regressions in the future. > > Please correct me if I've missed something. > > src/lj_opt_fold.c | 11 +++ > .../lj-784-cse-ref-base-over-retf.test.lua | 86 +++++++++++++++++++ > 2 files changed, 97 insertions(+) > create mode 100644 test/tarantool-tests/lj-784-cse-ref-base-over-retf.test.lua > > -- > 2.42.1 > -- Best regards, IM