numba / numba-rvsdg

Numba compatible RVSDG (Regionalized Value State Dependence Graph) utilities.
https://numba-rvsdg.readthedocs.io/
BSD 2-Clause "Simplified" License
18 stars 7 forks source link

Jump targets are not updated properly for simplest branching example. #139

Closed esc closed 3 months ago

esc commented 3 months ago

Code to reproduce:

from numba_rvsdg.core.datastructures.ast_transforms import AST2SCFGTransformer

def branch(b: int) -> int:
    if b:
        r = 1
    else:
        r = 2
    return r

scfg = AST2SCFGTransformer(branch).transform_to_SCFG()
scfg.restructure()
scfg.view()

This produced the following:

Screenshot 2024-08-02 at 13 52 19

As you can see the jump targets of both the region branch_region_0 and basic block 1 have been updated to read tail_region_0 but the jump targets of region branch_region_1 and basic block 2 have not! The updates should be symmetric. The same code path is taken for both branch regions, yet two different results are produced. What is going on here?