[llvm] r360384 - [ORC] Simplify logic for updating edges when should-discard atoms are pruned.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 15:03:59 PDT 2019


Author: lhames
Date: Thu May  9 15:03:58 2019
New Revision: 360384

URL: http://llvm.org/viewvc/llvm-project?rev=360384&view=rev
Log:
[ORC] Simplify logic for updating edges when should-discard atoms are pruned.

Modified:
    llvm/trunk/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp

Modified: llvm/trunk/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp?rev=360384&r1=360383&r2=360384&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp Thu May  9 15:03:58 2019
@@ -433,28 +433,16 @@ void prune(AtomGraph &G) {
     //
     // We replace if all of the following hold:
     //   (1) The atom is marked should-discard,
-    //   (2) it is live, and
-    //   (3) it has edges pointing to it.
+    //   (2) it has live edges (i.e. edges from live atoms) pointing to it.
     //
     // Otherwise we simply delete the atom.
-    bool ReplaceWithExternal = DA->isLive() && DA->shouldDiscard();
-    std::vector<Edge *> *EdgesToUpdateForDA = nullptr;
-    if (ReplaceWithExternal) {
-      auto ETUItr = EdgesToUpdate.find(DA);
-      if (ETUItr == EdgesToUpdate.end())
-        ReplaceWithExternal = false;
-      else
-        EdgesToUpdateForDA = &ETUItr->second;
-    }
 
     G.removeDefinedAtom(*DA);
 
-    if (ReplaceWithExternal) {
-      assert(EdgesToUpdateForDA &&
-             "Replacing atom: There should be edges to update");
-
+    auto EdgesToUpdateItr = EdgesToUpdate.find(DA);
+    if (EdgesToUpdateItr != EdgesToUpdate.end()) {
       auto &ExternalReplacement = G.addExternalAtom(DA->getName());
-      for (auto *EdgeToUpdate : *EdgesToUpdateForDA)
+      for (auto *EdgeToUpdate : EdgesToUpdateItr->second)
         EdgeToUpdate->setTarget(ExternalReplacement);
       LLVM_DEBUG(dbgs() << "replaced with " << ExternalReplacement << "\n");
     } else




More information about the llvm-commits mailing list