Repository navigation
feat: dominance, SSA and def-use chains - #16
Merged
Merged
Conversation
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Closes Phase 3 of
docs/architecture.md: dominance (§5) and SSA (§7).test: define dominance, SSA and def-use behavior), implementation follows.cfg/dominance.py: dominator tree with immediate dominators, children, dominance frontiers and iterated frontiers, computed with the Cooper–Harvey–Kennedy algorithm over reachable blocks. The same code on the reversed graph from a virtualEXITgives post-dominators; the post-dominance frontier is control dependence. Exposed ascfg.dominanceandcfg.post_dominancefunction analyses.ir/ssa.py:SSAAnalysis(ir.ssa) derives a new immutableFunctionIRfrom PyIR and the dominator tree. Locals disappear, merges getPhiinstructions placed on the iterated dominance frontier and pruned by liveness,for_nextdefines the loop variable, and a local read before any definition on some path reads an explicitUndefinedvalue created once in the entry block. Only reachable blocks are kept; values are renumbered densely. SSA is a derived analysis rather than an in-place transformation, so Rule 3 (immutable IR) holds and the manager caches and invalidates it like any other result.ir/defuse.py:DefUseAnalysis(ir.defuse) indexes definitions (parameter, instruction or terminator) and uses (instruction or terminator) of every SSA value.Phi,Undefined, a result onForNext, and genericoperands()/substitute()on every instruction and terminator.--emit-ir --ssaprints the §7 example exactly as the document shows it, with numbered values.Part of #15. Left open there: nothing functional; the "SSA invalidates dependants" bullet is satisfied by the manager's declarative dependencies (
SSAAnalysisrequiresPyIRAnalysisandDominanceAnalysis,DefUseAnalysisrequiresSSAAnalysis).Closes #15