feat(dataflow): sparse fact api#859
Open
axelcool1234 wants to merge 3 commits into
Open
Conversation
4bd5d12 to
abbbe5e
Compare
ineol
reviewed
Jun 12, 2026
9c78f96 to
d642161
Compare
axelcool1234
commented
Jun 12, 2026
Comment on lines
+34
to
+55
| /-- | ||
| Propagate a sparse lattice update by revisiting dependents and all users of the | ||
| updated SSA value for subscribed analyses. | ||
| -/ | ||
| def propagate (state : Fact kind) (anchor : LatticeAnchor) | ||
| (dfCtx : DataFlowContext) (irCtx : IRContext OpCode) : DataFlowContext := Id.run do | ||
| let mut dfCtx := { dfCtx with workList := state.enqueueDependents dfCtx.workList } | ||
| match anchor with | ||
| | .ValuePtr ssaValue => | ||
| let mut maybeUse := ssaValue.getFirstUse! irCtx | ||
| while let some use := maybeUse do | ||
| let user := (use.get! irCtx).owner | ||
| for analysisKind in state.subscribers do | ||
| match InsertPoint.after? user irCtx with | ||
| | some point => | ||
| dfCtx := dfCtx.enqueue (point, analysisKind) | ||
| | none => | ||
| pure () | ||
| maybeUse := (use.get! irCtx).nextUse | ||
| | _ => | ||
| pure () | ||
| dfCtx |
Collaborator
Author
There was a problem hiding this comment.
@math-fehr Here is an example of subscribers being used. For any fact that attaches to SSA Values, it enqueues into the worklist all of its uses for each subscribed analysis whenever said SSA fact changes. That's because its uses will be affected by that change. Analyses concerned about said change of this fact will be subscribed so that it can run its transfer function on the uses.
d642161 to
6e940a5
Compare
Collaborator
Author
|
Cc @math-fehr @regehr @ineol this is the first step towards supporting transfer functions on SSA values, which is what John is mostly concerned with. I need some review of this code, thank you 🙏 |
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.
The following is a type that builds off of the generic
Facttype. You can define "sparse facts" - facts that attach toValues, using this type. It'll handle notifying dependents and subscribed analyses for you when it changes.