Fixes #29. Refer to it for more context and details.
Gist
For any temp to be spilled, always
write it to a fixed slot on stack right after write
restore it into a new unique temp right before read, and use the new temp in the instruction
Potential Optimizations
Graph-coloring based allocator that accounts for interferences from a global perspective. (a simple print (1 + 2) shows how the greedy algorithm creates unnecessary spills due to lack of global perspective)
Calculate interference based on live-ranges (or essentially rename the temps based on live-ranges).
Don't spill all usage of temps -- only spill the one of them (i.e. break up 1 def-use chain part of live-interval)? Might take too many iterations in that case.
Fixes #29. Refer to it for more context and details.
Gist
For any temp to be spilled, always
Potential Optimizations
print (1 + 2)
shows how the greedy algorithm creates unnecessary spills due to lack of global perspective)