[3.13] gh-124871: fix 'visited' tracking in compiler's reachability analysis (GH-124952) (#124977)

gh-124871: fix 'visited' tracking in compiler's reachability analysis (GH-124952)
(cherry picked from commit f474391b26)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-10-05 00:34:20 +02:00 committed by GitHub
parent dd4e62e35f
commit b87aea6b0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 2 deletions

View file

@ -960,13 +960,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++;
}
@ -976,8 +977,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++;
}