Skip to content

Commit 37bcf2d

Browse files
committed
[ORC] Require JITDylib to be specified when adding IR and objects in the C API.
1 parent 0bcf2d8 commit 37bcf2d

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

llvm/examples/OrcV2Examples/OrcV2CBindingsAddObjectFile/OrcV2CBindingsAddObjectFile.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ int main(int argc, char *argv[]) {
111111

112112
// Add our object file buffer to the JIT.
113113
{
114+
LLVMOrcJITDylibRef MainJD = LLVMOrcLLJITGetMainJITDylib(J);
114115
LLVMErrorRef Err;
115-
if ((Err = LLVMOrcLLJITAddObjectFile(J, ObjectFileBuffer))) {
116+
if ((Err = LLVMOrcLLJITAddObjectFile(J, MainJD, ObjectFileBuffer))) {
116117
MainResult = handleError(Err);
117118
goto jit_cleanup;
118119
}

llvm/examples/OrcV2Examples/OrcV2CBindingsBasicUsage/OrcV2CBindingsBasicUsage.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ int main(int argc, char *argv[]) {
9494

9595
// Add our demo module to the JIT.
9696
{
97+
LLVMOrcJITDylibRef MainJD = LLVMOrcLLJITGetMainJITDylib(J);
9798
LLVMErrorRef Err;
98-
if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, TSM))) {
99+
if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, MainJD, TSM))) {
99100
// If adding the ThreadSafeModule fails then we need to clean it up
100101
// ourselves. If adding it succeeds the JIT will manage the memory.
101102
LLVMOrcDisposeThreadSafeModule(TSM);

llvm/examples/OrcV2Examples/OrcV2CBindingsReflectProcessSymbols/OrcV2CBindingsReflectProcessSymbols.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ int main(int argc, char *argv[]) {
161161

162162
// Add our demo module to the JIT.
163163
{
164+
LLVMOrcJITDylibRef MainJD = LLVMOrcLLJITGetMainJITDylib(J);
164165
LLVMErrorRef Err;
165-
if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, TSM))) {
166+
if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, MainJD, TSM))) {
166167
// If adding the ThreadSafeModule fails then we need to clean it up
167168
// ourselves. If adding it succeeds the JIT will manage the memory.
168169
LLVMOrcDisposeThreadSafeModule(TSM);

llvm/include/llvm-c/Orc.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,22 @@ LLVMOrcSymbolStringPoolEntryRef
292292
LLVMOrcLLJITMangleAndIntern(LLVMOrcLLJITRef J, const char *UnmangledName);
293293

294294
/**
295-
* Add a buffer representing an object file to the given LLJIT instance. This
296-
* operation transfers ownership of the buffer to the LLJIT instance. The
297-
* buffer should not be disposed of or referenced once this function returns.
295+
* Add a buffer representing an object file to the given JITDylib in the given
296+
* LLJIT instance. This operation transfers ownership of the buffer to the
297+
* LLJIT instance. The buffer should not be disposed of or referenced once this
298+
* function returns.
298299
*/
299-
LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J,
300+
LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD,
300301
LLVMMemoryBufferRef ObjBuffer);
301302

302303
/**
303-
* Add an IR module to the main JITDylib of the given LLJIT instance. This
304+
* Add an IR module to the given JITDylib of the given LLJIT instance. This
304305
* operation transfers ownership of the TSM argument to the LLJIT instance.
305306
* The TSM argument should not be 3disposed of or referenced once this
306307
* function returns.
307308
*/
308309
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J,
310+
LLVMOrcJITDylibRef JD,
309311
LLVMOrcThreadSafeModuleRef TSM);
310312
/**
311313
* Look up the given symbol in the main JITDylib of the given LLJIT instance.

llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,16 @@ LLVMOrcLLJITMangleAndIntern(LLVMOrcLLJITRef J, const char *UnmangledName) {
204204
unwrap(J)->mangleAndIntern(UnmangledName)));
205205
}
206206

207-
LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J,
207+
LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD,
208208
LLVMMemoryBufferRef ObjBuffer) {
209209
return wrap(unwrap(J)->addObjectFile(
210-
std::unique_ptr<MemoryBuffer>(unwrap(ObjBuffer))));
210+
*unwrap(JD), std::unique_ptr<MemoryBuffer>(unwrap(ObjBuffer))));
211211
}
212212

213213
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J,
214+
LLVMOrcJITDylibRef JD,
214215
LLVMOrcThreadSafeModuleRef TSM) {
215-
return wrap(unwrap(J)->addIRModule(std::move(*unwrap(TSM))));
216+
return wrap(unwrap(J)->addIRModule(*unwrap(JD), std::move(*unwrap(TSM))));
216217
}
217218

218219
LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J,

0 commit comments

Comments
 (0)