Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[LifetimeSafety] Add loan expiry analysis#148712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
usx95 wants to merge1 commit intousers/usx95/07-16-lifetime-safety-add-unit-tests
base:users/usx95/07-16-lifetime-safety-add-unit-tests
Choose a base branch
Loading
fromusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry

Conversation

usx95
Copy link
Contributor

@usx95usx95 commentedJul 14, 2025
edited
Loading

This PR adds theExpiredLoansAnalysis 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.

@usx95Graphite App
Copy link
ContributorAuthor

usx95 commentedJul 14, 2025
edited
Loading

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stackon Graphite.
Learn more

This stack of pull requests is managed byGraphite. Learn more aboutstacking.

@usx95usx95 changed the titleusers/usx95/lifetime-safety-add-loan-expiry[LifetimeSafety] Add loan expiry analysisJul 14, 2025
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch from880cf3b toed73e3bCompareJuly 14, 2025 19:49
@usx95usx95force-pushed theusers/usx95/lifetime-safety-liveness branch fromc217d0d to702d255CompareJuly 14, 2025 19:49
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch fromed73e3b toa50b00eCompareJuly 14, 2025 19:52
@usx95usx95force-pushed theusers/usx95/lifetime-safety-liveness branch 2 times, most recently from7e098b0 to793d58eCompareJuly 14, 2025 20:02
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch froma50b00e toa9f1e8dCompareJuly 14, 2025 20:03
@usx95usx95 self-assigned thisJul 14, 2025
@usx95usx95force-pushed theusers/usx95/lifetime-safety-liveness branch from793d58e to2bff132CompareJuly 15, 2025 09:09
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch 5 times, most recently from6ce3173 to9265536CompareJuly 15, 2025 10:27
@usx95usx95force-pushed theusers/usx95/lifetime-safety-liveness branch from2253ff0 toc073ef3CompareJuly 15, 2025 10:27
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch from9265536 to9da8f3aCompareJuly 15, 2025 10:47
@usx95usx95force-pushed theusers/usx95/lifetime-safety-liveness branch fromc073ef3 to51afc3eCompareJuly 15, 2025 10:47
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch from9da8f3a to04d6193CompareJuly 15, 2025 17:53
@usx95usx95force-pushed theusers/usx95/lifetime-safety-liveness branch from51afc3e to7b26a72CompareJuly 15, 2025 17:53
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch from04d6193 to2073937CompareJuly 15, 2025 21:33
@usx95usx95 changed the base branch fromusers/usx95/lifetime-safety-liveness tousers/usx95/07-15-add-backward-analysis-capabilityJuly 15, 2025 21:35
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch 2 times, most recently from5f09913 toaca68c2CompareJuly 15, 2025 21:54
@usx95usx95force-pushed theusers/usx95/07-15-add-backward-analysis-capability branch fromb109b6a to7502ee5CompareJuly 15, 2025 21:54
@usx95usx95 requested a review fromjvoungJuly 15, 2025 22:03
@usx95usx95 moved this fromTodo toIn Progress inLifetime Safety in ClangJul 15, 2025
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch from8bbae58 to037a7ecCompareJuly 16, 2025 10:45
@ymand
Copy link
Collaborator

Looks good, but what's the plan for tests?

@usx95Graphite App
Copy link
ContributorAuthor

Looks good, but what's the plan for tests?

Good question :) I think adding tests for each analyses to the currentllvm-lit tests is quite a pain for the eyes at this point. Also I want to test things at specific program points (is loan expired here, does origin contain loan here, etc). I am exploring a couple of options, primarilyhttps://github.com/llvm/llvm-project/blob/main/clang/include/clang/Testing/TestAST.h,https://github.com/llvm/llvm-project/blob/main/clang/unittests/Analysis/FlowSensitive/TestingSupport.h and something likehttps://github.com/llvm/llvm-project/blob/main/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp#L874-L900

This will likely take some more time. Happy to hold this off until I add something like this for unit tests!

I would still rely on llvm-lit tests for final diagnostic reporting (or maybe that also can be done through unit testing)

Copy link
Collaborator

@Xazax-hunXazax-hun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Once the testing story is figured out this looks good to me.

};

/// The analysis that tracks which loans have expired.
class ExpiredLoansAnalysis
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

So we have the expectation that we have a tight bound on this analysis. I wonder if there is a way to somehow add an assert to verify that the reality matches our expectations. Not super important but if it is not too complicated it could be nice.

We can also defer this to a later PR since we want to be able to add strict bounds to the number of iterations in the future and that might be required for us to easily assert on this.

@usx95
Copy link
ContributorAuthor

Once the testing story is figured out this looks good to me.

Alright. I will add some unit test infra separately before this PR then!

@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch from037a7ec toa4cba20CompareJuly 16, 2025 14:08
@usx95usx95force-pushed theusers/usx95/07-15-add-backward-analysis-capability branch from9475733 to7762a38CompareJuly 16, 2025 14:08
usx95 added a commit that referenced this pull requestJul 16, 2025
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### MotivationIn order to add more analyses, e.g. [loan expiry](#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!
@usx95usx95force-pushed theusers/usx95/07-15-add-backward-analysis-capability branch 2 times, most recently from4a23369 tob76c916CompareJuly 16, 2025 14:22
Base automatically changed fromusers/usx95/07-15-add-backward-analysis-capability tomainJuly 16, 2025 14:25
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch froma4cba20 to7365fc4CompareJuly 16, 2025 14:27
llvm-syncbot pushed a commit to arm/arm-toolchain that referenced this pull requestJul 16, 2025
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### MotivationIn 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!
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch from7365fc4 toa7d03b1CompareJuly 16, 2025 22:10
@usx95usx95 changed the base branch frommain tousers/usx95/07-16-lifetime-safety-add-unit-testsJuly 17, 2025 17:47
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch froma7d03b1 tod5b093eCompareJuly 17, 2025 17:48
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch fromd5b093e to70b63edCompareJuly 17, 2025 18:54
@usx95usx95force-pushed theusers/usx95/07-16-lifetime-safety-add-unit-tests branch from16fccbd to3e0b53fCompareJuly 17, 2025 18:54
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch 2 times, most recently from9a3a69a to8c5c8f1CompareJuly 18, 2025 11:57
@usx95usx95force-pushed theusers/usx95/07-16-lifetime-safety-add-unit-tests branch from3e0b53f toe6fc855CompareJuly 18, 2025 11:57
@usx95usx95force-pushed theusers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry branch from8c5c8f1 toc29040aCompareJuly 18, 2025 14:27
@usx95usx95 requested a review fromXazax-hunJuly 18, 2025 14:28
@usx95
Copy link
ContributorAuthor

Added unit tests for loan expiry!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jvoungjvoungAwaiting requested review from jvoung

@ymandymandAwaiting requested review from ymand

@Xazax-hunXazax-hunAwaiting requested review from Xazax-hun

Assignees

@usx95usx95

Labels
clang:analysisclangClang issues not falling into any other category
Projects
Status: In Progress
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@usx95@llvmbot@ymand@Xazax-hun

[8]ページ先頭

©2009-2025 Movatter.jp