ribrdb / desynced-tools

Tools for working with behaviors and blueprints from Desynced.
MIT License
4 stars 3 forks source link

Some output variables are rewritten as nil while the result do matter #28

Closed quisar closed 8 months ago

quisar commented 8 months ago

See https://github.com/quisar/desynced-tools/tree/variable_scope

This change doesn't pass the test. The issue is that the variable is used in the loop conditional and updated inside the loop. The generated assembly do not update the variable

quisar commented 8 months ago

Reading #regAlloc code, I do not understand how this code handles loops.

ribrdb commented 8 months ago

yeah, regAlloc is really dumb. I'm kind of surprised it ever works

ribrdb commented 8 months ago

Yep, need a better dataflow analysis to fix this. It might be able to just split the code into basic blocks and analyze that graph, without going all the way to SSA.

quisar commented 8 months ago

I think we can solve this without using dataflow. Instead we can keep a tree of variable declaration related to blocks. I will try to see if I can make this work.