(refactor): Migrate reorganize_blocks to DataflowAnalyzer (WIP) #9558
+51
−51
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.

Summary
Refactored the block reorganization code in the lowering phase to use the new dataflow analysis framework. This PR replaces the old
BackAnalysiswithDataflowBackAnalysisand updates theTopSortContextto implement theDataflowAnalyzertrait instead ofAnalyzer. The implementation now follows a more structured approach with dedicated methods for handling different types of edges and transfers.Type of change
Please check one:
Why is this change needed?
This change is part of the ongoing effort to standardize the dataflow analysis framework in the compiler. By migrating the block reorganization code to use the new dataflow analysis infrastructure, we ensure consistency across the codebase and make future maintenance easier.
What was the behavior or documentation before?
Previously, the block reorganization logic used the older
BackAnalysissystem with custom visitor methods for different statement types. The analysis was less structured and had separate methods for handling different block end types.What is the behavior or documentation after?
Now the code uses the more structured
DataflowBackAnalysisframework with clear separation between initialization, transfer functions, and edge handling. The implementation is more consistent with other parts of the compiler that use the dataflow analysis framework.Additional context
This refactoring maintains the same functionality while aligning with the new analysis infrastructure. The changes primarily affect how the analysis is structured rather than changing the actual block reorganization logic.