[clang] a11e844 - [clang][LifetimeSafety] Short-circuit joins of identical immutable containers (#208908)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 11 08:38:29 PDT 2026


Author: Gábor Horváth
Date: 2026-07-11T16:38:24+01:00
New Revision: a11e844f4e3302d47c7934e4817f14639e510aad

URL: https://github.com/llvm/llvm-project/commit/a11e844f4e3302d47c7934e4817f14639e510aad
DIFF: https://github.com/llvm/llvm-project/commit/a11e844f4e3302d47c7934e4817f14639e510aad.diff

LOG: [clang][LifetimeSafety] Short-circuit joins of identical immutable containers (#208908)

Added: 
    

Modified: 
    clang/include/clang/Analysis/Analyses/LifetimeSafety/Utils.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Analysis/Analyses/LifetimeSafety/Utils.h b/clang/include/clang/Analysis/Analyses/LifetimeSafety/Utils.h
index 101ee083f0d95..543bbd045593c 100644
--- a/clang/include/clang/Analysis/Analyses/LifetimeSafety/Utils.h
+++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety/Utils.h
@@ -38,6 +38,8 @@ template <typename Tag> struct ID {
 template <typename T>
 llvm::ImmutableSet<T> join(llvm::ImmutableSet<T> A, llvm::ImmutableSet<T> B,
                            typename llvm::ImmutableSet<T>::Factory &F) {
+  if (A.getRootWithoutRetain() == B.getRootWithoutRetain())
+    return A;
   if (A.getHeight() < B.getHeight())
     std::swap(A, B);
   for (const T &E : B)
@@ -70,6 +72,8 @@ llvm::ImmutableMap<K, V> join(const llvm::ImmutableMap<K, V> &A,
                               const llvm::ImmutableMap<K, V> &B,
                               typename llvm::ImmutableMap<K, V>::Factory &F,
                               Joiner JoinValues, JoinKind Kind) {
+  if (A.getRootWithoutRetain() == B.getRootWithoutRetain())
+    return A;
   if (A.getHeight() < B.getHeight())
     return join(B, A, F, JoinValues, Kind);
 


        


More information about the cfe-commits mailing list