[Synth][LowerVariaidc] Fix topological ordering and a pass phase ordering #9095
+36
−19
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.
This commit fixes topological sorting issues and pass ordering problems in the LowerVariadic pass.
The main lowering loop is changed from walk-based iteration to direct iteration using make_early_inc_range over top-level operations only. This is necessary because topologically sorting operations across nested regions is challenging (when a child implicitly captures SSA values, the current MLIR topologically sorting doesn't work well) and the previous approach did not handle this correctly.
The pass now uses MLIR's standard sortTopologically utility with an enhanced predicate that properly handles HW dialect operations, treating hw::InstanceOp as an anchor while allowing Comb and Synth operations to be sorted.
In the synthesis pipeline, LowerVariadic is moved to run after LowerWordToBits for better timing precision and scalability.