Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBb3n-00BTrK-CF for pgsql-committers@arkaria.postgresql.org; Fri, 08 Dec 2023 13:38:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rBb3j-0088Pg-Hy for pgsql-committers@arkaria.postgresql.org; Fri, 08 Dec 2023 13:38:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBb3j-0088PY-AZ for pgsql-committers@lists.postgresql.org; Fri, 08 Dec 2023 13:38:27 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBb3h-00Anus-2F for pgsql-committers@lists.postgresql.org; Fri, 08 Dec 2023 13:38:26 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id CED432FD3F01 for ; Fri, 8 Dec 2023 14:38:23 +0100 (CET) Received: from s899.loopia.se (unknown [172.22.191.6]) by s807.loopia.se (Postfix) with ESMTP id BF7532E27650; Fri, 8 Dec 2023 14:38:23 +0100 (CET) Received: from s471.loopia.se (unknown [172.22.191.6]) by s899.loopia.se (Postfix) with ESMTP id BD47A2C8BB08; Fri, 8 Dec 2023 14:38:23 +0100 (CET) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-1 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1] autolearn=disabled Received: from s979.loopia.se ([172.22.191.5]) by s471.loopia.se (s471.loopia.se [172.22.190.35]) (amavisd-new, port 10024) with UTF8LMTP id QRGTycnyThSj; Fri, 8 Dec 2023 14:38:23 +0100 (CET) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.193 Received: from smtpclient.apple (customer-89-255-232-193.stosn.net [89.255.232.193]) (Authenticated sender: daniel@yesql.se) by s979.loopia.se (Postfix) with ESMTPSA id 640A210BC4D3; Fri, 8 Dec 2023 14:38:23 +0100 (CET) From: Daniel Gustafsson Message-Id: <82CD6B67-1B7C-4D4B-9533-A94A2E4BC15B@yesql.se> Content-Type: multipart/mixed; boundary="Apple-Mail=_593D158B-D5E8-4A2D-BA4F-94B6CF8CA568" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\)) Subject: Re: pgsql: llvmjit: Use explicit LLVMContextRef for inlining Date: Fri, 8 Dec 2023 14:38:23 +0100 In-Reply-To: <3EF0CBF1-6460-4977-A62B-A9B58641175B@yesql.se> Cc: pgsql-committers@lists.postgresql.org, Andres Freund To: Tom Lane References: <1106876.1700409912@sss.pgh.pa.us> <3469A042-A3EB-4483-831D-0D8815D4EF41@yesql.se> <3EF0CBF1-6460-4977-A62B-A9B58641175B@yesql.se> X-Mailer: Apple Mail (2.3696.120.41.1.4) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_593D158B-D5E8-4A2D-BA4F-94B6CF8CA568 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On 20 Nov 2023, at 22:53, Daniel Gustafsson wrote: >=20 >> On 19 Nov 2023, at 21:08, Daniel Gustafsson wrote: >=20 >> I'll have a look with fresh eyes in the morning, and hopefully it = will be >> fixable. If it get's messy it's quite possible that skipping v12 is = the best >> option. >=20 > As an update, discussing with Andres off-list I have a potential patch = for > this, need to rebuild LLVM debug builds tomorrow to test further but = there > should be either a fix or a revert soon. After some more work with Andres, the bug was found to be a void pointer = not created in the referenced context. The attached diff fixes the issue = (which is related to code refactored in v13 hence why it only affects v12). I = will apply that to v12 shortly after a little more testing. -- Daniel Gustafsson --Apple-Mail=_593D158B-D5E8-4A2D-BA4F-94B6CF8CA568 Content-Disposition: attachment; filename=llvmcontext_v12_fix.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="llvmcontext_v12_fix.diff" Content-Transfer-Encoding: 7bit diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c index c25960a82b..f2cf2fadaa 100644 --- a/src/backend/jit/llvm/llvmjit_expr.c +++ b/src/backend/jit/llvm/llvmjit_expr.c @@ -2620,7 +2620,9 @@ build_EvalXFunc(LLVMBuilderRef b, LLVMModuleRef mod, const char *funcname, LLVMValueRef v_fn; LLVMTypeRef param_types[3]; LLVMValueRef params[3]; + LLVMContextRef lc; + lc = LLVMGetModuleContext(mod); v_fn = LLVMGetNamedFunction(mod, funcname); if (!v_fn) { @@ -2628,7 +2630,7 @@ build_EvalXFunc(LLVMBuilderRef b, LLVMModuleRef mod, const char *funcname, param_types[1] = l_ptr(StructExprEvalStep); param_types[2] = l_ptr(StructExprContext); - sig = LLVMFunctionType(LLVMVoidType(), + sig = LLVMFunctionType(LLVMVoidTypeInContext(lc), param_types, lengthof(param_types), false); v_fn = LLVMAddFunction(mod, funcname, sig); --Apple-Mail=_593D158B-D5E8-4A2D-BA4F-94B6CF8CA568--