LLVM: lib/ExecutionEngine/Orc/ExecutorResolutionGenerator.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

10

14

15#define DEBUG_TYPE "orc"

16

17namespace llvm {

18namespace orc {

19

20Expected<std::unique_ptr>

25 if (H)

26 return H.takeError();

27 return std::make_unique(

28 ES, *H, std::move(Allow), std::move(AbsoluteSymbols));

29}

30

34

35 if (LookupSet.empty())

37

39 dbgs() << "ExecutorResolutionGenerator trying to generate " << LookupSet

40 << "\n";

41 });

42

44 for (auto &[Name, LookupFlag] : LookupSet) {

45 if (Allow && !Allow(Name))

46 continue;

47 LookupSymbols.add(Name, LookupFlag);

48 }

49

51 EPC.getDylibMgr().lookupSymbolsAsync(

52 LR, [this, LS = std::move(LS), JD = JITDylibSP(&JD),

53 LookupSymbols](auto Result) mutable {

56 dbgs() << "ExecutorResolutionGenerator lookup failed due to error";

57 });

58 return LS.continueLookup(Result.takeError());

59 }

61 "Results for more than one library returned");

62 assert(Result->front().size() == LookupSymbols.size() &&

63 "Result has incorrect number of elements");

64

65

66

67 auto Syms = Result->front().begin();

70 for (auto &[Name, Flags] : LookupSymbols) {

71 const auto &Sym = *Syms++;

72 if (Sym && Sym->getAddress())

73 NewSyms[Name] = *Sym;

76 MissingSymbols.insert(Name);

77 }

78

80 dbgs() << "ExecutorResolutionGenerator lookup returned " << NewSyms

81 << "\n";

82 });

83

84 if (NewSyms.empty())

86

89 this->EPC.getSymbolStringPool(), std::move(MissingSymbols)));

90

91 LS.continueLookup(JD->define(AbsoluteSymbols(std::move(NewSyms))));

92 });

93

95}

96

97}

98}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

#define LLVM_UNLIKELY(EXPR)

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

std::pair< iterator, bool > insert(const ValueT &V)

friend class ExecutionSession

virtual Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath)=0

Load the dynamic library at the given path and return a handle to it.

ExecutorProcessControl & getExecutorProcessControl()

Get the ExecutorProcessControl object associated with this ExecutionSession.

DylibManager & getDylibMgr() const

Return the DylibManager for the target process.

static Expected< std::unique_ptr< ExecutorResolutionGenerator > > Load(ExecutionSession &ES, const char *LibraryPath, SymbolPredicate Allow=SymbolPredicate(), AbsoluteSymbolsFn AbsoluteSymbols=absoluteSymbols)

Permanently loads the library at the given path and, on success, returns an ExecutorResolutionGenerat...

Definition ExecutorResolutionGenerator.cpp:21

unique_function< std::unique_ptr< MaterializationUnit >(SymbolMap)> AbsoluteSymbolsFn

Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &LookupSet) override

DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.

Definition ExecutorResolutionGenerator.cpp:31

unique_function< bool(const SymbolStringPtr &)> SymbolPredicate

Represents a JIT'd dynamic library.

Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)

Define all symbols provided by the materialization unit to be part of this JITDylib.

Wraps state for a lookup-in-progress.

A set of symbols to look up, each associated with a SymbolLookupFlags value.

IntrusiveRefCntPtr< JITDylib > JITDylibSP

JITDylibLookupFlags

Lookup flags that apply to each dylib in the search order for a lookup.

DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap

A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).

LookupKind

Describes the kind of lookup being performed.

DenseSet< SymbolStringPtr > SymbolNameSet

A set of symbol names (represented by SymbolStringPtrs for.

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

Error make_error(ArgTs &&... Args)

Make a Error instance representing failure using the given error info type.

A pair of a dylib and a set of symbols to be looked up.