]> granicus.if.org Git - llvm/commitdiff
[ORC] Simplify logic for updating edges when should-discard atoms are pruned.
authorLang Hames <lhames@gmail.com>
Thu, 9 May 2019 22:03:58 +0000 (22:03 +0000)
committerLang Hames <lhames@gmail.com>
Thu, 9 May 2019 22:03:58 +0000 (22:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360384 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp

index 8e4cfa05363a88f7a4d216a08df5d32170b2269b..b3477f1ee4ce43ffc5ec3c45e48900aab96646d9 100644 (file)
@@ -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