Open
Description
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
Notice that both "branch" regions contain a RETURN_VALUE
.
I have two workarounds at sklam/numba@c9d3634:
- rewrite the bytecode to turn RETURN_VALUE into jumps and inserting a unified RETURN_VALUE after the last bytecode offset. sklam/numba@c9d3634#diff-777376747c149410653d20624af95aff1bc2dc050186ef11e4e8a222288184aaR628-R672
- a SCFG version of the above logic but done before restructuring. sklam/numba@c9d3634#diff-777376747c149410653d20624af95aff1bc2dc050186ef11e4e8a222288184aaR596-R619
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.
Metadata
Metadata
Assignees
Labels
No labels
Activity