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 000000000000000..3334f63e224dd46 --- /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. diff --git a/Python/ceval_gil.c b/Python/ceval_gil.c index 2425bc1b39f0dcc..c6f51c936866bff 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) { diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index e45bbd7cceb295f..7b1953bf8fa63a2 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -17718,6 +17718,7 @@ _PyStackRef arg; _PyStackRef res; _PyStackRef a; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_0 = _tos_cache0; oparg = CURRENT_OPARG(); arg = _stack_item_0; @@ -17741,7 +17742,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; @@ -17765,8 +17768,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; @@ -23178,6 +23184,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]; @@ -23202,7 +23209,9 @@ _PyStackRef top; _PyStackRef middle; _PyStackRef bottom; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_0 = _tos_cache0; + Py_GCC_ATTRIBUTE((unused)) _PyStackRef _stack_item_1 = _tos_cache1; top = _stack_item_1; middle = _stack_item_0; @@ -23227,8 +23236,11 @@ _PyStackRef top; _PyStackRef middle; _PyStackRef bottom; + 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; top = _stack_item_2; middle = _stack_item_1; diff --git a/Python/optimizer.c b/Python/optimizer.c index c9f6ebdb62f07b2..9b02b6464f91152 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 /***************************************** diff --git a/Tools/cases_generator/stack.py b/Tools/cases_generator/stack.py index 8044ac10dd0ad70..deacba6c32c23f2 100644 --- a/Tools/cases_generator/stack.py +++ b/Tools/cases_generator/stack.py @@ -224,9 +224,13 @@ 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) \ + 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}")) diff --git a/Tools/cases_generator/tier2_generator.py b/Tools/cases_generator/tier2_generator.py index b166b08b188deef..1a40153ba550ca1 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()