[llvm-branch-commits] [clang] [LifetimeSafety] Disable canonicalization in immutable collections (PR #159850)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Sep 19 14:46:43 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-analysis
Author: Utkarsh Saxena (usx95)
<details>
<summary>Changes</summary>
Disable canonicalization in immutable collections for lifetime analysis.
Modified the `LifetimeFactory` struct in `LifetimeSafety.cpp` to explicitly initialize the immutable collection factories with `canonicalize=false`. This prevents the factories from canonicalizing their data structures, which can improve performance by avoiding unnecessary comparisons and digest computations.
---
Full diff: https://github.com/llvm/llvm-project/pull/159850.diff
1 Files Affected:
- (modified) clang/lib/Analysis/LifetimeSafety.cpp (+6-3)
``````````diff
diff --git a/clang/lib/Analysis/LifetimeSafety.cpp b/clang/lib/Analysis/LifetimeSafety.cpp
index 0dd5716d93fb6..43cab406a9dc3 100644
--- a/clang/lib/Analysis/LifetimeSafety.cpp
+++ b/clang/lib/Analysis/LifetimeSafety.cpp
@@ -966,9 +966,12 @@ using ExpiredLoanMap = llvm::ImmutableMap<LoanID, const ExpireFact *>;
/// An object to hold the factories for immutable collections, ensuring
/// that all created states share the same underlying memory management.
struct LifetimeFactory {
- OriginLoanMap::Factory OriginMapFactory;
- LoanSet::Factory LoanSetFactory;
- ExpiredLoanMap::Factory ExpiredLoanMapFactory;
+ // Avoid canonicalising
+ OriginLoanMap::Factory OriginMapFactory =
+ OriginLoanMap::Factory(/*canonicalize=*/false);
+ LoanSet::Factory LoanSetFactory = LoanSet::Factory(/*canonicalize=*/false);
+ ExpiredLoanMap::Factory ExpiredLoanMapFactory =
+ ExpiredLoanMap::Factory(/*canonicalize=*/false);
};
/// Represents the dataflow lattice for loan propagation.
``````````
</details>
https://github.com/llvm/llvm-project/pull/159850
More information about the llvm-branch-commits
mailing list