[llvm-branch-commits] [clang] [LifetimeSafety] Introduce a liveness-based lifetime policy (PR #159991)
Utkarsh Saxena via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Sep 24 03:20:36 PDT 2025
================
@@ -1085,11 +1080,17 @@ class LoanPropagationAnalysis
/// Merges two lattices by taking the union of loans for each origin.
// TODO(opt): Keep the state small by removing origins which become dead.
Lattice join(Lattice A, Lattice B) {
- OriginLoanMap JoinedOrigins =
- utils::join(A.Origins, B.Origins, OriginLoanMapFactory,
- [&](LoanSet S1, LoanSet S2) {
- return utils::join(S1, S2, LoanSetFactory);
- });
+ OriginLoanMap JoinedOrigins = utils::join(
+ A.Origins, B.Origins, OriginLoanMapFactory,
+ [&](const LoanSet *S1, const LoanSet *S2) {
+ assert((S1 || S2) && "unexpectedly merging 2 empty sets");
+ if (!S1)
+ return *S2;
+ if (!S2)
+ return *S1;
+ return utils::join(*S1, *S2, LoanSetFactory);
+ },
+ /*JoinAllKeys=*/false);
----------------
usx95 wrote:
Primarily for performance. We can join all keys but we do not need to in case of Loan propagation analysis: we want the set difference to make it into the merged set "as-is". Same is not true for `Liveness` because of "confidence". We also want to demote the set difference to "Maybe" confidence.
Let me add a comment about this.
https://github.com/llvm/llvm-project/pull/159991
More information about the llvm-branch-commits
mailing list