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

1

2

3

4

5

6

7

8

12

13using namespace llvm;

15

20 LCTMgr(LCTMgr),

21 BuildIndirectStubsManager(std::move(BuildIndirectStubsManager)) {}

22

24 this->AliaseeImpls = Imp;

25}

26

28 std::unique_ptr R, ThreadSafeModule TSM) {

29 assert(TSM && "Null module");

30

32

33

34

35 auto &PDR = getPerDylibResources(R->getTargetJITDylib());

36

39

40 for (auto &KV : R->getSymbols()) {

41 auto &Name = KV.first;

42 auto &Flags = KV.second;

43 if (Flags.isCallable())

45 else

47 }

48

49

50 if (auto Err = PDR.getImplDylib().define(

51 std::make_unique(

53 ES.reportError(std::move(Err));

54 R->failMaterialization();

55 return;

56 }

57

58 if (!NonCallables.empty())

59 if (auto Err =

60 R->replace(reexports(PDR.getImplDylib(), std::move(NonCallables),

63 R->failMaterialization();

64 return;

65 }

66 if (!Callables.empty()) {

67 if (auto Err = R->replace(

68 lazyReexports(LCTMgr, PDR.getISManager(), PDR.getImplDylib(),

69 std::move(Callables), AliaseeImpls))) {

71 R->failMaterialization();

72 return;

73 }

74 }

75}

76

77CompileOnDemandLayer::PerDylibResources &

78CompileOnDemandLayer::getPerDylibResources(JITDylib &TargetD) {

79 std::lock_guardstd::mutex Lock(CODLayerMutex);

80

81 auto I = DylibResources.find(&TargetD);

82 if (I == DylibResources.end()) {

83 auto &ImplD =

87 NewLinkOrder = TargetLinkOrder;

88 });

89

90 assert(!NewLinkOrder.empty() && NewLinkOrder.front().first == &TargetD &&

91 NewLinkOrder.front().second ==

93 "TargetD must be at the front of its own search order and match "

94 "non-exported symbol");

95 NewLinkOrder.insert(std::next(NewLinkOrder.begin()),

96 {&ImplD, JITDylibLookupFlags::MatchAllSymbols});

97 ImplD.setLinkOrder(NewLinkOrder, false);

98 TargetD.setLinkOrder(std::move(NewLinkOrder), false);

99

100 PerDylibResources PDR(ImplD, BuildIndirectStubsManager());

101 I = DylibResources.insert(std::make_pair(&TargetD, std::move(PDR))).first;

102 }

103

104 return I->second;

105}

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

Module.h This file contains the declarations for the Module class.

const std::string & getName() const

Get the name for this JITLinkDylib.

void emit(std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM) override

Emits the given module.

Definition CompileOnDemandLayer.cpp:27

CompileOnDemandLayer(ExecutionSession &ES, IRLayer &BaseLayer, LazyCallThroughManager &LCTMgr, IndirectStubsManagerBuilder BuildIndirectStubsManager)

Construct a CompileOnDemandLayer.

Definition CompileOnDemandLayer.cpp:16

void setImplMap(ImplSymbolMap *Imp)

Sets the ImplSymbolMap.

Definition CompileOnDemandLayer.cpp:23

std::function< std::unique_ptr< IndirectStubsManager >()> IndirectStubsManagerBuilder

Builder for IndirectStubsManagers.

An ExecutionSession represents a running JIT program.

void reportError(Error Err)

Report a error for this execution session.

LLVM_ABI JITDylib & createBareJITDylib(std::string Name)

Add a new bare JITDylib to this ExecutionSession.

IRLayer(ExecutionSession &ES, const IRSymbolMapper::ManglingOptions *&MO)

ExecutionSession & getExecutionSession()

Returns the ExecutionSession for this layer.

const IRSymbolMapper::ManglingOptions *& getManglingOptions() const

Get the mangling options for this layer.

Represents a JIT'd dynamic library.

auto withLinkOrderDo(Func &&F) -> decltype(F(std::declval< const JITDylibSearchOrder & >()))

Do something with the link order (run under the session lock).

LLVM_ABI void setLinkOrder(JITDylibSearchOrder NewSearchOrder, bool LinkAgainstThisJITDylibFirst=true)

Set the link order to be used when fixing up definitions in JITDylib.

Manages a set of 'lazy call-through' trampolines.

An LLVM Module together with a shared ThreadSafeContext.

std::vector< std::pair< JITDylib *, JITDylibLookupFlags > > JITDylibSearchOrder

A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search order during symbol lookup.

std::unique_ptr< ReExportsMaterializationUnit > reexports(JITDylib &SourceJD, SymbolAliasMap Aliases, JITDylibLookupFlags SourceJDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)

Create a materialization unit for re-exporting symbols from another JITDylib with alternative names/f...

std::unique_ptr< LazyReexportsMaterializationUnit > lazyReexports(LazyCallThroughManager &LCTManager, RedirectableSymbolManager &RSManager, JITDylib &SourceJD, SymbolAliasMap CallableAliases, ImplSymbolMap *SrcJDLoc=nullptr)

Define lazy-reexports based on the given SymbolAliasMap.

DenseMap< SymbolStringPtr, SymbolAliasMapEntry > SymbolAliasMap

A map of Symbols to (Symbol, Flags) pairs.

This is an optimization pass for GlobalISel generic memory operations.

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.