From 3ecf00a78c074d8fe5eb5c28da249b8510cab529 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 29 Sep 2026 16:07:36 +0200 Subject: [PATCH] Fix MSVC shift warnings in IR vector bounds checks Make the conversion of IR_VECTOR_LENGTH to int64_t explicit in the REPLACE and EXTRACT folding rules. The vector length fits in 32 bits, but MSVC warns when its shifted value is implicitly widened for comparison (C4334), breaking builds with /WX. Keep the fix as a bundled-source patch so the IR import remains reproducible. --- .github/scripts/download-bundled/jit-ir.patch | 22 +++++++++++++++++++ .github/scripts/download-bundled/jit-ir.sh | 3 +++ ext/opcache/jit/ir/ir_fold.h | 4 ++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .github/scripts/download-bundled/jit-ir.patch diff --git a/.github/scripts/download-bundled/jit-ir.patch b/.github/scripts/download-bundled/jit-ir.patch new file mode 100644 index 000000000000..6814cb162111 --- /dev/null +++ b/.github/scripts/download-bundled/jit-ir.patch @@ -0,0 +1,22 @@ +diff --git a/ext/opcache/jit/ir/ir_fold.h b/ext/opcache/jit/ir/ir_fold.h +index c5fd2f28894..fae3b4b4655 100644 +--- a/ext/opcache/jit/ir/ir_fold.h ++++ b/ext/opcache/jit/ir/ir_fold.h +@@ -1841,7 +1841,7 @@ IR_FOLD(REPLACE(LONG_CONST, _)) + && IR_IS_CONST_REF(op2) + && IR_IS_TYPE_INT(op2_insn->type) + && op2_insn->val.i64 >= 0 +- && op2_insn->val.i64 < IR_VECTOR_LENGTH(op1_insn->type)) { ++ && op2_insn->val.i64 < (int64_t)IR_VECTOR_LENGTH(op1_insn->type)) { + IR_ASSERT(IR_IS_TYPE_VECTOR(op1_insn->type) + && (IR_VECTOR_BASE_TYPE(op1_insn->type) == op3_insn->type + || (IR_IS_TYPE_INT(IR_VECTOR_BASE_TYPE(op1_insn->type)) +@@ -1943,7 +1943,7 @@ IR_FOLD(EXTRACT(LONG_CONST, _)) + if (IR_IS_CONST_REF(op2) + && IR_IS_TYPE_INT(op2_insn->type) + && op2_insn->val.i64 >= 0 +- && op2_insn->val.i64 < IR_VECTOR_LENGTH(op1_insn->type)) { ++ && op2_insn->val.i64 < (int64_t)IR_VECTOR_LENGTH(op1_insn->type)) { + uint32_t idx = op2_insn->val.u32; + void *ptr; + diff --git a/.github/scripts/download-bundled/jit-ir.sh b/.github/scripts/download-bundled/jit-ir.sh index fed7a9938d21..e1eae8eb8fa0 100755 --- a/.github/scripts/download-bundled/jit-ir.sh +++ b/.github/scripts/download-bundled/jit-ir.sh @@ -35,3 +35,6 @@ rm ir_mem2ssa.c # add extra files git restore README + +# patch customized files +git apply -v ../../../../.github/scripts/download-bundled/jit-ir.patch diff --git a/ext/opcache/jit/ir/ir_fold.h b/ext/opcache/jit/ir/ir_fold.h index c5fd2f288947..fae3b4b46552 100644 --- a/ext/opcache/jit/ir/ir_fold.h +++ b/ext/opcache/jit/ir/ir_fold.h @@ -1841,7 +1841,7 @@ IR_FOLD(REPLACE(LONG_CONST, _)) && IR_IS_CONST_REF(op2) && IR_IS_TYPE_INT(op2_insn->type) && op2_insn->val.i64 >= 0 - && op2_insn->val.i64 < IR_VECTOR_LENGTH(op1_insn->type)) { + && op2_insn->val.i64 < (int64_t)IR_VECTOR_LENGTH(op1_insn->type)) { IR_ASSERT(IR_IS_TYPE_VECTOR(op1_insn->type) && (IR_VECTOR_BASE_TYPE(op1_insn->type) == op3_insn->type || (IR_IS_TYPE_INT(IR_VECTOR_BASE_TYPE(op1_insn->type)) @@ -1943,7 +1943,7 @@ IR_FOLD(EXTRACT(LONG_CONST, _)) if (IR_IS_CONST_REF(op2) && IR_IS_TYPE_INT(op2_insn->type) && op2_insn->val.i64 >= 0 - && op2_insn->val.i64 < IR_VECTOR_LENGTH(op1_insn->type)) { + && op2_insn->val.i64 < (int64_t)IR_VECTOR_LENGTH(op1_insn->type)) { uint32_t idx = op2_insn->val.u32; void *ptr;