Skip to content

JIT optimizer debug output misses subsequent uops when multiple are emitted. #144623

@cocolato

Description

@cocolato

Bug report

Bug description:

Currently, optimize_uops uses DUMP_UOP to log instructions. However, DUMP_UOP typically logs only a single instruction at the out_ptr. Since optimize_uops is capable of emitting multiple uops into the buffer in a single pass (e.g., during decomposition or specific optimizations), this mechanism causes the debug log to miss any subsequent uops that were generated after the first one.

case:
If we want to split _BINARY_SLICE to three uops:

  op(_BINARY_SLICE, (container, start, stop -- res)) {
        ...
        if (type == &PyList_Type) {
            ADD_OP(_GUARD_3OS_TYPE, 0, (uintptr_t)type);
            ADD_OP(_UNPACK_INDICES, 0, 0);
            ADD_OP(_BINARY_SLICE_LIST, 0, 0);Expand commentComment on line R1500Resolved
           ...
        }

The debug log will output with wrong uop id and missed _UNPACK_INDICES _BINARY_SLICE_LIST:

 stack_level 5
  24 abs: _BINARY_SLICE (0, target=24, operand0=0, operand1=0)
    locals=[<? at 0x101b58440>, <recorded type list>, <? at 0x101b58460>, <? at 0x101b58470>, <int at 0x101b584c0>, <? at 0x101b58490>]
    stack=[<? at 0x101b584a0>, <? at 0x101b584b0>, <recorded type list>, <? at 0x101b58460>, <? at 0x101b58470>]
  26 out: _GUARD_3OS_TYPE (0, target=24, operand0=0x101745988, operand1=0)
    locals=[<? at 0x101b58440>, <recorded type list>, <? at 0x101b58460>, <? at 0x101b58470>, <int at 0x101b584c0>, <? at 0x101b58490>]
    stack=[<? at 0x101b584a0>, <? at 0x101b584b0>, <list at 0x101b584d0>]

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions