[llvm] d162c91 - [ORC] Avoid self-dependence in SuperNode dependence graph. (#169286)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 24 03:50:34 PST 2025
Author: Lang Hames
Date: 2025-11-24T22:50:29+11:00
New Revision: d162c91c01a66e4af0af190044961e60db0eeb3d
URL: https://github.com/llvm/llvm-project/commit/d162c91c01a66e4af0af190044961e60db0eeb3d
DIFF: https://github.com/llvm/llvm-project/commit/d162c91c01a66e4af0af190044961e60db0eeb3d.diff
LOG: [ORC] Avoid self-dependence in SuperNode dependence graph. (#169286)
Avoid adding any given SuperNode SN to its own SuperNode-deps set. This
saves us from trying to redundantly merge its dependencies back into
itself (a no-op, but a potentially expensive one).
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h b/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h
index f9995917363f9..9f14c8b2efd5f 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h
@@ -500,7 +500,7 @@ template <typename ContainerIdT, typename ElementIdT> class WaitingOnGraph {
if (I == SN->Deps.end())
continue;
for (auto &[DefElem, DefSN] : DefElems)
- if (I->second.erase(DefElem))
+ if (I->second.erase(DefElem) && DefSN != SN.get())
SNDeps.insert(DefSN);
if (I->second.empty())
SN->Deps.erase(I);
@@ -511,11 +511,13 @@ template <typename ContainerIdT, typename ElementIdT> class WaitingOnGraph {
// Compute transitive closure of deps for each node.
static void propagateSuperNodeDeps(SuperNodeDepsMap &SuperNodeDeps) {
for (auto &[SN, Deps] : SuperNodeDeps) {
- DenseSet<SuperNode *> Reachable({SN});
+ DenseSet<SuperNode *> Reachable;
SmallVector<SuperNode *> Worklist(Deps.begin(), Deps.end());
while (!Worklist.empty()) {
auto *DepSN = Worklist.pop_back_val();
+ if (DepSN == SN)
+ continue;
if (!Reachable.insert(DepSN).second)
continue;
auto I = SuperNodeDeps.find(DepSN);
@@ -537,9 +539,11 @@ template <typename ContainerIdT, typename ElementIdT> class WaitingOnGraph {
if (I == SuperNodeDeps.end())
continue;
- for (auto *DepSN : I->second)
+ for (auto *DepSN : I->second) {
+ assert(DepSN != SN.get() && "Unexpected self-dependence for SN");
for (auto &[Container, Elems] : DepSN->Deps)
SN->Deps[Container].insert(Elems.begin(), Elems.end());
+ }
}
}
More information about the llvm-commits
mailing list