Skip to content

Instantly share code, notes, and snippets.

@sklam

sklam/graph.svg Secret

Created May 24, 2023 20:50
Show Gist options
  • Save sklam/f43f7c4eb574a79eaca9d5b4d27ef6ba to your computer and use it in GitHub Desktop.
Save sklam/f43f7c4eb574a79eaca9d5b4d27ef6ba to your computer and use it in GitHub Desktop.
issue_find_headers_and_entries
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from numba_rvsdg.core.datastructures.byte_flow import ByteFlow
from numba_rvsdg.rendering.rendering import ByteFlowRenderer
def while_count(s, e):
i = s
c = 0
while i < e:
c += i
i += 1
return c
code = while_count.__code__
byteflow = ByteFlow.from_bytecode(code)
bcmap = byteflow.scfg.bcmap_from_bytecode(byteflow.bc)
byteflow = byteflow.restructure()
# render
bfr = ByteFlowRenderer()
bfr.bcmap_from_bytecode(byteflow.bc)
bfr.render_scfg(byteflow.scfg).view("scfg")
scfg = byteflow.scfg
the_branch = scfg.graph["python_bytecode_block_1"]
the_loop = the_branch.subregion["python_bytecode_block_1"]
the_pybc_block = the_loop.subregion["python_bytecode_block_1"]
headers, entries = the_loop.subregion.find_headers_and_entries(the_loop.subregion)
print("entries?", entries)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment