Skip to content
1 change: 1 addition & 0 deletions Python/ceval_gil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1724,6 +1727,7 @@ uop_optimize(
*exec_ptr = executor;
return 1;
}
#endif


/*****************************************
Expand Down
6 changes: 5 additions & 1 deletion Tools/cases_generator/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is too fragile. Can't we just have a maybe unused attribute instead? and what about clang attributes? (AFAICT this is a GCC attribute only).

I do not think the unused variable warnings need to be suppressed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the Py_UNUSED macro be applied to lvalue variables?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. But again is there a need to suppress such warnings? we provide no guarantee for -Wall -Werror/-Wpedantic and I do not see value in suppressing unused variable warninga in general.

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}"))

Expand Down
2 changes: 1 addition & 1 deletion Tools/cases_generator/tier2_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading