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. 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) { 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/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 /***************************************** 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()