[llvm] 61ba60c - [orc] Avoid pathological propogation order (#107488)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 08:35:33 PDT 2024


Author: Ben Langmuir
Date: 2024-09-06T08:35:30-07:00
New Revision: 61ba60c15416db03872e94217fcc215371caad5d

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

LOG: [orc] Avoid pathological propogation order (#107488)

In certain pathological object files we were getting extremely slow
linking because we were repeatedly propogating dependencies to the same
blocks instead of accumulating as many changes as possible. Change the
order of iteration so that we go through every node in the worklist
before returning to any previous node, reducing the number of expensive
dependency iterations.

In practice, this took one case from 60 seconds to 2 seconds. Note: the
performance is still non-deterministic, because the block order itself
is non-deterministic.

rdar://133734391

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
index a66c40ddb68775..073c25ea788c25 100644
--- a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
@@ -605,7 +605,7 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
       bool DependenciesChanged = true;
     };
     DenseMap<Block *, BlockInfo> BlockInfos;
-    SmallVector<Block *> WorkList;
+    std::deque<Block *> WorkList;
 
     // Pre-allocate map entries. This prevents any iterator/reference
     // invalidation in the next loop.
@@ -637,7 +637,8 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
 
     // Propagate block-level dependencies through the block-dependence graph.
     while (!WorkList.empty()) {
-      auto *B = WorkList.pop_back_val();
+      auto *B = WorkList.back();
+      WorkList.pop_back();
 
       auto &BI = BlockInfos[B];
       assert(BI.DependenciesChanged &&
@@ -650,7 +651,7 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
               DependantBI.Dependencies.insert(Dependency).second)
             if (!DependantBI.DependenciesChanged) {
               DependantBI.DependenciesChanged = true;
-              WorkList.push_back(Dependant);
+              WorkList.push_front(Dependant);
             }
         }
       }


        


More information about the llvm-commits mailing list