Skip to content

Rewrite the slotworks gathering to work across blocks

As @DorentuZ touched on in #24, the current system for slot gathering has some major issues.

In particular, the slot gatherer can't find slots across blocks. This leads to slotworks eliminating seemingly redundant slots that are actually used in another block.

For example, take the slot_block_gathering test. It's as follows:

local myvar = 1
print(myvar)

if gbl then
        inblock(myvar)
end

Which decompiles to:

print(1)

if gbl then
        inblock(slot0)
end

Since slot0 was eliminated since it was only found to had a single use.

The solution here I think is to track the possible slots backwards to find at what point a given slot can't be observed, and use that to track each one's scope.

This will require quite a bit of rewriting, and I may well leave some comments for how this is going, hence why I'm opening the issue.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information