BasicBlockRewriter.jl
BasicBlockRewriter.jl copied to clipboard
Code-regrouping to reduce latency in Julia code compilation
BasicBlockRewriter
This package explores a new approach to latency reduction in Julia. It determines the unique basic blocks present across a swath of Julia code and rewrites functions as calls to "fragments" that represent these blocks.
This is a work in progress, and most of the features described below have not yet been implemented.
Analysis pass
Starting from a method, generate relocatable fragments:
- split the lowered code into blocks. Trim gotos, which are external to fragments.
- for each trimmed block, renumber
SlotNumbers and internalSSAValues by the order in which they appear - convert external
SSAValues into slots
Generating callable fragments
Starting from the original lowered code, block-internal SSAValues accessed from other blocks, as well as updates to slots, are assembled to create the fragment return values. Ideally this gets done "swath-wide" because the same fragment may be used in different ways (using or ignoring different possible return values) by other code.
Then the fragments from the analysis pass get wrapped in methods.
Rewriting parent functions in terms of fragments
Parent lowered code gets replaced with calls to the fragments.