Skip to content

Commit 8d6a153

Browse files
committed
amend! [C-API] LLVMOrcCreateObjectLinkingLayerWithInProcessMemoryManager
[C-API] LLVMOrcCreateObjectLinkingLayerWithInProcessMemoryManager (#169862) Allow C programs to use JITLink instead of RuntimeDyld. Modeled on LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager except that it has to deal with failure to create InProcessMemoryManager.
1 parent ab1a9b5 commit 8d6a153

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

llvm/include/llvm-c/OrcEE.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ typedef void (*LLVMMemoryManagerNotifyTerminatingCallback)(void *CtxCtx);
4545

4646
/**
4747
* Create a ObjectLinkingLayer instance using the standard JITLink
48-
* InProcessMemoryManager for memory management. Result is NULL on failure to
49-
* determine system page size.
48+
* InProcessMemoryManager for memory management.
5049
*/
51-
LLVMOrcObjectLayerRef
50+
LLVM_C_ABI LLVMErrorRef
5251
LLVMOrcCreateObjectLinkingLayerWithInProcessMemoryManager(
53-
LLVMOrcExecutionSessionRef ES);
52+
LLVMOrcObjectLayerRef *Result, LLVMOrcExecutionSessionRef ES);
5453

5554
/**
5655
* Create a RTDyldObjectLinkingLayer instance using the standard

llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,16 +1019,16 @@ LLVMOrcLLJITGetObjTransformLayer(LLVMOrcLLJITRef J) {
10191019
return wrap(&unwrap(J)->getObjTransformLayer());
10201020
}
10211021

1022-
LLVMOrcObjectLayerRef
1023-
LLVMOrcCreateObjectLinkingLayerWithInProcessMemoryManager(
1024-
LLVMOrcExecutionSessionRef ES) {
1022+
LLVMErrorRef LLVMOrcCreateObjectLinkingLayerWithInProcessMemoryManager(
1023+
LLVMOrcObjectLayerRef *Result, LLVMOrcExecutionSessionRef ES) {
1024+
assert(Result && "Result must not be null");
10251025
assert(ES && "ES must not be null");
1026-
auto mm = jitlink::InProcessMemoryManager::Create();
1027-
if (!mm) {
1028-
unwrap(ES)->reportError(mm.takeError());
1029-
return nullptr;
1026+
auto MM = jitlink::InProcessMemoryManager::Create();
1027+
if (!MM) {
1028+
return wrap(MM.takeError());
10301029
}
1031-
return wrap(new ObjectLinkingLayer(*unwrap(ES), std::move(*mm)));
1030+
*Result = wrap(new ObjectLinkingLayer(*unwrap(ES), std::move(*MM)));
1031+
return LLVMErrorSuccess;
10321032
}
10331033

10341034
LLVMOrcObjectLayerRef

0 commit comments

Comments
 (0)