LLVM: lib/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.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>

24 auto Handle =

26 if (!Handle)

27 return Handle.takeError();

28

29 return std::make_unique(

30 ES, *Handle, std::move(Allow), std::move(AddAbsoluteSymbols));

31}

32

36

37 if (Symbols.empty())

39

41 dbgs() << "EPCDynamicLibrarySearchGenerator trying to generate "

42 << Symbols << "\n";

43 });

44

45

46 if (!H) {

47 assert(Allow && "No handle or filter?");

49 for (auto &[Name, LookupFlags] : Symbols) {

50 if (Allow(Name))

51 Nulls[Name] = {};

52 }

53 return addAbsolutes(JD, std::move(Nulls));

54 }

55

56

58

59 for (auto &KV : Symbols) {

60

61 if (Allow && !Allow(KV.first))

62 continue;

64 }

65

67

68 EPC.getDylibMgr().lookupSymbolsAsync(Request, [this, &JD, LS = std::move(LS),

69 LookupSymbols](

70 auto Result) mutable {

73 dbgs() << "EPCDynamicLibrarySearchGenerator lookup failed due to error";

74 });

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

76 }

77

78 assert(Result->size() == 1 && "Results for more than one library returned");

80 "Result has incorrect number of elements");

81

82 auto SymsIt = Result->front().begin();

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

86 const auto &Sym = *SymsIt++;

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

88 NewSymbols[Name] = *Sym;

91 MissingSymbols.insert(Name);

92 }

93

95 dbgs() << "EPCDynamicLibrarySearchGenerator lookup returned "

96 << NewSymbols << "\n";

97 });

98

99

100 if (NewSymbols.empty())

102

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

106

107

108 Error Err = addAbsolutes(JD, std::move(NewSymbols));

109

110 LS.continueLookup(std::move(Err));

111 });

112

114}

115

116Error EPCDynamicLibrarySearchGenerator::addAbsolutes(JITDylib &JD,

118 return AddAbsoluteSymbols ? AddAbsoluteSymbols(JD, std::move(Symbols))

120}

121

122}

123}

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.

static Expected< std::unique_ptr< EPCDynamicLibrarySearchGenerator > > Load(ExecutionSession &ES, const char *LibraryPath, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)

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

Definition EPCDynamicLibrarySearchGenerator.cpp:21

unique_function< bool(const SymbolStringPtr &)> SymbolPredicate

unique_function< Error(JITDylib &, SymbolMap)> AddAbsoluteSymbolsFn

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

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

Definition EPCDynamicLibrarySearchGenerator.cpp:33

ExecutorProcessControl & getExecutorProcessControl()

Get the ExecutorProcessControl object associated with this ExecutionSession.

DylibManager & getDylibMgr() const

Return the DylibManager for the target process.

Represents a JIT'd dynamic library.

Wraps state for a lookup-in-progress.

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

UnderlyingVector::size_type size() const

SymbolLookupSet & add(SymbolStringPtr Name, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)

Add an element to the set.

std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)

Create an AbsoluteSymbolsMaterializationUnit with the given symbols.

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.

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

Implement std::hash so that hash_code can be used in STL containers.

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