From e2551375e0093b8e24821a316edf42c6ff2d7ac7 Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Sun, 11 Jan 2026 12:44:25 +1300 Subject: [PATCH v2 3/3] jit: Fix integer constants for LLVM 22. LLVM 22 fails an assertion where we do: l_int8_const(lc, 1 << ((attnum) & 0x07)) Assertion failed: (llvm::isUIntN(BitWidth, val) && "Value is not an N-bit unsigned value") That's because it no longer truncates values to fit the type[1]. Unfortunately our l_intN_const() wrapper functions take signed intN_t arguments that are internally coerced to unsigned long long, triggering sign extension. That was OK with automatic truncation, but now it fails a bit-width test. Cast to the corresponding unsigned type first to avoid that. [1] https://github.com/llvm/llvm-project/commit/a83c89495ba6fe0134dcaa02372c320cc7ff0dbf Backpatch-through: 14 Reviewed-by: Discussion: https://postgr.es/m/CA%2BhUKGJTumad75o8Zao-LFseEbt%3DenbUFCM7LZVV%3Dc8yg2i7dg%40mail.gmail.com --- src/include/jit/llvmjit_emit.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/include/jit/llvmjit_emit.h b/src/include/jit/llvmjit_emit.h index 089945391ee..83b67dffd25 100644 --- a/src/include/jit/llvmjit_emit.h +++ b/src/include/jit/llvmjit_emit.h @@ -47,7 +47,7 @@ l_ptr(LLVMTypeRef t) static inline LLVMValueRef l_int8_const(LLVMContextRef lc, int8 i) { - return LLVMConstInt(LLVMInt8TypeInContext(lc), i, false); + return LLVMConstInt(LLVMInt8TypeInContext(lc), (uint8) i, false); } /* @@ -56,7 +56,7 @@ l_int8_const(LLVMContextRef lc, int8 i) static inline LLVMValueRef l_int16_const(LLVMContextRef lc, int16 i) { - return LLVMConstInt(LLVMInt16TypeInContext(lc), i, false); + return LLVMConstInt(LLVMInt16TypeInContext(lc), (uint16) i, false); } /* @@ -65,7 +65,7 @@ l_int16_const(LLVMContextRef lc, int16 i) static inline LLVMValueRef l_int32_const(LLVMContextRef lc, int32 i) { - return LLVMConstInt(LLVMInt32TypeInContext(lc), i, false); + return LLVMConstInt(LLVMInt32TypeInContext(lc), (uint32) i, false); } /* @@ -74,7 +74,7 @@ l_int32_const(LLVMContextRef lc, int32 i) static inline LLVMValueRef l_int64_const(LLVMContextRef lc, int64 i) { - return LLVMConstInt(LLVMInt64TypeInContext(lc), i, false); + return LLVMConstInt(LLVMInt64TypeInContext(lc), (uint64) i, false); } /* -- 2.52.0