mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
[ORC] Fix a memory leak in the OrcV2 C API (and some comment typos).
The LLVMOrcLLJITAddLLVMIRModule function was leaking its LLVMOrcThreadSafeModuleRef argument. Wrapping the argument in a unique_ptr fixes this.
This commit is contained in:
parent
221e615a9c
commit
ac29437d5b
@ -192,7 +192,7 @@ LLVMErrorRef LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess(
|
||||
*
|
||||
* Ownership of the underlying ThreadSafeContext data is shared: Clients
|
||||
* can and should dispose of their ThreadSafeContext as soon as they no longer
|
||||
* need to refer to it directly. Other references (e.g. from ThreadSafeModules
|
||||
* need to refer to it directly. Other references (e.g. from ThreadSafeModules)
|
||||
* will keep the data alive as long as it is needed.
|
||||
*/
|
||||
LLVMOrcThreadSafeContextRef LLVMOrcCreateNewThreadSafeContext(void);
|
||||
@ -214,7 +214,7 @@ void LLVMOrcDisposeThreadSafeContext(LLVMOrcThreadSafeContextRef TSCtx);
|
||||
* after this function returns.
|
||||
*
|
||||
* Ownership of the ThreadSafeModule is unique: If it is transferred to the JIT
|
||||
* (e.g. by LLVMOrcLLJITAddLLVMIRModule), in which case the client is no longer
|
||||
* (e.g. by LLVMOrcLLJITAddLLVMIRModule) then the client is no longer
|
||||
* responsible for it. If it is not transferred to the JIT then the client
|
||||
* should call LLVMOrcDisposeThreadSafeModule to dispose of it.
|
||||
*/
|
||||
|
@ -257,7 +257,8 @@ LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD,
|
||||
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J,
|
||||
LLVMOrcJITDylibRef JD,
|
||||
LLVMOrcThreadSafeModuleRef TSM) {
|
||||
return wrap(unwrap(J)->addIRModule(*unwrap(JD), std::move(*unwrap(TSM))));
|
||||
std::unique_ptr<ThreadSafeModule> TmpTSM(unwrap(TSM));
|
||||
return wrap(unwrap(J)->addIRModule(*unwrap(JD), std::move(*TmpTSM)));
|
||||
}
|
||||
|
||||
LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J,
|
||||
|
Loading…
Reference in New Issue
Block a user