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 CD1FD1519BCC; Thu, 18 Sep 2025 16:54:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CD1FD1519BCC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1758203684; bh=jwIx4nXVB8DRLwNym/zSDnA3vZVMuBlYjeFDZFxL7g8=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ClGEuIW4l/8ReKlZ1X9smnrTmeKDfVHURlvvDRXt+OgScOuTlckLJEYUQT78F4FrY t3hLEbSIQMxS3Yedzf/bJ5Sx+8OyinDUSiA0QrF8/PLOrfNka6G7n8vXMrWh3Lpj4O 1JZy2tGjTtVFYmIM7CWPASkxnKWLSokTg9W4lDF8= Received: from send264.i.mail.ru (send264.i.mail.ru [95.163.59.103]) (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 AFF7A58752D for ; Thu, 18 Sep 2025 16:54:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AFF7A58752D Received: by exim-smtp-648cc8c6cc-khnhs with esmtpa (envelope-from ) id 1uzF5t-00000000QXu-3BNy; Thu, 18 Sep 2025 16:54:42 +0300 To: Sergey Bronnikov Date: Thu, 18 Sep 2025 16:55:35 +0300 Message-ID: <20250918135535.22756-1-skaplun@tarantool.org> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9DB4A046F746C73F1FDB10792A35A4DD99521849FA6D3CD4F182A05F538085040E206928938DD270B3DE06ABAFEAF67052934871F118462BC20848BAC8AA4A9DE58F334736D7A8F2F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE751DD1FEBB966604DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB553375660434B977B7E22810A2EA72BE0857D8DE3DA6C94177B04D63C716C072330B5991389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C08794E14F7ADDB10D8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B625DC386152A6764ACC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE75A9E79F66F1C28F3731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A500BE77118A8F23085002B1117B3ED6969C4151A948DFE443715D9AB585B0EB04823CB91A9FED034534781492E4B8EEAD2F8D89FC5850081EC79554A2A72441328621D336A7BC284946AD531847A6065A17B107DEF921CE79BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742DC8270968E61249B1004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D341B5517184E88C1BD288FF446D509F26CE01AD81886F57DDAB724759B892FC1686C51A7DF57976A251D7E09C32AA3244C3BD9D2F300F0361277DD89D51EBB7742734959A15080CBFFEA455F16B58544A2557BDE0DD54B3590A5AE236DF995FB59829709634694AABAED6A17656DB59BCAD427812AF56FC65B X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVd2LZJfJwXSdvlp1DcRfkzw= X-DA7885C5: F53CF0A36475491EF255D290C0D534F93C4853FE89B49DD120C1F61D1F20651582621F331AA126265B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393FE9E42A757851DB61E6C498AF87A80F2D9FEC7CB5315E63DFC7DDE49C197E366E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit] ARM64: Fix assembly of HREFK (again). 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 Thanks to Peter Cawley. (cherry picked from commit 93ce12ee15abf28ef4cb24ae7e4b8a5b73d75c85) When assembling the HREFK IR with the huge offset of the target node from the table, this offset calculation and the key loading from the node are emitted like the following: | ldr x16, [x2, 40] | add x16, x16, x21 | ldr x27, [x16, 8] | cmp x27, x17 Here, `x16` is the node register, `x27` is the key register, and `x21` is the register containing the offset. It is possible that the register for holding the constant operand in the addition may be chosen as the same register containing the node address, since the full `RSET_GPR` is given to the `emit_opk()`. It will result in the following invalid mcode: | ldr x27, [x2, 40] | str x27, [sp, 8] | add x16, x16, x16 | ldr x16, [sp, 8] | ldr x27, [x16, 8] | cmp x27, x17 It seems that in the current implementation the LuaJIT's register allocator always prefers the register holding the key instead, so this does not lead to the invalid emitting. Hence, it is impossible to come up with any valid reproducer. However, to avoid possible regressions in the future, this patch fixes the invalid register set by excluding the node register from it. Sergey Kaplun: * added the description for the problem Part of tarantool/tarantool#11691 --- Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1026-fix-ra-hrefk Related issues: * https://github.com/tarantool/tarantool/issues/11691 * https://github.com/LuaJIT/LuaJIT/issues/1026 The issue isn't reproduced even with the RANDOM_RA, so I suppose we may apply the patch without a test case. src/lj_asm_arm64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lj_asm_arm64.h b/src/lj_asm_arm64.h index 9b3c0467..313b4a96 100644 --- a/src/lj_asm_arm64.h +++ b/src/lj_asm_arm64.h @@ -911,7 +911,7 @@ static void asm_hrefk(ASMState *as, IRIns *ir) emit_nm(as, A64I_CMPx, key, ra_allock(as, k, rset_exclude(allow, key))); emit_lso(as, A64I_LDRx, key, idx, kofs); if (bigofs) - emit_opk(as, A64I_ADDx, dest, node, ofs, RSET_GPR); + emit_opk(as, A64I_ADDx, dest, node, ofs, rset_exclude(RSET_GPR, node)); } static void asm_uref(ASMState *as, IRIns *ir) -- 2.51.0