Skip to content

gh-126835: Set location for noped out instructions after constant folding in CFG. #130109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use NO_LOCATION
  • Loading branch information
WolframAlph committed Feb 14, 2025
commit 0f95636ca4bb33c5102c885621d8514a9df27c94
14 changes: 6 additions & 8 deletions Python/flowgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,10 +1388,10 @@ get_constant_sequence(basicblock *bb, int start, int size,

/*
Walk basic block backwards starting from "start" and change "count" number of
non-NOP instructions to NOP's and set their i_loc info to "location" if provided.
non-NOP instructions to NOP's and set their location to NO_LOCATION.
*/
static void
nop_out(basicblock *bb, int start, int count, _Py_SourceLocation *location)
nop_out(basicblock *bb, int start, int count)
{
assert(start < bb->b_iused);
for (; count > 0; start--) {
Expand All @@ -1401,9 +1401,7 @@ nop_out(basicblock *bb, int start, int count, _Py_SourceLocation *location)
continue;
}
INSTR_SET_OP0(instr, NOP);
if (location != NULL) {
INSTR_SET_LOC(instr, *location);
}
INSTR_SET_LOC(instr, NO_LOCATION);
count--;
}
}
Expand Down Expand Up @@ -1432,7 +1430,7 @@ fold_tuple_of_constants(basicblock *bb, int n, PyObject *consts, PyObject *const
assert(PyTuple_CheckExact(newconst) && PyTuple_GET_SIZE(newconst) == seq_size);
int index = add_const(newconst, consts, const_cache);
RETURN_IF_ERROR(index);
nop_out(bb, n-1, seq_size, &instr->i_loc);
nop_out(bb, n-1, seq_size);
INSTR_SET_OP1(instr, LOAD_CONST, index);
return SUCCESS;
}
Expand Down Expand Up @@ -1482,7 +1480,7 @@ optimize_lists_and_sets(basicblock *bb, int i, int nextop,
}
int index = add_const(newconst, consts, const_cache);
RETURN_IF_ERROR(index);
nop_out(bb, i-1, seq_size, &instr->i_loc);
nop_out(bb, i-1, seq_size);
if (contains_or_iter) {
INSTR_SET_OP1(instr, LOAD_CONST, index);
}
Expand Down Expand Up @@ -1545,7 +1543,7 @@ optimize_if_const_binop(basicblock *bb, int i, PyObject *consts, PyObject *const
}
int newopcode, newoparg;
RETURN_IF_ERROR(newop_from_folded(newconst, consts, const_cache, &newopcode, &newoparg));
nop_out(bb, i-1, 2, &binop->i_loc);
nop_out(bb, i-1, 2);
INSTR_SET_OP1(binop, newopcode, newoparg);
return SUCCESS;
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy