[llvm-commits] [PATCH] Fix leaks in LLVMContext!

Török Edwin edwintorok at gmail.com
Sun Aug 30 13:46:45 PDT 2009


On 2009-08-30 23:01, Török Edwin wrote:
> On 2009-08-28 16:24, Török Edwin wrote:
>   
>> Hi,
>>
>> Now that all the ManagedStatic constants are in LLVMContext, we can
>> delete the constants when the LLVMContext is destroyed, and we
>> can control the destruction order by doing that in ~LLVMContextImpl.
>>
>> Attached are 2 patches that fix leaks, it passed make check for me
>> (didn't check llvm-gcc yet).
>>   
>>     
>
> llvm-gcc needs the attached tiny patch (to free TheModule),
> otherwise it tries to destroy a constant that is still used by a GV, and
> an assertion fails.
>   

Actually neither llvm-gcc, nor any of the other tools should need to be
patched.
As suggested by Duncan, I only free the constants in LLVMContext if they
are not used.

So if a single-threaded tool decides it doesn't want to free the module
since it is going to exit anyway,
it doesn't have to free the module: llvmcontext will skip freeing the
constants that are used by the module.

New patch attached.

Best regards,
--Edwin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-ExplicitSymbols-leak.patch
Type: text/x-diff
Size: 976 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090830/8c1b0d2b/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Leakfix.patch
Type: text/x-diff
Size: 3479 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090830/8c1b0d2b/attachment-0001.patch>


More information about the llvm-commits mailing list