From 13f194f0535251301df6e326959c27064488a32a Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Fri, 17 Apr 2026 16:33:37 +0000 Subject: [PATCH 1/6] 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 e05adb344c8d06..d2c06b59ebc41b 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 @@ -1644,6 +1646,7 @@ stack_allocate(_PyUOpInstruction *buffer, _PyUOpInstruction *output, int length) return (int)(write - output); } +#ifndef Py_GIL_DISABLED static int uop_optimize( _PyInterpreterFrame *frame, @@ -1724,6 +1727,7 @@ uop_optimize( *exec_ptr = executor; return 1; } +#endif /***************************************** From 9b9ac50077d816e7016e65c8d3f727b611c0a159 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Fri, 17 Apr 2026 16:52:42 +0000 Subject: [PATCH 2/6] 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 49b2ede4ed3e60..549df0bc344108 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 4cb355eea94e0314ae8cc9dc86378cf4b5dabe55 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Fri, 17 Apr 2026 17:38:41 +0000 Subject: [PATCH 3/6] Supress unused variable warnings in generated executor_cases header --- Python/executor_cases.c.h | 30 ++++++++++++++++++++++++ Tools/cases_generator/stack.py | 5 +++- Tools/cases_generator/tier2_generator.py | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index bc85ccd9ddb4fc..9915eb68173229 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -17903,6 +17903,7 @@ _PyStackRef arg; _PyStackRef res; _PyStackRef a; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_0 = _tos_cache0; oparg = CURRENT_OPARG(); arg = _stack_item_0; @@ -17926,7 +17927,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; @@ -17950,8 +17953,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; @@ -23424,6 +23430,7 @@ _PyStackRef top; _PyStackRef middle; _PyStackRef bottom; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_0 = _tos_cache0; top = _stack_item_0; middle = stack_pointer[-1]; @@ -23444,11 +23451,22 @@ case _RROT_3_r23: { CHECK_CURRENT_CACHED_VALUES(2); +<<<<<<< HEAD ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); _PyStackRef top; _PyStackRef middle; _PyStackRef bottom; +======= + assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE()); + _PyStackRef arg; + _PyStackRef callable; + _PyStackRef res; + _PyStackRef a; + _PyStackRef c; + Py_GCC_ATTRIBUTE((unused)) +>>>>>>> 896acf80c2 (Supress unused variable warnings in generated executor_cases header) _PyStackRef _stack_item_0 = _tos_cache0; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_1 = _tos_cache1; top = _stack_item_1; middle = _stack_item_0; @@ -23469,12 +23487,24 @@ case _RROT_3_r33: { CHECK_CURRENT_CACHED_VALUES(3); +<<<<<<< HEAD ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); _PyStackRef top; _PyStackRef middle; _PyStackRef bottom; +======= + assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE()); + _PyStackRef arg; + _PyStackRef callable; + _PyStackRef res; + _PyStackRef a; + _PyStackRef c; + Py_GCC_ATTRIBUTE((unused)) +>>>>>>> 896acf80c2 (Supress unused variable warnings in generated executor_cases header) _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; top = _stack_item_2; middle = _stack_item_1; diff --git a/Tools/cases_generator/stack.py b/Tools/cases_generator/stack.py index 8044ac10dd0ad7..626f69d70a1d99 100644 --- a/Tools/cases_generator/stack.py +++ b/Tools/cases_generator/stack.py @@ -224,9 +224,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 b166b08b188dee..1a40153ba550ca 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(__FILE__, __LINE__);\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 c31182da7e78cad9ca85791ee663cd1fdfe5ca6d 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/6] =?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. From f49a2b24650f64ee0667540d9462376d2af8dfd8 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Tue, 7 Jul 2026 03:19:03 +0000 Subject: [PATCH 5/6] Cover _RROT_3 opcodes as well --- Tools/cases_generator/stack.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tools/cases_generator/stack.py b/Tools/cases_generator/stack.py index 626f69d70a1d99..deacba6c32c23f 100644 --- a/Tools/cases_generator/stack.py +++ b/Tools/cases_generator/stack.py @@ -228,7 +228,8 @@ def push_cache(self, op_name: str, cached_items:list[str], outputs: int, out: CW 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): + or (op_name == "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW" and outputs == 3) \ + or (op_name == "_RROT_3" 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}")) From 2db3a2119a1464a57334032c1c47e110f8e14543 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Sun, 11 Oct 2026 12:21:30 +0000 Subject: [PATCH 6/6] Regnerate executor cases --- Python/executor_cases.c.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 9915eb68173229..b46146dcd5181a 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -23451,20 +23451,11 @@ case _RROT_3_r23: { CHECK_CURRENT_CACHED_VALUES(2); -<<<<<<< HEAD ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); _PyStackRef top; _PyStackRef middle; _PyStackRef bottom; -======= - assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE()); - _PyStackRef arg; - _PyStackRef callable; - _PyStackRef res; - _PyStackRef a; - _PyStackRef c; Py_GCC_ATTRIBUTE((unused)) ->>>>>>> 896acf80c2 (Supress unused variable warnings in generated executor_cases header) _PyStackRef _stack_item_0 = _tos_cache0; Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_1 = _tos_cache1; @@ -23487,20 +23478,11 @@ case _RROT_3_r33: { CHECK_CURRENT_CACHED_VALUES(3); -<<<<<<< HEAD ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); _PyStackRef top; _PyStackRef middle; _PyStackRef bottom; -======= - assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE()); - _PyStackRef arg; - _PyStackRef callable; - _PyStackRef res; - _PyStackRef a; - _PyStackRef c; Py_GCC_ATTRIBUTE((unused)) ->>>>>>> 896acf80c2 (Supress unused variable warnings in generated executor_cases header) _PyStackRef _stack_item_0 = _tos_cache0; Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_1 = _tos_cache1;