Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ Changes to the C API
* Added ``LLVMGetICmpSameSign`` and ``LLVMSetICmpSameSign`` for the `samesign`
flag on `icmp` instructions.

* Added `LLVMOrcThreadSafeContextGetLock` and `LLVMOrcThreadSafeContextReleaseLock`
for acquiring and releasing locks associated with `ThreadSafeContext` instances.

Changes to the CodeGen infrastructure
-------------------------------------

Expand Down
18 changes: 18 additions & 0 deletions llvm/include/llvm-c/Orc.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ typedef int (*LLVMOrcSymbolPredicate)(void *Ctx,
*/
typedef struct LLVMOrcOpaqueThreadSafeContext *LLVMOrcThreadSafeContextRef;

/**
* A reference to an orc::ThreadSafeContext::Lock instance.
*/
typedef struct LLVMOrcOpaqueThreadSafeContextLock
*LLVMOrcThreadSafeContextLockRef;

/**
* A reference to an orc::ThreadSafeModule instance.
*/
Expand Down Expand Up @@ -1082,6 +1088,18 @@ LLVMOrcThreadSafeContextGetContext(LLVMOrcThreadSafeContextRef TSCtx);
*/
void LLVMOrcDisposeThreadSafeContext(LLVMOrcThreadSafeContextRef TSCtx);

/**
* Acquire the lock associated with a ThreadSafeContext.
*/
LLVMOrcThreadSafeContextLockRef
LLVMOrcThreadSafeContextGetLock(LLVMOrcThreadSafeContextRef TSCtx);

/**
* Release the lock associated with a ThreadSafeContext.
*/
void LLVMOrcThreadSafeContextReleaseLock(
LLVMOrcThreadSafeContextLockRef TSCtxLock);

/**
* Create a ThreadSafeModule wrapper around the given LLVM module. This takes
* ownership of the M argument which should not be disposed of or referenced
Expand Down
12 changes: 12 additions & 0 deletions llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DefinitionGenerator,
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(InProgressLookupState, LLVMOrcLookupStateRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ThreadSafeContext,
LLVMOrcThreadSafeContextRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ThreadSafeContext::Lock,
LLVMOrcThreadSafeContextLockRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ThreadSafeModule, LLVMOrcThreadSafeModuleRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(JITTargetMachineBuilder,
LLVMOrcJITTargetMachineBuilderRef)
Expand Down Expand Up @@ -738,6 +740,16 @@ void LLVMOrcDisposeThreadSafeContext(LLVMOrcThreadSafeContextRef TSCtx) {
delete unwrap(TSCtx);
}

LLVMOrcThreadSafeContextLockRef
LLVMOrcThreadSafeContextGetLock(LLVMOrcThreadSafeContextRef TSCtx) {
return wrap(new ThreadSafeContext::Lock(std::move(unwrap(TSCtx)->getLock())));
}

void LLVMOrcThreadSafeContextReleaseLock(
LLVMOrcThreadSafeContextLockRef TSCtxLock) {
delete unwrap(TSCtxLock);
}

LLVMErrorRef
LLVMOrcThreadSafeModuleWithModuleDo(LLVMOrcThreadSafeModuleRef TSM,
LLVMOrcGenericIRModuleOperationFunction F,
Expand Down
Loading