[LLHD] Add dedicated Mem2Reg pass #8244
Open
+1,465
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement a dedicated LLHD pass that promotes signal/memory slots to SSA values and forwards drives to probes. The pass is distinct from MLIR's upstream Mem2Reg pass in that it also works for regions where the memory slots are defined outside the region. It also understands
llhd.wait
andllhd.halt
operations which may suspend execution of a process and therefore allows the values of signals to change before execution resumes. To deal with this, the pass uses a lattice to propagate the need for slot definitions backwards from probes, and to propagate reaching definitions for slots forward from drives and initial probes. Using the lattice, the pass can forward driven values to probes as long as there is no process suspension in between (llhd.wait
), and it will insert probes immediately after and drives immediately before suspension points. This moves most intra-process data flow into SSA values and block arguments, and retains probes and drives around the suspension point to interact with ops outside the process.This first implementation only supports unconditional blocking drives, and only probes and drives that interact with a
llhd.sig
directly without any field projections or aliasing. The pass is designed to deal with these in the future though: a more detailed aliasing analysis can determine which definitions are invalidated by drives, drives to field projections can be converted into field insertions on the whole definition, and drive conditions can be propagated along definitions to the drives inserted by the pass ahead of suspension points.Fixes #8245
Fixes #8246