0001-jit-Fix-LLVM-back-patching-bug-in-12-and-13.patch

application/x-patch

Filename: 0001-jit-Fix-LLVM-back-patching-bug-in-12-and-13.patch
Type: application/x-patch
Part: 0
Message: Re: LLVM 16 (opaque pointers)

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0001
Subject: jit: Fix LLVM back-patching bug in 12 and 13.
File+
src/backend/jit/llvm/llvmjit_expr.c 1 1
From 52397f8c70641080f2487ee5f019f143dd35957c Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 22 Oct 2023 23:20:56 +0000
Subject: [PATCH] jit: Fix LLVM back-patching bug in 12 and 13.

While back-patching f90b4a84, I missed that branches before 14 did some
type punning in a function parameter.  That didn't cause any problem for
release builds of LLVM, but debug builds of some older versions would
fail a type cross-check assertion.  To fix this, we need to back-patch a
line of df99ddc7.

Per build farm animal xenodermus, which runs a debug build of LLVM 6
with jit_above_cost=0.

diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c
index d84fbba7cc..c2e367f00d 100644
--- a/src/backend/jit/llvm/llvmjit_expr.c
+++ b/src/backend/jit/llvm/llvmjit_expr.c
@@ -1126,7 +1126,7 @@ llvm_compile_expr(ExprState *state)
 										 llvm_pg_var_type("TypeExecEvalSubroutine"));
 
 					v_params[0] = v_state;
-					v_params[1] = l_ptr_const(op, l_ptr(TypeSizeT));
+					v_params[1] = l_ptr_const(op, l_ptr(StructExprEvalStep));
 					v_params[2] = v_econtext;
 					l_call(b,
 						   LLVMGetFunctionType(ExecEvalSubroutineTemplate),
-- 
2.42.0