[llvm] 37bcf2d - [ORC] Require JITDylib to be specified when adding IR and objects in the C API.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 18:00:38 PDT 2020
Author: Lang Hames
Date: 2020-04-09T17:59:26-07:00
New Revision: 37bcf2df01cfa47e4509a5d225a23e2ca95005e6
URL: https://github.com/llvm/llvm-project/commit/37bcf2df01cfa47e4509a5d225a23e2ca95005e6
DIFF: https://github.com/llvm/llvm-project/commit/37bcf2df01cfa47e4509a5d225a23e2ca95005e6.diff
LOG: [ORC] Require JITDylib to be specified when adding IR and objects in the C API.
Added:
Modified:
llvm/examples/OrcV2Examples/OrcV2CBindingsAddObjectFile/OrcV2CBindingsAddObjectFile.c
llvm/examples/OrcV2Examples/OrcV2CBindingsBasicUsage/OrcV2CBindingsBasicUsage.c
llvm/examples/OrcV2Examples/OrcV2CBindingsReflectProcessSymbols/OrcV2CBindingsReflectProcessSymbols.c
llvm/include/llvm-c/Orc.h
llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
Removed:
################################################################################
diff --git a/llvm/examples/OrcV2Examples/OrcV2CBindingsAddObjectFile/OrcV2CBindingsAddObjectFile.c b/llvm/examples/OrcV2Examples/OrcV2CBindingsAddObjectFile/OrcV2CBindingsAddObjectFile.c
index 522eeb50f66c..49eca25b07a8 100644
--- a/llvm/examples/OrcV2Examples/OrcV2CBindingsAddObjectFile/OrcV2CBindingsAddObjectFile.c
+++ b/llvm/examples/OrcV2Examples/OrcV2CBindingsAddObjectFile/OrcV2CBindingsAddObjectFile.c
@@ -111,8 +111,9 @@ int main(int argc, char *argv[]) {
// Add our object file buffer to the JIT.
{
+ LLVMOrcJITDylibRef MainJD = LLVMOrcLLJITGetMainJITDylib(J);
LLVMErrorRef Err;
- if ((Err = LLVMOrcLLJITAddObjectFile(J, ObjectFileBuffer))) {
+ if ((Err = LLVMOrcLLJITAddObjectFile(J, MainJD, ObjectFileBuffer))) {
MainResult = handleError(Err);
goto jit_cleanup;
}
diff --git a/llvm/examples/OrcV2Examples/OrcV2CBindingsBasicUsage/OrcV2CBindingsBasicUsage.c b/llvm/examples/OrcV2Examples/OrcV2CBindingsBasicUsage/OrcV2CBindingsBasicUsage.c
index 373ff58c4d8e..cc54cc49ec24 100644
--- a/llvm/examples/OrcV2Examples/OrcV2CBindingsBasicUsage/OrcV2CBindingsBasicUsage.c
+++ b/llvm/examples/OrcV2Examples/OrcV2CBindingsBasicUsage/OrcV2CBindingsBasicUsage.c
@@ -94,8 +94,9 @@ int main(int argc, char *argv[]) {
// Add our demo module to the JIT.
{
+ LLVMOrcJITDylibRef MainJD = LLVMOrcLLJITGetMainJITDylib(J);
LLVMErrorRef Err;
- if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, TSM))) {
+ if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, MainJD, TSM))) {
// If adding the ThreadSafeModule fails then we need to clean it up
// ourselves. If adding it succeeds the JIT will manage the memory.
LLVMOrcDisposeThreadSafeModule(TSM);
diff --git a/llvm/examples/OrcV2Examples/OrcV2CBindingsReflectProcessSymbols/OrcV2CBindingsReflectProcessSymbols.c b/llvm/examples/OrcV2Examples/OrcV2CBindingsReflectProcessSymbols/OrcV2CBindingsReflectProcessSymbols.c
index 7d70e13da4b4..a9c65103c2c6 100644
--- a/llvm/examples/OrcV2Examples/OrcV2CBindingsReflectProcessSymbols/OrcV2CBindingsReflectProcessSymbols.c
+++ b/llvm/examples/OrcV2Examples/OrcV2CBindingsReflectProcessSymbols/OrcV2CBindingsReflectProcessSymbols.c
@@ -161,8 +161,9 @@ int main(int argc, char *argv[]) {
// Add our demo module to the JIT.
{
+ LLVMOrcJITDylibRef MainJD = LLVMOrcLLJITGetMainJITDylib(J);
LLVMErrorRef Err;
- if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, TSM))) {
+ if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, MainJD, TSM))) {
// If adding the ThreadSafeModule fails then we need to clean it up
// ourselves. If adding it succeeds the JIT will manage the memory.
LLVMOrcDisposeThreadSafeModule(TSM);
diff --git a/llvm/include/llvm-c/Orc.h b/llvm/include/llvm-c/Orc.h
index 60ff406150ba..4af2141b5270 100644
--- a/llvm/include/llvm-c/Orc.h
+++ b/llvm/include/llvm-c/Orc.h
@@ -292,20 +292,22 @@ LLVMOrcSymbolStringPoolEntryRef
LLVMOrcLLJITMangleAndIntern(LLVMOrcLLJITRef J, const char *UnmangledName);
/**
- * Add a buffer representing an object file to the given LLJIT instance. This
- * operation transfers ownership of the buffer to the LLJIT instance. The
- * buffer should not be disposed of or referenced once this function returns.
+ * Add a buffer representing an object file to the given JITDylib in the given
+ * LLJIT instance. This operation transfers ownership of the buffer to the
+ * LLJIT instance. The buffer should not be disposed of or referenced once this
+ * function returns.
*/
-LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J,
+LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD,
LLVMMemoryBufferRef ObjBuffer);
/**
- * Add an IR module to the main JITDylib of the given LLJIT instance. This
+ * Add an IR module to the given JITDylib of the given LLJIT instance. This
* operation transfers ownership of the TSM argument to the LLJIT instance.
* The TSM argument should not be 3disposed of or referenced once this
* function returns.
*/
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J,
+ LLVMOrcJITDylibRef JD,
LLVMOrcThreadSafeModuleRef TSM);
/**
* Look up the given symbol in the main JITDylib of the given LLJIT instance.
diff --git a/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp b/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
index 5e82a4a8613a..a35ec6954345 100644
--- a/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
@@ -204,15 +204,16 @@ LLVMOrcLLJITMangleAndIntern(LLVMOrcLLJITRef J, const char *UnmangledName) {
unwrap(J)->mangleAndIntern(UnmangledName)));
}
-LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J,
+LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD,
LLVMMemoryBufferRef ObjBuffer) {
return wrap(unwrap(J)->addObjectFile(
- std::unique_ptr<MemoryBuffer>(unwrap(ObjBuffer))));
+ *unwrap(JD), std::unique_ptr<MemoryBuffer>(unwrap(ObjBuffer))));
}
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J,
+ LLVMOrcJITDylibRef JD,
LLVMOrcThreadSafeModuleRef TSM) {
- return wrap(unwrap(J)->addIRModule(std::move(*unwrap(TSM))));
+ return wrap(unwrap(J)->addIRModule(*unwrap(JD), std::move(*unwrap(TSM))));
}
LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J,
More information about the llvm-commits
mailing list