[llvm] r330141 - [ORC] Merge VSO notifyResolutionFailed and notifyFinalizationFailed in to

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 16 11:05:22 PDT 2018


Author: lhames
Date: Mon Apr 16 11:05:22 2018
New Revision: 330141

URL: http://llvm.org/viewvc/llvm-project?rev=330141&view=rev
Log:
[ORC] Merge VSO notifyResolutionFailed and notifyFinalizationFailed in to
notifyMaterializationFailed.

The notifyMaterializationFailed method can determine which error to raise by
looking at which queue the pending queries are in (resolution or finalization).

Modified:
    llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h
    llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp
    llvm/trunk/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp

Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h?rev=330141&r1=330140&r2=330141&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h Mon Apr 16 11:05:22 2018
@@ -291,14 +291,11 @@ public:
   ///        mark the symbols as finalized yet.
   void resolve(const SymbolMap &SymbolValues);
 
-  /// @brief Notify the VSO that the given symbols failed to finalize.
-  void notifyResolutionFailed(const SymbolNameSet &Names);
-
   /// @brief Finalize the given symbols.
   void finalize(const SymbolNameSet &SymbolsToFinalize);
 
-  /// @brief Notify the VSO that the given symbols failed to finalize.
-  void notifyFinalizationFailed(const SymbolNameSet &Names);
+  /// @brief Notify the VSO that the given symbols failed to materialized.
+  void notifyMaterializationFailed(const SymbolNameSet &Names);
 
   /// @brief Look up the flags for the given symbols.
   ///

Modified: llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp?rev=330141&r1=330140&r2=330141&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp Mon Apr 16 11:05:22 2018
@@ -390,11 +390,13 @@ void VSO::resolve(const SymbolMap &Symbo
   }
 }
 
-void VSO::notifyResolutionFailed(const SymbolNameSet &Names) {
-  assert(!Names.empty() && "Failed to resolve empty set?");
+void VSO::notifyMaterializationFailed(const SymbolNameSet &Names) {
+  assert(!Names.empty() && "Failed to materialize empty set?");
 
   std::map<std::shared_ptr<AsynchronousSymbolQuery>, SymbolNameSet>
-      QueriesToFail;
+      ResolutionFailures;
+  std::map<std::shared_ptr<AsynchronousSymbolQuery>, SymbolNameSet>
+      FinalizationFailures;
 
   for (auto &S : Names) {
     auto I = Symbols.find(S);
@@ -402,17 +404,23 @@ void VSO::notifyResolutionFailed(const S
 
     auto J = MaterializingInfos.find(S);
     if (J != MaterializingInfos.end()) {
-      assert(J->second.PendingFinalization.empty() &&
-             "Failed during resolution, but queries pending finalization?");
-      for (auto &Q : J->second.PendingResolution)
-        QueriesToFail[Q].insert(S);
+      if (J->second.PendingFinalization.empty()) {
+        for (auto &Q : J->second.PendingResolution)
+          ResolutionFailures[Q].insert(S);
+      } else {
+        for (auto &Q : J->second.PendingFinalization)
+          FinalizationFailures[Q].insert(S);
+      }
       MaterializingInfos.erase(J);
     }
     Symbols.erase(I);
   }
 
-  for (auto &KV : QueriesToFail)
+  for (auto &KV : ResolutionFailures)
     KV.first->notifyFailed(make_error<FailedToResolve>(std::move(KV.second)));
+
+  for (auto &KV : FinalizationFailures)
+    KV.first->notifyFailed(make_error<FailedToFinalize>(std::move(KV.second)));
 }
 
 void VSO::finalize(const SymbolNameSet &SymbolsToFinalize) {
@@ -432,33 +440,6 @@ void VSO::finalize(const SymbolNameSet &
   }
 }
 
-void VSO::notifyFinalizationFailed(const SymbolNameSet &Names) {
-  assert(!Names.empty() && "Failed to finalize empty set?");
-
-  std::map<std::shared_ptr<AsynchronousSymbolQuery>, SymbolNameSet>
-      QueriesToFail;
-
-  for (auto &S : Names) {
-    auto I = Symbols.find(S);
-    assert(I != Symbols.end() && "Symbol not present in this VSO");
-    assert((I->second.Flags & JITSymbolFlags::Materializing) &&
-           "Failed to finalize symbol that was not materializing");
-
-    auto J = MaterializingInfos.find(S);
-    if (J != MaterializingInfos.end()) {
-      assert(J->second.PendingResolution.empty() &&
-             "Failed during finalization, but queries pending resolution?");
-      for (auto &Q : J->second.PendingFinalization)
-        QueriesToFail[Q].insert(S);
-      MaterializingInfos.erase(J);
-    }
-    Symbols.erase(I);
-  }
-
-  for (auto &KV : QueriesToFail)
-    KV.first->notifyFailed(make_error<FailedToFinalize>(std::move(KV.second)));
-}
-
 SymbolNameSet VSO::lookupFlags(SymbolFlagsMap &Flags, SymbolNameSet Names) {
 
   for (SymbolNameSet::iterator I = Names.begin(), E = Names.end(); I != E;) {

Modified: llvm/trunk/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp?rev=330141&r1=330140&r2=330141&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp Mon Apr 16 11:05:22 2018
@@ -323,7 +323,7 @@ TEST(CoreAPIsTest, FailResolution) {
             {{Foo, JITSymbolFlags::Weak}, {Bar, JITSymbolFlags::Weak}});
       },
       [&](VSO &V) -> Error {
-        V.notifyResolutionFailed(Names);
+        V.notifyMaterializationFailed(Names);
         return Error::success();
       },
       [&](VSO &V, SymbolStringPtr Name) {
@@ -384,7 +384,7 @@ TEST(CoreAPIsTest, FailFinalization) {
         auto FooSym = JITEvaluatedSymbol(FakeFooAddr, JITSymbolFlags::Exported);
         auto BarSym = JITEvaluatedSymbol(FakeBarAddr, JITSymbolFlags::Exported);
         V.resolve(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}));
-        V.notifyFinalizationFailed(Names);
+        V.notifyMaterializationFailed(Names);
         return Error::success();
       },
       [&](VSO &V, SymbolStringPtr Name) {




More information about the llvm-commits mailing list