19 :
IRLayer(ES, BaseLayer.getManglingOptions()), BaseLayer(BaseLayer),
21 BuildIndirectStubsManager(
std::
move(BuildIndirectStubsManager)) {}
24 this->AliaseeImpls = Imp;
29 assert(TSM &&
"Null module");
35 auto &PDR = getPerDylibResources(R->getTargetJITDylib());
40 for (
auto &KV : R->getSymbols()) {
41 auto &
Name = KV.first;
42 auto &Flags = KV.second;
43 if (Flags.isCallable())
50 if (
auto Err = PDR.getImplDylib().define(
51 std::make_unique<BasicIRLayerMaterializationUnit>(
53 ES.reportError(std::move(Err));
54 R->failMaterialization();
58 if (!NonCallables.
empty())
60 R->replace(
reexports(PDR.getImplDylib(), std::move(NonCallables),
63 R->failMaterialization();
66 if (!Callables.
empty()) {
67 if (
auto Err = R->replace(
69 std::move(Callables), AliaseeImpls))) {
71 R->failMaterialization();
77CompileOnDemandLayer::PerDylibResources &
78CompileOnDemandLayer::getPerDylibResources(
JITDylib &TargetD) {
79 std::lock_guard<std::mutex> Lock(CODLayerMutex);
81 auto I = DylibResources.find(&TargetD);
82 if (
I == DylibResources.end()) {
87 NewLinkOrder = TargetLinkOrder;
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);
100 PerDylibResources PDR(ImplD, BuildIndirectStubsManager());
101 I = DylibResources.insert(std::make_pair(&TargetD, std::move(PDR))).first;
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const std::string & getName() const
Get the name for this JITLinkDylib.
std::function< std::unique_ptr< IndirectStubsManager >()> IndirectStubsManagerBuilder
Builder for IndirectStubsManagers.
void emit(std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM) override
Emits the given module.
CompileOnDemandLayer(ExecutionSession &ES, IRLayer &BaseLayer, LazyCallThroughManager &LCTMgr, IndirectStubsManagerBuilder BuildIndirectStubsManager)
Construct a CompileOnDemandLayer.
void setImplMap(ImplSymbolMap *Imp)
Sets the ImplSymbolMap.
An ExecutionSession represents a running JIT program.
void reportError(Error Err)
Report a error for this execution session.
JITDylib & createBareJITDylib(std::string Name)
Add a new bare JITDylib to this ExecutionSession.
Interface for layers that accept LLVM IR.
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).
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.
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.