0xPolygonMiden / compiler

Compiler from MidenIR to Miden Assembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ensure that load/store ops are not reordered with respect to each other in treegraph

greenhat opened this issue · comments

Currently, we do not attach control dependencies to side-effecting operations in the computation of the dependency graph, which is used to derive the treegraph from which we schedule the actual Miden Assembly instructions. The result is that things like load and store instructions contained in different sub-trees of the treegraph can be reordered with respect to one another. This is not an issue when the memory referenced by those instructions is disjoint, but in general is an issue, and applies to other side-effecting instructions as well, including function calls.

The dependency graph already supports the notion of "control" dependencies, which are edges that instead of representing a data dependency, represent an explicit ordering of instructions such that control must pass through the predecessor instruction before reaching the successor. We actually use this already to ensure that side-effecting operations with no/unused results are always executed before the terminator instruction of that block, by attaching a control dependency from the terminator to the side-effecting operation, such that the latter must always be scheduled before the former.

We simply need to ensure control dependencies for other instruction relationships are added to the dependency graph.