Skip to content

Commit 988286e

Browse files
authored
gh-144623: Fix missing output uops in optimizer debug output (GH-144617)
1 parent dd30f16 commit 988286e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Python/optimizer_analysis.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ dump_abstract_stack(_Py_UOpsAbstractFrame *frame, JitOptRef *stack_pointer)
8383

8484
static void
8585
dump_uop(JitOptContext *ctx, const char *label, int index,
86-
const _PyUOpInstruction *instr, JitOptRef *stack_pointer)
86+
const _PyUOpInstruction *instr, JitOptRef *stack_pointer)
8787
{
8888
if (get_lltrace() >= 3) {
8989
printf("%4d %s: ", index, label);
@@ -95,11 +95,24 @@ dump_uop(JitOptContext *ctx, const char *label, int index,
9595
}
9696
}
9797

98+
static void
99+
dump_uops(JitOptContext *ctx, const char *label,
100+
_PyUOpInstruction *start, JitOptRef *stack_pointer)
101+
{
102+
int current_len = uop_buffer_length(&ctx->out_buffer);
103+
int added_count = (int)(ctx->out_buffer.next - start);
104+
for (int j = 0; j < added_count; j++) {
105+
dump_uop(ctx, label, current_len - added_count + j, &start[j], stack_pointer);
106+
}
107+
}
108+
98109
#define DUMP_UOP dump_uop
110+
#define DUMP_UOPS dump_uops
99111

100112
#else
101113
#define DPRINTF(level, ...)
102114
#define DUMP_UOP(ctx, label, index, instr, stack_pointer)
115+
#define DUMP_UOPS(ctx, label, start, stack_pointer)
103116
#endif
104117

105118
static int
@@ -508,7 +521,7 @@ optimize_uops(
508521
*(ctx->out_buffer.next++) = *this_instr;
509522
}
510523
assert(ctx->frame != NULL);
511-
DUMP_UOP(ctx, "out", uop_buffer_length(&ctx->out_buffer) - 1, out_ptr, stack_pointer);
524+
DUMP_UOPS(ctx, "out", out_ptr, stack_pointer);
512525
if (!CURRENT_FRAME_IS_INIT_SHIM() && !ctx->done) {
513526
DPRINTF(3, " stack_level %d\n", STACK_LEVEL());
514527
ctx->frame->stack_pointer = stack_pointer;

0 commit comments

Comments
 (0)