[llvm-commits] [PATCH] Make Inits FoldingSetNodes

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Jul 14 14:29:41 PDT 2011


On Jul 14, 2011, at 2:04 PM, David A. Greene wrote:

> Jakob Stoklund Olesen <stoklund at 2pi.dk> writes:
> 
>> For StringInit and CodeInit, I am not sure interning is even
>> necessary. You definitely want to have an empty string singleton, but
>> other than that, how many duplicate strings are there really?
> 
> There will be a lot of duplicates in the future.  This is all in
> preparation for the complete AVX implementation.

This surprises me. From my reading of the TableGen code, a StringInit is only ever allocated after parsing a string. That means the only way you can get duplicate StringInit instances is by typing multiple identical strings in your .td files.

Multiclasses and default arguments and all that stuff is already sharing inits AFAIK.

But a StringMap is nice and fast for interning this stuff, so I don't mind doing that.

>>> +  static void ReleaseMemory() {
>>> +    InitAllocator.Reset();
>>> +  }
>> 
>> 
>> I don't think there is any reason to release memory. This function
>> leaks a ton anyway since it doesn't call destructors, and it is only
>> called immediately before exiting the process. It is very hard to beat
>> _exit(2) for speed of deallocating complex data structures.
> 
> Ok, but will Valgrind report leaks?

Yes. I don't think that is a problem.

Leaks are important to plug for long running processes and library code.

Short-lived command line tools like TableGen don't really benefit from cleaning up. And it can take a long time to deallocate complicated data structures.

/jakob




More information about the llvm-commits mailing list