Skip to content

Commit ebb10bb

Browse files
committed
calculate block ID and use it for label, instead of address
1 parent 78f3fa9 commit ebb10bb

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Python/compile.c

+7-8
Original file line numberDiff line numberDiff line change
@@ -9691,8 +9691,12 @@ cfg_to_instructions(cfg_builder *g)
96919691
if (instructions == NULL) {
96929692
return NULL;
96939693
}
9694+
int lbl = 1;
96949695
for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
9695-
PyObject *lbl = PyLong_FromUnsignedLongLong((uintptr_t)b);
9696+
b->b_label = lbl++;
9697+
}
9698+
for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
9699+
PyObject *lbl = PyLong_FromLong(b->b_label);
96969700
if (lbl == NULL) {
96979701
goto error;
96989702
}
@@ -9704,14 +9708,9 @@ cfg_to_instructions(cfg_builder *g)
97049708
for (int i = 0; i < b->b_iused; i++) {
97059709
struct instr *instr = &b->b_instr[i];
97069710
struct location loc = instr->i_loc;
9707-
uintptr_t arg = instr->i_oparg;
9708-
if (HAS_TARGET(instr->i_opcode)) {
9709-
/* Use the address of the block as its unique ID (for the label) */
9710-
arg = (uintptr_t)instr->i_target;
9711-
}
9712-
9711+
int arg = HAS_TARGET(instr->i_opcode) ? instr->i_target->b_label : instr->i_oparg;
97139712
PyObject *inst_tuple = Py_BuildValue(
9714-
"(iLiiii)", instr->i_opcode, arg,
9713+
"(iiiiii)", instr->i_opcode, arg,
97159714
loc.lineno, loc.end_lineno,
97169715
loc.col_offset, loc.end_col_offset);
97179716
if (inst_tuple == NULL) {

0 commit comments

Comments
 (0)