mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
gh-124871: fix 'visited' tracking in compiler's reachability analysis (#124952)
This commit is contained in:
parent
994051e086
commit
f474391b26
3 changed files with 18 additions and 2 deletions
|
@ -1001,13 +1001,14 @@ remove_unreachable(basicblock *entryblock) {
|
|||
basicblock **sp = stack;
|
||||
entryblock->b_predecessors = 1;
|
||||
*sp++ = entryblock;
|
||||
entryblock->b_visited = 1;
|
||||
while (sp > stack) {
|
||||
basicblock *b = *(--sp);
|
||||
b->b_visited = 1;
|
||||
if (b->b_next && BB_HAS_FALLTHROUGH(b)) {
|
||||
if (!b->b_next->b_visited) {
|
||||
assert(b->b_next->b_predecessors == 0);
|
||||
*sp++ = b->b_next;
|
||||
b->b_next->b_visited = 1;
|
||||
}
|
||||
b->b_next->b_predecessors++;
|
||||
}
|
||||
|
@ -1017,8 +1018,8 @@ remove_unreachable(basicblock *entryblock) {
|
|||
if (is_jump(instr) || is_block_push(instr)) {
|
||||
target = instr->i_target;
|
||||
if (!target->b_visited) {
|
||||
assert(target->b_predecessors == 0 || target == b->b_next);
|
||||
*sp++ = target;
|
||||
target->b_visited = 1;
|
||||
}
|
||||
target->b_predecessors++;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue