[llvm] [EquivalenceClasses] Introduce erase member function (PR #134660)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 9 08:36:55 PDT 2025


================
@@ -220,6 +221,56 @@ template <class ElemTy> class EquivalenceClasses {
     return *ECV;
   }
 
+  /// erase - Erase a value from the union/find set, return "true" if erase
+  /// succeeded.
+  bool erase(const ElemTy &V) {
+    if (!TheMapping.contains(V))
+      return false;
+    const ECValue *Cur = TheMapping[V];
+    const ECValue *Next = Cur->getNext();
+    if (Cur->isLeader()) {
+      // If the current element is the leader and has a successor element,
+      // update the successor element's 'Leader' field to be the last element,
+      // set the successor element's stolen bit, and set the 'Leader' field of
+      // all other elements in same class to be the successor element.
+      if (Next) {
----------------
kuhar wrote:

Can we combine this if with the previous one?

https://github.com/llvm/llvm-project/pull/134660


More information about the llvm-commits mailing list