From 83e37220cc3e8cb04b0d8a608240fdde4b003713 Mon Sep 17 00:00:00 2001 From: Dmitrii Dolgov <9erthalion6@gmail.com> Date: Sat, 30 Mar 2024 17:45:38 +0100 Subject: [PATCH v1] Workaround for deform crashing in LLVM inliner Deform function returns via the outblock that contains a "ret void" instruction build with LLVMBuildRetVoid. This triggers a bug in the latest LLVM 18.1, when the inliner pass is applied to the function [1]. Avoid the issue via introducing a fake return variable, which will be ignored on the call site. [1]: https://github.com/llvm/llvm-project/issues/86162 --- src/backend/jit/llvm/llvmjit_deform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/jit/llvm/llvmjit_deform.c b/src/backend/jit/llvm/llvmjit_deform.c index b07f8e7f756..7ebc7b6d731 100644 --- a/src/backend/jit/llvm/llvmjit_deform.c +++ b/src/backend/jit/llvm/llvmjit_deform.c @@ -761,6 +761,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, { LLVMValueRef v_off = l_load(b, TypeSizeT, v_offp, ""); LLVMValueRef v_flags; + LLVMValueRef v_fake_ret = l_sizet_const(0); LLVMBuildStore(b, l_int16_const(lc, natts), v_nvalidp); v_off = LLVMBuildTrunc(b, v_off, LLVMInt32TypeInContext(lc), ""); @@ -768,7 +769,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, v_flags = l_load(b, LLVMInt16TypeInContext(lc), v_flagsp, "tts_flags"); v_flags = LLVMBuildOr(b, v_flags, l_int16_const(lc, TTS_FLAG_SLOW), ""); LLVMBuildStore(b, v_flags, v_flagsp); - LLVMBuildRetVoid(b); + LLVMBuildRet(b, v_fake_ret); } LLVMDisposeBuilder(b); base-commit: 7eb9a8201890f3b208fd4c109a5b08bf139b692a -- 2.41.0