[ORC] Require JITDylib to be specified when adding IR and objects in the C API.

This commit is contained in:
Lang Hames 2020-04-09 17:54:59 -07:00
parent 0bcf2d8864
commit 37bcf2df01
5 changed files with 17 additions and 11 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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.

View File

@ -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,