From bcd8563ae2cb22055b523f5709de2fe369e78478 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Fri, 17 Apr 2026 16:33:37 +0000 Subject: [PATCH 1/4] Include `uop_optimize` only when not disabling the GIL. --- Python/optimizer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Python/optimizer.c b/Python/optimizer.c index 60f3e541be25cf..ba52ab3f31ca66 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -116,10 +116,12 @@ insert_executor(PyCodeObject *code, _Py_CODEUNIT *instr, int index, _PyExecutorO static _PyExecutorObject * make_executor_from_uops(_PyThreadStateImpl *tstate, _PyUOpInstruction *buffer, int length, const _PyBloomFilter *dependencies); +#ifndef Py_GIL_DISABLED static int uop_optimize(_PyInterpreterFrame *frame, PyThreadState *tstate, _PyExecutorObject **exec_ptr, bool progress_needed); +#endif /* Returns 1 if optimized, 0 if not optimized, and -1 for an error. * If optimized, *executor_ptr contains a new reference to the executor @@ -1526,6 +1528,7 @@ stack_allocate(_PyUOpInstruction *buffer, _PyUOpInstruction *output, int length) return (int)(write - output); } +#ifndef Py_GIL_DISABLED static int uop_optimize( _PyInterpreterFrame *frame, @@ -1606,6 +1609,7 @@ uop_optimize( *exec_ptr = executor; return 1; } +#endif /***************************************** From a32158f98e6527849db9a2f9bde036377fa3b0d1 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Fri, 17 Apr 2026 16:52:42 +0000 Subject: [PATCH 2/4] Mark `npending` in `update_eval_breaker_for_thread` as possibly unused. --- Python/ceval_gil.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/ceval_gil.c b/Python/ceval_gil.c index 2425bc1b39f0dc..c6f51c936866bf 100644 --- a/Python/ceval_gil.c +++ b/Python/ceval_gil.c @@ -78,6 +78,7 @@ update_eval_breaker_for_thread(PyInterpreterState *interp, PyThreadState *tstate return; #endif + Py_GCC_ATTRIBUTE((unused)) int32_t npending = _Py_atomic_load_int32_relaxed( &interp->ceval.pending.npending); if (npending) { From 896acf80c2a449c5c2f6e33240ead98d85aa86d6 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Fri, 17 Apr 2026 17:38:41 +0000 Subject: [PATCH 3/4] Supress unused variable warnings in generated executor_cases header --- Python/executor_cases.c.h | 12 ++++++++++++ Tools/cases_generator/stack.py | 5 ++++- Tools/cases_generator/tier2_generator.py | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 93d39bee1b9ff6..7d52cedc985c6c 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -17042,6 +17042,7 @@ _PyStackRef arg; _PyStackRef res; _PyStackRef a; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_0 = _tos_cache0; oparg = CURRENT_OPARG(); arg = _stack_item_0; @@ -17065,7 +17066,9 @@ _PyStackRef arg; _PyStackRef res; _PyStackRef a; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_0 = _tos_cache0; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_1 = _tos_cache1; oparg = CURRENT_OPARG(); arg = _stack_item_1; @@ -17089,8 +17092,11 @@ _PyStackRef arg; _PyStackRef res; _PyStackRef a; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_0 = _tos_cache0; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_1 = _tos_cache1; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_2 = _tos_cache2; oparg = CURRENT_OPARG(); arg = _stack_item_2; @@ -22369,6 +22375,7 @@ _PyStackRef res; _PyStackRef a; _PyStackRef c; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_0 = _tos_cache0; arg = _stack_item_0; callable = stack_pointer[-2]; @@ -22394,7 +22401,9 @@ _PyStackRef res; _PyStackRef a; _PyStackRef c; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_0 = _tos_cache0; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_1 = _tos_cache1; arg = _stack_item_1; callable = stack_pointer[-1]; @@ -22420,8 +22429,11 @@ _PyStackRef res; _PyStackRef a; _PyStackRef c; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_0 = _tos_cache0; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_1 = _tos_cache1; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_2 = _tos_cache2; arg = _stack_item_2; callable = _stack_item_0; diff --git a/Tools/cases_generator/stack.py b/Tools/cases_generator/stack.py index efc534fb607b90..662c8453ab282b 100644 --- a/Tools/cases_generator/stack.py +++ b/Tools/cases_generator/stack.py @@ -223,9 +223,12 @@ def __init__(self, check_stack_bounds: bool = False) -> None: self.variables: list[Local] = [] self.check_stack_bounds = check_stack_bounds - def push_cache(self, cached_items:list[str], out: CWriter) -> None: + def push_cache(self, op_name: str, cached_items:list[str], outputs: int, out: CWriter) -> None: for i, name in enumerate(cached_items): out.start_line() + if (op_name == "_CALL_TYPE_1" and outputs == 2) \ + or (op_name == "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW" and outputs == 3): + out.emit("Py_GCC_ATTRIBUTE((unused))\n") out.emit(f"_PyStackRef _stack_item_{i} = {name};\n") self.push(Local.register(f"_stack_item_{i}")) diff --git a/Tools/cases_generator/tier2_generator.py b/Tools/cases_generator/tier2_generator.py index 12da5bff254957..675eff176581ca 100644 --- a/Tools/cases_generator/tier2_generator.py +++ b/Tools/cases_generator/tier2_generator.py @@ -282,7 +282,7 @@ def generate_tier2( out.emit("assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());\n") declare_variables(uop, out) stack = Stack() - stack.push_cache([f"_tos_cache{i}" for i in range(inputs)], out) + stack.push_cache(uop.name, [f"_tos_cache{i}" for i in range(inputs)], outputs, out) stack._print(out) reachable, stack = write_uop(uop, emitter, stack, outputs) out.start_line() From bd9f775d5e463a8a41df703a6e20ee7f2a73d8b1 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2026 17:42:19 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2026-04-17-17-42-16.gh-issue-148695.XHT5JS.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-04-17-17-42-16.gh-issue-148695.XHT5JS.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-04-17-17-42-16.gh-issue-148695.XHT5JS.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-04-17-17-42-16.gh-issue-148695.XHT5JS.rst new file mode 100644 index 00000000000000..3334f63e224dd4 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-04-17-17-42-16.gh-issue-148695.XHT5JS.rst @@ -0,0 +1 @@ +Lint warnings in cases generator, ceval with GIL, and optimizer.