Cleanup tier2 debug output (#116920)

Various tweaks, including a slight refactor of the special cases for `_PUSH_FRAME`/`_POP_FRAME` to show the actual operand emitted.
This commit is contained in:
Guido van Rossum 2024-03-18 11:08:43 -07:00 committed by GitHub
parent 849e0716d3
commit 76d0868907
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 50 additions and 22 deletions

View file

@ -35,6 +35,7 @@
#ifdef Py_DEBUG
extern const char *_PyUOpName(int index);
extern void _PyUOpPrint(const _PyUOpInstruction *uop);
static const char *const DEBUG_ENV = "PYTHON_OPT_DEBUG";
static inline int get_lltrace(void) {
char *uop_debug = Py_GETENV(DEBUG_ENV);
@ -377,14 +378,20 @@ optimize_uops(
_Py_UopsSymbol **stack_pointer = ctx->frame->stack_pointer;
DPRINTF(3, "Abstract interpreting %s:%d ",
_PyUOpName(opcode),
oparg);
#ifdef Py_DEBUG
if (get_lltrace() >= 3) {
printf("%4d abs: ", (int)(this_instr - trace));
_PyUOpPrint(this_instr);
printf(" ");
}
#endif
switch (opcode) {
#include "optimizer_cases.c.h"
default:
DPRINTF(1, "Unknown opcode in abstract interpreter\n");
DPRINTF(1, "\nUnknown opcode in abstract interpreter\n");
Py_UNREACHABLE();
}
assert(ctx->frame != NULL);
@ -397,11 +404,13 @@ optimize_uops(
return 1;
out_of_space:
DPRINTF(3, "\n");
DPRINTF(1, "Out of space in abstract interpreter\n");
_Py_uop_abstractcontext_fini(ctx);
return 0;
error:
DPRINTF(3, "\n");
DPRINTF(1, "Encountered error in abstract interpreter\n");
_Py_uop_abstractcontext_fini(ctx);
return 0;
@ -411,6 +420,7 @@ hit_bottom:
// This means that the abstract interpreter has hit unreachable code.
// We *could* generate an _EXIT_TRACE or _FATAL_ERROR here, but it's
// simpler to just admit failure and not create the executor.
DPRINTF(3, "\n");
DPRINTF(1, "Hit bottom in abstract interpreter\n");
_Py_uop_abstractcontext_fini(ctx);
return 0;