summaryrefslogtreecommitdiffstats
path: root/Python/flowgraph.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2024-03-27 17:38:19 (GMT)
committerGitHub <noreply@github.com>2024-03-27 17:38:19 (GMT)
commit262fb911ab7df8e890ebd0efb0773c3e0b5a757f (patch)
tree250f7b163f7cc074be10e6c5c2321579eca991b4 /Python/flowgraph.c
parent74c8568d07719529b874897598d8b3bc25ff0434 (diff)
downloadcpython-262fb911ab7df8e890ebd0efb0773c3e0b5a757f.zip
cpython-262fb911ab7df8e890ebd0efb0773c3e0b5a757f.tar.gz
cpython-262fb911ab7df8e890ebd0efb0773c3e0b5a757f.tar.bz2
gh-117288: Allocate fewer label IDs in _PyCfg_ToInstructionSequence (#117290)
Diffstat (limited to 'Python/flowgraph.c')
-rw-r--r--Python/flowgraph.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/flowgraph.c b/Python/flowgraph.c
index 2f47e47..5437c38 100644
--- a/Python/flowgraph.c
+++ b/Python/flowgraph.c
@@ -2717,13 +2717,14 @@ _PyCfg_ToInstructionSequence(cfg_builder *g, _PyCompile_InstructionSequence *seq
int lbl = 0;
for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
b->b_label = (jump_target_label){lbl};
- lbl += b->b_iused;
+ lbl += 1;
}
for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
RETURN_IF_ERROR(_PyCompile_InstructionSequence_UseLabel(seq, b->b_label.id));
for (int i = 0; i < b->b_iused; i++) {
cfg_instr *instr = &b->b_instr[i];
- if (OPCODE_HAS_JUMP(instr->i_opcode) || is_block_push(instr)) {
+ if (HAS_TARGET(instr->i_opcode)) {
+ /* Set oparg to the label id (it will later be mapped to an offset) */
instr->i_oparg = instr->i_target->b_label.id;
}
RETURN_IF_ERROR(