LCOV - code coverage report
Current view: top level - lib/ExecutionEngine/Orc - Legacy.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 19 22 86.4 %
Date: 2018-10-20 13:21:21 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===------- Legacy.cpp - Adapters for ExecutionEngine API interop --------===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #include "llvm/ExecutionEngine/Orc/Legacy.h"
      11             : 
      12             : namespace llvm {
      13             : namespace orc {
      14             : 
      15           0 : void SymbolResolver::anchor() {}
      16             : 
      17         102 : JITSymbolResolverAdapter::JITSymbolResolverAdapter(
      18         102 :     ExecutionSession &ES, SymbolResolver &R, MaterializationResponsibility *MR)
      19         204 :     : ES(ES), R(R), MR(MR) {}
      20             : 
      21          40 : void JITSymbolResolverAdapter::lookup(const LookupSet &Symbols,
      22             :                                       OnResolvedFunction OnResolved) {
      23             :   SymbolNameSet InternedSymbols;
      24         105 :   for (auto &S : Symbols)
      25         130 :     InternedSymbols.insert(ES.intern(S));
      26             : 
      27          40 :   auto OnResolvedWithUnwrap = [OnResolved](Expected<SymbolMap> InternedResult) {
      28             :     if (!InternedResult) {
      29             :       OnResolved(InternedResult.takeError());
      30             :       return;
      31             :     }
      32             : 
      33             :     LookupResult Result;
      34             :     for (auto &KV : *InternedResult)
      35             :       Result[*KV.first] = std::move(KV.second);
      36             :     OnResolved(Result);
      37             :   };
      38             : 
      39             :   auto Q = std::make_shared<AsynchronousSymbolQuery>(
      40             :       InternedSymbols, OnResolvedWithUnwrap,
      41          40 :       [this](Error Err) { ES.reportError(std::move(Err)); });
      42             : 
      43         160 :   auto Unresolved = R.lookup(Q, InternedSymbols);
      44          40 :   if (Unresolved.empty()) {
      45          40 :     if (MR)
      46           0 :       MR->addDependenciesForAll(Q->QueryRegistrations);
      47             :   } else
      48           0 :     ES.legacyFailQuery(*Q, make_error<SymbolsNotFound>(std::move(Unresolved)));
      49          40 : }
      50             : 
      51             : Expected<JITSymbolResolverAdapter::LookupSet>
      52         102 : JITSymbolResolverAdapter::getResponsibilitySet(const LookupSet &Symbols) {
      53             :   SymbolNameSet InternedSymbols;
      54         121 :   for (auto &S : Symbols)
      55          38 :     InternedSymbols.insert(ES.intern(S));
      56             : 
      57         102 :   auto InternedResult = R.getResponsibilitySet(InternedSymbols);
      58             :   LookupSet Result;
      59         119 :   for (auto &S : InternedResult) {
      60             :     ResolvedStrings.insert(S);
      61          34 :     Result.insert(*S);
      62             :   }
      63             : 
      64         102 :   return Result;
      65             : }
      66             : 
      67             : } // End namespace orc.
      68             : } // End namespace llvm.

Generated by: LCOV version 1.13