Skip to content
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

Unifying RETURN_VALUE bytecode #90

Open
sklam opened this issue Jul 31, 2023 · 0 comments
Open

Unifying RETURN_VALUE bytecode #90

sklam opened this issue Jul 31, 2023 · 0 comments

Comments

@sklam
Copy link
Member

sklam commented Jul 31, 2023

The RETURN_VALUE bytecode is not unified by when SCFG join returns. This leads to SCFG that semantically terminates in the middle of switches.

For example:

import dis
from numba_rvsdg.core.datastructures.scfg import SCFG
from numba_rvsdg.core.datastructures.byte_flow import ByteFlow

def example(x):
    if x:
        return 1
    else:
        return 2


dis.dis(example)

bf = ByteFlow.from_bytecode(example).restructure()
bf.scfg.view()

The bytecode is:

  5           0 RESUME                   0

  6           2 LOAD_FAST                0 (x)
              4 POP_JUMP_FORWARD_IF_FALSE     2 (to 10)

  7           6 LOAD_CONST               1 (1)
              8 RETURN_VALUE

  9     >>   10 LOAD_CONST               2 (2)
             12 RETURN_VALUE

The SCFG
Screenshot 2023-07-31 at 6 28 27 PM

Notice that both "branch" regions contain a RETURN_VALUE.

I have two workarounds at sklam/numba@c9d3634:

Update - Aug 4

I have a new workaround that solely addresses the problem in RVSDG->NumbaIR (bcinterp.py) at numba/numba@a117aae. It relies on interpreting RETURN_VALUE as non terminating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant