[llvm] [ORC] Refactor WaitingOnGraph::processExternalDeps. NFCI. (PR #185152)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 21:24:01 PST 2026


https://github.com/lhames created https://github.com/llvm/llvm-project/pull/185152

Refactor WaitingOnGraph::processExternalDeps to use the recently introduced ContainerElementsMap::visit and ElementSet::remove_if methods.

>From 8723b16fc5898fa8e197bf16528f4846f5dafb5e Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Sat, 7 Mar 2026 16:15:52 +1100
Subject: [PATCH] [ORC] Refactor WaitingOnGraph::processExternalDeps. NFCI.

Refactor WaitingOnGraph::processExternalDeps to use the recently introduced
ContainerElementsMap::visit and ElementSet::remove_if methods.
---
 .../llvm/ExecutionEngine/Orc/WaitingOnGraph.h | 34 ++++++-------------
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h b/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h
index 9cd534fa446a7..2ffd6bd6cbffd 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h
@@ -725,34 +725,20 @@ template <typename ContainerIdT, typename ElementIdT> class WaitingOnGraph {
   processExternalDeps(std::vector<std::unique_ptr<SuperNode>> &SNs,
                       GetExternalStateFn &GetExternalState) {
     DenseSet<SuperNode *> FailedSNs;
-    for (auto &SN : SNs) {
-      bool SNHasError = false;
-      SmallVector<ContainerId> ContainersToRemove;
-      for (auto &[Container, Elems] : SN->Deps) {
-        SmallVector<ElementId> ElemToRemove;
-        for (auto &Elem : Elems) {
+    for (auto &SN : SNs)
+      SN->Deps.visit([&](ContainerId &Container, ElementSet &Elements) {
+        return Elements.remove_if([&](ElementId &Elem) {
           switch (GetExternalState(Container, Elem)) {
           case ExternalState::None:
-            break;
+            return false;
           case ExternalState::Ready:
-            ElemToRemove.push_back(Elem);
-            break;
+            return true;
           case ExternalState::Failed:
-            ElemToRemove.push_back(Elem);
-            SNHasError = true;
-            break;
-          }
-        }
-        for (auto &Elem : ElemToRemove)
-          Elems.erase(Elem);
-        if (Elems.empty())
-          ContainersToRemove.push_back(Container);
-      }
-      for (auto &Container : ContainersToRemove)
-        SN->Deps.erase(Container);
-      if (SNHasError)
-        FailedSNs.insert(SN.get());
-    }
+            FailedSNs.insert(SN.get());
+            return true;
+          };
+        });
+      });
 
     return FailedSNs;
   }



More information about the llvm-commits mailing list