1 //===- CompileOnDemandLayer.h - Compile each function on demand -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // JIT layer for breaking up modules and inserting callbacks to allow
11 // individual functions to be compiled on demand.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
16 #define LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
18 #include "llvm/ADT/APInt.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/ADT/Twine.h"
22 #include "llvm/ExecutionEngine/JITSymbol.h"
23 #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
24 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
25 #include "llvm/ExecutionEngine/Orc/Layer.h"
26 #include "llvm/ExecutionEngine/Orc/Legacy.h"
27 #include "llvm/ExecutionEngine/Orc/OrcError.h"
28 #include "llvm/ExecutionEngine/RuntimeDyld.h"
29 #include "llvm/IR/Attributes.h"
30 #include "llvm/IR/Constant.h"
31 #include "llvm/IR/Constants.h"
32 #include "llvm/IR/DataLayout.h"
33 #include "llvm/IR/Function.h"
34 #include "llvm/IR/GlobalAlias.h"
35 #include "llvm/IR/GlobalValue.h"
36 #include "llvm/IR/GlobalVariable.h"
37 #include "llvm/IR/Instruction.h"
38 #include "llvm/IR/Mangler.h"
39 #include "llvm/IR/Module.h"
40 #include "llvm/IR/Type.h"
41 #include "llvm/Support/Casting.h"
42 #include "llvm/Support/raw_ostream.h"
43 #include "llvm/Transforms/Utils/ValueMapper.h"
61 class ExtractingIRMaterializationUnit;
63 class CompileOnDemandLayer2 : public IRLayer {
64 friend class ExtractingIRMaterializationUnit;
67 /// Builder for IndirectStubsManagers.
68 using IndirectStubsManagerBuilder =
69 std::function<std::unique_ptr<IndirectStubsManager>()>;
71 using GetAvailableContextFunction = std::function<LLVMContext &()>;
73 CompileOnDemandLayer2(ExecutionSession &ES, IRLayer &BaseLayer,
74 JITCompileCallbackManager &CCMgr,
75 IndirectStubsManagerBuilder BuildIndirectStubsManager,
76 GetAvailableContextFunction GetAvailableContext);
78 Error add(VSO &V, VModuleKey K, std::unique_ptr<Module> M) override;
80 void emit(MaterializationResponsibility R, VModuleKey K,
81 std::unique_ptr<Module> M) override;
84 using StubManagersMap =
85 std::map<const VSO *, std::unique_ptr<IndirectStubsManager>>;
87 IndirectStubsManager &getStubsManager(const VSO &V);
89 void emitExtractedFunctionsModule(MaterializationResponsibility R,
90 std::unique_ptr<Module> M);
92 mutable std::mutex CODLayerMutex;
95 JITCompileCallbackManager &CCMgr;
96 IndirectStubsManagerBuilder BuildIndirectStubsManager;
97 StubManagersMap StubsMgrs;
98 GetAvailableContextFunction GetAvailableContext;
101 /// Compile-on-demand layer.
103 /// When a module is added to this layer a stub is created for each of its
104 /// function definitions. The stubs and other global values are immediately
105 /// added to the layer below. When a stub is called it triggers the extraction
106 /// of the function body from the original module. The extracted body is then
107 /// compiled and executed.
108 template <typename BaseLayerT,
109 typename CompileCallbackMgrT = JITCompileCallbackManager,
110 typename IndirectStubsMgrT = IndirectStubsManager>
111 class CompileOnDemandLayer {
113 template <typename MaterializerFtor>
114 class LambdaMaterializer final : public ValueMaterializer {
116 LambdaMaterializer(MaterializerFtor M) : M(std::move(M)) {}
118 Value *materialize(Value *V) final { return M(V); }
124 template <typename MaterializerFtor>
125 LambdaMaterializer<MaterializerFtor>
126 createLambdaMaterializer(MaterializerFtor M) {
127 return LambdaMaterializer<MaterializerFtor>(std::move(M));
130 // Provide type-erasure for the Modules and MemoryManagers.
131 template <typename ResourceT>
132 class ResourceOwner {
134 ResourceOwner() = default;
135 ResourceOwner(const ResourceOwner &) = delete;
136 ResourceOwner &operator=(const ResourceOwner &) = delete;
137 virtual ~ResourceOwner() = default;
139 virtual ResourceT& getResource() const = 0;
142 template <typename ResourceT, typename ResourcePtrT>
143 class ResourceOwnerImpl : public ResourceOwner<ResourceT> {
145 ResourceOwnerImpl(ResourcePtrT ResourcePtr)
146 : ResourcePtr(std::move(ResourcePtr)) {}
148 ResourceT& getResource() const override { return *ResourcePtr; }
151 ResourcePtrT ResourcePtr;
154 template <typename ResourceT, typename ResourcePtrT>
155 std::unique_ptr<ResourceOwner<ResourceT>>
156 wrapOwnership(ResourcePtrT ResourcePtr) {
157 using RO = ResourceOwnerImpl<ResourceT, ResourcePtrT>;
158 return llvm::make_unique<RO>(std::move(ResourcePtr));
161 class StaticGlobalRenamer {
163 StaticGlobalRenamer() = default;
164 StaticGlobalRenamer(StaticGlobalRenamer &&) = default;
165 StaticGlobalRenamer &operator=(StaticGlobalRenamer &&) = default;
167 void rename(Module &M) {
169 if (F.hasLocalLinkage())
170 F.setName("$static." + Twine(NextId++));
171 for (auto &G : M.globals())
172 if (G.hasLocalLinkage())
173 G.setName("$static." + Twine(NextId++));
180 struct LogicalDylib {
181 struct SourceModuleEntry {
182 std::unique_ptr<Module> SourceMod;
183 std::set<Function*> StubsToClone;
186 using SourceModulesList = std::vector<SourceModuleEntry>;
187 using SourceModuleHandle = typename SourceModulesList::size_type;
189 LogicalDylib() = default;
191 LogicalDylib(VModuleKey K, std::shared_ptr<SymbolResolver> BackingResolver,
192 std::unique_ptr<IndirectStubsMgrT> StubsMgr)
193 : K(std::move(K)), BackingResolver(std::move(BackingResolver)),
194 StubsMgr(std::move(StubsMgr)) {}
196 SourceModuleHandle addSourceModule(std::unique_ptr<Module> M) {
197 SourceModuleHandle H = SourceModules.size();
198 SourceModules.push_back(SourceModuleEntry());
199 SourceModules.back().SourceMod = std::move(M);
203 Module& getSourceModule(SourceModuleHandle H) {
204 return *SourceModules[H].SourceMod;
207 std::set<Function*>& getStubsToClone(SourceModuleHandle H) {
208 return SourceModules[H].StubsToClone;
211 JITSymbol findSymbol(BaseLayerT &BaseLayer, const std::string &Name,
212 bool ExportedSymbolsOnly) {
213 if (auto Sym = StubsMgr->findStub(Name, ExportedSymbolsOnly))
215 for (auto BLK : BaseLayerVModuleKeys)
216 if (auto Sym = BaseLayer.findSymbolIn(BLK, Name, ExportedSymbolsOnly))
218 else if (auto Err = Sym.takeError())
219 return std::move(Err);
223 Error removeModulesFromBaseLayer(BaseLayerT &BaseLayer) {
224 for (auto &BLK : BaseLayerVModuleKeys)
225 if (auto Err = BaseLayer.removeModule(BLK))
227 return Error::success();
231 std::shared_ptr<SymbolResolver> BackingResolver;
232 std::unique_ptr<IndirectStubsMgrT> StubsMgr;
233 StaticGlobalRenamer StaticRenamer;
234 SourceModulesList SourceModules;
235 std::vector<VModuleKey> BaseLayerVModuleKeys;
240 /// Module partitioning functor.
241 using PartitioningFtor = std::function<std::set<Function*>(Function&)>;
243 /// Builder for IndirectStubsManagers.
244 using IndirectStubsManagerBuilderT =
245 std::function<std::unique_ptr<IndirectStubsMgrT>()>;
247 using SymbolResolverGetter =
248 std::function<std::shared_ptr<SymbolResolver>(VModuleKey K)>;
250 using SymbolResolverSetter =
251 std::function<void(VModuleKey K, std::shared_ptr<SymbolResolver> R)>;
253 /// Construct a compile-on-demand layer instance.
254 CompileOnDemandLayer(ExecutionSession &ES, BaseLayerT &BaseLayer,
255 SymbolResolverGetter GetSymbolResolver,
256 SymbolResolverSetter SetSymbolResolver,
257 PartitioningFtor Partition,
258 CompileCallbackMgrT &CallbackMgr,
259 IndirectStubsManagerBuilderT CreateIndirectStubsManager,
260 bool CloneStubsIntoPartitions = true)
261 : ES(ES), BaseLayer(BaseLayer),
262 GetSymbolResolver(std::move(GetSymbolResolver)),
263 SetSymbolResolver(std::move(SetSymbolResolver)),
264 Partition(std::move(Partition)), CompileCallbackMgr(CallbackMgr),
265 CreateIndirectStubsManager(std::move(CreateIndirectStubsManager)),
266 CloneStubsIntoPartitions(CloneStubsIntoPartitions) {}
268 ~CompileOnDemandLayer() {
269 // FIXME: Report error on log.
270 while (!LogicalDylibs.empty())
271 consumeError(removeModule(LogicalDylibs.begin()->first));
274 /// Add a module to the compile-on-demand layer.
275 Error addModule(VModuleKey K, std::unique_ptr<Module> M) {
277 assert(!LogicalDylibs.count(K) && "VModuleKey K already in use");
278 auto I = LogicalDylibs.insert(
280 std::make_pair(K, LogicalDylib(K, GetSymbolResolver(K),
281 CreateIndirectStubsManager())));
283 return addLogicalModule(I->second, std::move(M));
286 /// Add extra modules to an existing logical module.
287 Error addExtraModule(VModuleKey K, std::unique_ptr<Module> M) {
288 return addLogicalModule(LogicalDylibs[K], std::move(M));
291 /// Remove the module represented by the given key.
293 /// This will remove all modules in the layers below that were derived from
294 /// the module represented by K.
295 Error removeModule(VModuleKey K) {
296 auto I = LogicalDylibs.find(K);
297 assert(I != LogicalDylibs.end() && "VModuleKey K not valid here");
298 auto Err = I->second.removeModulesFromBaseLayer(BaseLayer);
299 LogicalDylibs.erase(I);
303 /// Search for the given named symbol.
304 /// @param Name The name of the symbol to search for.
305 /// @param ExportedSymbolsOnly If true, search only for exported symbols.
306 /// @return A handle for the given named symbol, if it exists.
307 JITSymbol findSymbol(StringRef Name, bool ExportedSymbolsOnly) {
308 for (auto &KV : LogicalDylibs) {
309 if (auto Sym = KV.second.StubsMgr->findStub(Name, ExportedSymbolsOnly))
311 if (auto Sym = findSymbolIn(KV.first, Name, ExportedSymbolsOnly))
313 else if (auto Err = Sym.takeError())
314 return std::move(Err);
316 return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
319 /// Get the address of a symbol provided by this layer, or some layer
321 JITSymbol findSymbolIn(VModuleKey K, const std::string &Name,
322 bool ExportedSymbolsOnly) {
323 assert(LogicalDylibs.count(K) && "VModuleKey K is not valid here");
324 return LogicalDylibs[K].findSymbol(BaseLayer, Name, ExportedSymbolsOnly);
327 /// Update the stub for the given function to point at FnBodyAddr.
328 /// This can be used to support re-optimization.
329 /// @return true if the function exists and the stub is updated, false
332 // FIXME: We should track and free associated resources (unused compile
333 // callbacks, uncompiled IR, and no-longer-needed/reachable function
335 Error updatePointer(std::string FuncName, JITTargetAddress FnBodyAddr) {
336 //Find out which logical dylib contains our symbol
337 auto LDI = LogicalDylibs.begin();
338 for (auto LDE = LogicalDylibs.end(); LDI != LDE; ++LDI) {
339 if (auto LMResources =
340 LDI->getLogicalModuleResourcesForSymbol(FuncName, false)) {
341 Module &SrcM = LMResources->SourceModule->getResource();
342 std::string CalledFnName = mangle(FuncName, SrcM.getDataLayout());
343 if (auto Err = LMResources->StubsMgr->updatePointer(CalledFnName,
346 return Error::success();
349 return make_error<JITSymbolNotFound>(FuncName);
353 Error addLogicalModule(LogicalDylib &LD, std::unique_ptr<Module> SrcMPtr) {
355 // Rename all static functions / globals to $static.X :
356 // This will unique the names across all modules in the logical dylib,
357 // simplifying symbol lookup.
358 LD.StaticRenamer.rename(*SrcMPtr);
360 // Bump the linkage and rename any anonymous/private members in SrcM to
361 // ensure that everything will resolve properly after we partition SrcM.
362 makeAllSymbolsExternallyAccessible(*SrcMPtr);
364 // Create a logical module handle for SrcM within the logical dylib.
365 Module &SrcM = *SrcMPtr;
366 auto LMId = LD.addSourceModule(std::move(SrcMPtr));
368 // Create stub functions.
369 const DataLayout &DL = SrcM.getDataLayout();
371 typename IndirectStubsMgrT::StubInitsMap StubInits;
372 for (auto &F : SrcM) {
373 // Skip declarations.
374 if (F.isDeclaration())
377 // Skip weak functions for which we already have definitions.
378 auto MangledName = mangle(F.getName(), DL);
379 if (F.hasWeakLinkage() || F.hasLinkOnceLinkage()) {
380 if (auto Sym = LD.findSymbol(BaseLayer, MangledName, false))
382 else if (auto Err = Sym.takeError())
383 return std::move(Err);
386 // Record all functions defined by this module.
387 if (CloneStubsIntoPartitions)
388 LD.getStubsToClone(LMId).insert(&F);
390 // Create a callback, associate it with the stub for the function,
391 // and set the compile action to compile the partition containing the
393 auto CompileAction = [this, &LD, LMId, &F]() -> JITTargetAddress {
394 if (auto FnImplAddrOrErr = this->extractAndCompile(LD, LMId, F))
395 return *FnImplAddrOrErr;
397 // FIXME: Report error, return to 'abort' or something similar.
398 consumeError(FnImplAddrOrErr.takeError());
403 CompileCallbackMgr.getCompileCallback(std::move(CompileAction)))
404 StubInits[MangledName] =
405 std::make_pair(*CCAddr, JITSymbolFlags::fromGlobalValue(F));
407 return CCAddr.takeError();
410 if (auto Err = LD.StubsMgr->createStubs(StubInits))
414 // If this module doesn't contain any globals, aliases, or module flags then
415 // we can bail out early and avoid the overhead of creating and managing an
416 // empty globals module.
417 if (SrcM.global_empty() && SrcM.alias_empty() &&
418 !SrcM.getModuleFlagsMetadata())
419 return Error::success();
421 // Create the GlobalValues module.
422 auto GVsM = llvm::make_unique<Module>((SrcM.getName() + ".globals").str(),
424 GVsM->setDataLayout(DL);
426 ValueToValueMapTy VMap;
428 // Clone global variable decls.
429 for (auto &GV : SrcM.globals())
430 if (!GV.isDeclaration() && !VMap.count(&GV))
431 cloneGlobalVariableDecl(*GVsM, GV, &VMap);
434 for (auto &A : SrcM.aliases())
436 cloneGlobalAliasDecl(*GVsM, A, VMap);
438 // Clone the module flags.
439 cloneModuleFlagsMetadata(*GVsM, SrcM, VMap);
441 // Now we need to clone the GV and alias initializers.
443 // Initializers may refer to functions declared (but not defined) in this
444 // module. Build a materializer to clone decls on demand.
445 auto Materializer = createLambdaMaterializer(
446 [&LD, &GVsM](Value *V) -> Value* {
447 if (auto *F = dyn_cast<Function>(V)) {
448 // Decls in the original module just get cloned.
449 if (F->isDeclaration())
450 return cloneFunctionDecl(*GVsM, *F);
452 // Definitions in the original module (which we have emitted stubs
453 // for at this point) get turned into a constant alias to the stub
455 const DataLayout &DL = GVsM->getDataLayout();
456 std::string FName = mangle(F->getName(), DL);
457 unsigned PtrBitWidth = DL.getPointerTypeSizeInBits(F->getType());
458 JITTargetAddress StubAddr =
459 LD.StubsMgr->findStub(FName, false).getAddress();
461 ConstantInt *StubAddrCI =
462 ConstantInt::get(GVsM->getContext(), APInt(PtrBitWidth, StubAddr));
463 Constant *Init = ConstantExpr::getCast(Instruction::IntToPtr,
464 StubAddrCI, F->getType());
465 return GlobalAlias::create(F->getFunctionType(),
466 F->getType()->getAddressSpace(),
467 F->getLinkage(), F->getName(),
474 // Clone the global variable initializers.
475 for (auto &GV : SrcM.globals())
476 if (!GV.isDeclaration())
477 moveGlobalVariableInitializer(GV, VMap, &Materializer);
479 // Clone the global alias initializers.
480 for (auto &A : SrcM.aliases()) {
481 auto *NewA = cast<GlobalAlias>(VMap[&A]);
482 assert(NewA && "Alias not cloned?");
483 Value *Init = MapValue(A.getAliasee(), VMap, RF_None, nullptr,
485 NewA->setAliasee(cast<Constant>(Init));
488 // Build a resolver for the globals module and add it to the base layer.
489 auto LegacyLookup = [this, &LD](const std::string &Name) -> JITSymbol {
490 if (auto Sym = LD.StubsMgr->findStub(Name, false))
493 if (auto Sym = LD.findSymbol(BaseLayer, Name, false))
495 else if (auto Err = Sym.takeError())
496 return std::move(Err);
501 auto GVsResolver = createSymbolResolver(
502 [&LD, LegacyLookup](const SymbolNameSet &Symbols) {
503 auto SymbolFlags = lookupFlagsWithLegacyFn(Symbols, LegacyLookup);
506 logAllUnhandledErrors(SymbolFlags.takeError(), errs(),
507 "CODLayer/GVsResolver flags lookup failed: ");
508 return SymbolFlagsMap();
511 if (SymbolFlags->size() == Symbols.size())
514 SymbolNameSet NotFoundViaLegacyLookup;
515 for (auto &S : Symbols)
516 if (!SymbolFlags->count(S))
517 NotFoundViaLegacyLookup.insert(S);
519 LD.BackingResolver->lookupFlags(NotFoundViaLegacyLookup);
521 for (auto &KV : SymbolFlags2)
522 (*SymbolFlags)[KV.first] = std::move(KV.second);
527 LegacyLookup](std::shared_ptr<AsynchronousSymbolQuery> Query,
528 SymbolNameSet Symbols) {
529 auto NotFoundViaLegacyLookup =
530 lookupWithLegacyFn(ES, *Query, Symbols, LegacyLookup);
531 return LD.BackingResolver->lookup(Query, NotFoundViaLegacyLookup);
534 SetSymbolResolver(LD.K, std::move(GVsResolver));
536 if (auto Err = BaseLayer.addModule(LD.K, std::move(GVsM)))
539 LD.BaseLayerVModuleKeys.push_back(LD.K);
541 return Error::success();
544 static std::string mangle(StringRef Name, const DataLayout &DL) {
545 std::string MangledName;
547 raw_string_ostream MangledNameStream(MangledName);
548 Mangler::getNameWithPrefix(MangledNameStream, Name, DL);
553 Expected<JITTargetAddress>
554 extractAndCompile(LogicalDylib &LD,
555 typename LogicalDylib::SourceModuleHandle LMId,
557 Module &SrcM = LD.getSourceModule(LMId);
559 // If F is a declaration we must already have compiled it.
560 if (F.isDeclaration())
563 // Grab the name of the function being called here.
564 std::string CalledFnName = mangle(F.getName(), SrcM.getDataLayout());
566 JITTargetAddress CalledAddr = 0;
567 auto Part = Partition(F);
568 if (auto PartKeyOrErr = emitPartition(LD, LMId, Part)) {
569 auto &PartKey = *PartKeyOrErr;
570 for (auto *SubF : Part) {
571 std::string FnName = mangle(SubF->getName(), SrcM.getDataLayout());
572 if (auto FnBodySym = BaseLayer.findSymbolIn(PartKey, FnName, false)) {
573 if (auto FnBodyAddrOrErr = FnBodySym.getAddress()) {
574 JITTargetAddress FnBodyAddr = *FnBodyAddrOrErr;
576 // If this is the function we're calling record the address so we can
577 // return it from this function.
579 CalledAddr = FnBodyAddr;
581 // Update the function body pointer for the stub.
582 if (auto EC = LD.StubsMgr->updatePointer(FnName, FnBodyAddr))
586 return FnBodyAddrOrErr.takeError();
587 } else if (auto Err = FnBodySym.takeError())
588 return std::move(Err);
590 llvm_unreachable("Function not emitted for partition");
593 LD.BaseLayerVModuleKeys.push_back(PartKey);
595 return PartKeyOrErr.takeError();
600 template <typename PartitionT>
602 emitPartition(LogicalDylib &LD,
603 typename LogicalDylib::SourceModuleHandle LMId,
604 const PartitionT &Part) {
605 Module &SrcM = LD.getSourceModule(LMId);
607 // Create the module.
608 std::string NewName = SrcM.getName();
609 for (auto *F : Part) {
611 NewName += F->getName();
614 auto M = llvm::make_unique<Module>(NewName, SrcM.getContext());
615 M->setDataLayout(SrcM.getDataLayout());
616 ValueToValueMapTy VMap;
618 auto Materializer = createLambdaMaterializer([&LD, &LMId,
619 &M](Value *V) -> Value * {
620 if (auto *GV = dyn_cast<GlobalVariable>(V))
621 return cloneGlobalVariableDecl(*M, *GV);
623 if (auto *F = dyn_cast<Function>(V)) {
624 // Check whether we want to clone an available_externally definition.
625 if (!LD.getStubsToClone(LMId).count(F))
626 return cloneFunctionDecl(*M, *F);
628 // Ok - we want an inlinable stub. For that to work we need a decl
629 // for the stub pointer.
630 auto *StubPtr = createImplPointer(*F->getType(), *M,
631 F->getName() + "$stub_ptr", nullptr);
632 auto *ClonedF = cloneFunctionDecl(*M, *F);
633 makeStub(*ClonedF, *StubPtr);
634 ClonedF->setLinkage(GlobalValue::AvailableExternallyLinkage);
635 ClonedF->addFnAttr(Attribute::AlwaysInline);
639 if (auto *A = dyn_cast<GlobalAlias>(V)) {
640 auto *Ty = A->getValueType();
641 if (Ty->isFunctionTy())
642 return Function::Create(cast<FunctionType>(Ty),
643 GlobalValue::ExternalLinkage, A->getName(),
646 return new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage,
647 nullptr, A->getName(), nullptr,
648 GlobalValue::NotThreadLocal,
649 A->getType()->getAddressSpace());
655 // Create decls in the new module.
657 cloneFunctionDecl(*M, *F, &VMap);
659 // Move the function bodies.
661 moveFunctionBody(*F, VMap, &Materializer);
663 auto K = ES.allocateVModule();
665 auto LegacyLookup = [this, &LD](const std::string &Name) -> JITSymbol {
666 return LD.findSymbol(BaseLayer, Name, false);
669 // Create memory manager and symbol resolver.
670 auto Resolver = createSymbolResolver(
671 [&LD, LegacyLookup](const SymbolNameSet &Symbols) {
672 auto SymbolFlags = lookupFlagsWithLegacyFn(Symbols, LegacyLookup);
674 logAllUnhandledErrors(SymbolFlags.takeError(), errs(),
675 "CODLayer/SubResolver flags lookup failed: ");
676 return SymbolFlagsMap();
679 if (SymbolFlags->size() == Symbols.size())
682 SymbolNameSet NotFoundViaLegacyLookup;
683 for (auto &S : Symbols)
684 if (!SymbolFlags->count(S))
685 NotFoundViaLegacyLookup.insert(S);
688 LD.BackingResolver->lookupFlags(NotFoundViaLegacyLookup);
690 for (auto &KV : SymbolFlags2)
691 (*SymbolFlags)[KV.first] = std::move(KV.second);
695 [this, &LD, LegacyLookup](std::shared_ptr<AsynchronousSymbolQuery> Q,
696 SymbolNameSet Symbols) {
697 auto NotFoundViaLegacyLookup =
698 lookupWithLegacyFn(ES, *Q, Symbols, LegacyLookup);
699 return LD.BackingResolver->lookup(Q,
700 std::move(NotFoundViaLegacyLookup));
702 SetSymbolResolver(K, std::move(Resolver));
704 if (auto Err = BaseLayer.addModule(std::move(K), std::move(M)))
705 return std::move(Err);
710 ExecutionSession &ES;
711 BaseLayerT &BaseLayer;
712 SymbolResolverGetter GetSymbolResolver;
713 SymbolResolverSetter SetSymbolResolver;
714 PartitioningFtor Partition;
715 CompileCallbackMgrT &CompileCallbackMgr;
716 IndirectStubsManagerBuilderT CreateIndirectStubsManager;
718 std::map<VModuleKey, LogicalDylib> LogicalDylibs;
719 bool CloneStubsIntoPartitions;
722 } // end namespace orc
724 } // end namespace llvm
726 #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H