[LifetimeSafety] Add loan expiry analysis#148712
Merged
usx95 merged 1 commit intoJul 23, 2025
Merged
Conversation
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
880cf3b to
ed73e3b
Compare
c217d0d to
702d255
Compare
ed73e3b to
a50b00e
Compare
7e098b0 to
793d58e
Compare
a50b00e to
a9f1e8d
Compare
793d58e to
2bff132
Compare
6ce3173 to
9265536
Compare
2253ff0 to
c073ef3
Compare
9265536 to
9da8f3a
Compare
c073ef3 to
51afc3e
Compare
9da8f3a to
04d6193
Compare
51afc3e to
7b26a72
Compare
04d6193 to
2073937
Compare
5f09913 to
aca68c2
Compare
b109b6a to
7502ee5
Compare
8c5c8f1 to
c29040a
Compare
Contributor
Author
|
Added unit tests for loan expiry! |
This was referenced Jul 18, 2025
ymand
approved these changes
Jul 21, 2025
|
|
||
| // ========================================================================= // | ||
| // Expired Loans Analysis | ||
| // ========================================================================= // |
Contributor
Author
There was a problem hiding this comment.
Can you please add a suggestion? I don't quite get the location where you are referring.
| } | ||
|
|
||
| Lattice transfer(Lattice In, const IssueFact &F) { | ||
| return Lattice(Factory.remove(In.Expired, F.getLoanID())); |
Contributor
There was a problem hiding this comment.
Might be worth explaining why this is necessary. Specifically, now its possible that the loan would appear in In.Expired at all to be worth removing. I assume this arises because of backedges.
Contributor
Author
There was a problem hiding this comment.
Done. There is a subtle false negative due to this as well. Mentioned that.
Xazax-hun
approved these changes
Jul 21, 2025
Xazax-hun
left a comment
Contributor
There was a problem hiding this comment.
Once the comments are addressed it looks good to me.
c29040a to
6ad27da
Compare
e6fc855 to
ad8d8a8
Compare
6ad27da to
7ec322f
Compare
Base automatically changed from
users/usx95/07-16-lifetime-safety-add-unit-tests
to
main
July 22, 2025 10:32
7ec322f to
65f5402
Compare
65f5402 to
7a78e40
Compare
Contributor
Author
mahesh-attarde
pushed a commit
to mahesh-attarde/llvm-project
that referenced
this pull request
Jul 28, 2025
This PR adds the `ExpiredLoansAnalysis` class to track which loans have expired. The analysis uses a dataflow lattice (`ExpiredLattice`) to maintain the set of expired loans at each program point. This is a very light weight dataflow analysis and is expected to reach fixed point in ~2 iterations. In principle, this does not need a dataflow analysis but is used for convenience in favour of lean code.
This was referenced Aug 14, 2025
Xazax-hun
pushed a commit
to swiftlang/llvm-project
that referenced
this pull request
Dec 12, 2025
Refactored the lifetime safety analysis to use a generic dataflow framework with a policy-based design. - Introduced a generic `DataflowAnalysis` template class that can be specialized for different analyses - Renamed `LifetimeLattice` to `LoanPropagationLattice` to better reflect its purpose - Created a `LoanPropagationAnalysis` class that inherits from the generic framework - Moved transfer functions from the standalone `Transferer` class into the analysis class - Restructured the code to separate the dataflow engine from the specific analysis logic - Updated debug output and test expectations to use the new class names In order to add more analyses, e.g. [loan expiry](llvm#148712) and origin liveness, the previous implementation would have separate, nearly identical dataflow runners for each analysis. This change creates a single, reusable component, which will make it much simpler to add subsequent analyses without repeating boilerplate code. This is quite close to the existing dataflow framework!
Xazax-hun
pushed a commit
to swiftlang/llvm-project
that referenced
this pull request
Dec 12, 2025
This PR adds the `ExpiredLoansAnalysis` class to track which loans have expired. The analysis uses a dataflow lattice (`ExpiredLattice`) to maintain the set of expired loans at each program point. This is a very light weight dataflow analysis and is expected to reach fixed point in ~2 iterations. In principle, this does not need a dataflow analysis but is used for convenience in favour of lean code.
markrvmurray
pushed a commit
to markrvmurray/llvm-mc6809
that referenced
this pull request
Jun 14, 2026
Refactored the lifetime safety analysis to use a generic dataflow framework with a policy-based design. ### Changes - Introduced a generic `DataflowAnalysis` template class that can be specialized for different analyses - Renamed `LifetimeLattice` to `LoanPropagationLattice` to better reflect its purpose - Created a `LoanPropagationAnalysis` class that inherits from the generic framework - Moved transfer functions from the standalone `Transferer` class into the analysis class - Restructured the code to separate the dataflow engine from the specific analysis logic - Updated debug output and test expectations to use the new class names ### Motivation In order to add more analyses, e.g. [loan expiry](llvm/llvm-project#148712) and origin liveness, the previous implementation would have separate, nearly identical dataflow runners for each analysis. This change creates a single, reusable component, which will make it much simpler to add subsequent analyses without repeating boilerplate code. This is quite close to the existing dataflow framework!
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.

This PR adds the
ExpiredLoansAnalysisclass to track which loans have expired. The analysis uses a dataflow lattice (ExpiredLattice) to maintain the set of expired loans at each program point.This is a very light weight dataflow analysis and is expected to reach fixed point in ~2 iterations.
In principle, this does not need a dataflow analysis but is used for convenience in favour of lean code.