Skip to content

Commit 069d089

Browse files
committed
Pass memory buffer to RuntimeDyld::MemoryManager factory
1 parent 8b167db commit 069d089

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class LLVM_ABI RTDyldObjectLinkingLayer
5050
MaterializationResponsibility &R, std::unique_ptr<MemoryBuffer>)>;
5151

5252
using GetMemoryManagerFunction =
53-
unique_function<std::unique_ptr<RuntimeDyld::MemoryManager>()>;
53+
unique_function<std::unique_ptr<RuntimeDyld::MemoryManager>(
54+
const MemoryBuffer&)>;
5455

5556
/// Construct an ObjectLinkingLayer with the given NotifyLoaded,
5657
/// and NotifyEmitted functors.

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ class GenericLLVMIRPlatformSupport : public LLJIT::PlatformSupport {
269269
}
270270

271271
void registerInitFunc(JITDylib &JD, SymbolStringPtr InitName) {
272-
getExecutionSession().runSessionLocked([&]() {
273-
InitFunctions[&JD].add(InitName);
274-
});
272+
getExecutionSession().runSessionLocked([&]() {
273+
InitFunctions[&JD].add(InitName);
274+
});
275275
}
276276

277277
void registerDeInitFunc(JITDylib &JD, SymbolStringPtr DeInitName) {
@@ -935,8 +935,8 @@ Error LLJIT::addObjectFile(JITDylib &JD, std::unique_ptr<MemoryBuffer> Obj) {
935935
Expected<ExecutorAddr> LLJIT::lookupLinkerMangled(JITDylib &JD,
936936
SymbolStringPtr Name) {
937937
if (auto Sym = ES->lookup(
938-
makeJITDylibSearchOrder(&JD, JITDylibLookupFlags::MatchAllSymbols),
939-
Name))
938+
makeJITDylibSearchOrder(&JD, JITDylibLookupFlags::MatchAllSymbols),
939+
Name))
940940
return Sym->getAddress();
941941
else
942942
return Sym.takeError();
@@ -951,7 +951,9 @@ LLJIT::createObjectLinkingLayer(LLJITBuilderState &S, ExecutionSession &ES) {
951951

952952
// Otherwise default to creating an RTDyldObjectLinkingLayer that constructs
953953
// a new SectionMemoryManager for each object.
954-
auto GetMemMgr = []() { return std::make_unique<SectionMemoryManager>(); };
954+
auto GetMemMgr = [](const MemoryBuffer&) {
955+
return std::make_unique<SectionMemoryManager>();
956+
};
955957
auto Layer =
956958
std::make_unique<RTDyldObjectLinkingLayer>(ES, std::move(GetMemMgr));
957959

llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,10 @@ LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager(
10221022
LLVMOrcExecutionSessionRef ES) {
10231023
assert(ES && "ES must not be null");
10241024
return wrap(new RTDyldObjectLinkingLayer(
1025-
*unwrap(ES), [] { return std::make_unique<SectionMemoryManager>(); }));
1025+
*unwrap(ES),
1026+
[] (const MemoryBuffer &) {
1027+
return std::make_unique<SectionMemoryManager>();
1028+
}));
10261029
}
10271030

10281031
LLVMOrcObjectLayerRef
@@ -1128,7 +1131,8 @@ LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks(
11281131
CreateContextCtx, CreateContext, NotifyTerminating, AllocateCodeSection,
11291132
AllocateDataSection, FinalizeMemory, Destroy);
11301133

1131-
return wrap(new RTDyldObjectLinkingLayer(*unwrap(ES), [CBs = std::move(CBs)] {
1134+
return wrap(new RTDyldObjectLinkingLayer(*unwrap(ES),
1135+
[CBs = std::move(CBs)] (const MemoryBuffer &) {
11321136
return std::make_unique<MCJITMemoryManagerLikeCallbacksMemMgr>(CBs);
11331137
}));
11341138

llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class JITDylibSearchOrderResolver : public JITSymbolResolver {
2222
SymbolDependenceMap &Deps)
2323
: MR(MR), Deps(Deps) {}
2424

25-
void lookup(const LookupSet &Symbols, OnResolvedFunction OnResolved) override {
25+
void lookup(const LookupSet &Symbols, OnResolvedFunction OnResolved) override {
2626
auto &ES = MR.getTargetJITDylib().getExecutionSession();
2727
SymbolLookupSet InternedSymbols;
2828

@@ -181,7 +181,7 @@ void RTDyldObjectLinkingLayer::emit(
181181
}
182182
}
183183

184-
auto MemMgr = GetMemoryManager();
184+
auto MemMgr = GetMemoryManager(*O);
185185
auto &MemMgrRef = *MemMgr;
186186

187187
// Switch to shared ownership of MR so that it can be captured by both

mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ ExecutionEngine::create(Operation *m, const ExecutionEngineOptions &options,
315315
// process and dynamically linked libraries.
316316
auto objectLinkingLayerCreator = [&](ExecutionSession &session) {
317317
auto objectLayer = std::make_unique<RTDyldObjectLinkingLayer>(
318-
session, [sectionMemoryMapper = options.sectionMemoryMapper]() {
318+
session, [sectionMemoryMapper = options.sectionMemoryMapper]
319+
(const MemoryBuffer&) {
319320
return std::make_unique<SectionMemoryManager>(sectionMemoryMapper);
320321
});
321322

0 commit comments

Comments
 (0)