<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 27 April 2017 at 03:13, Brian Cain via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Do other compilers behave similarly in terms if memory consumption for your example code?</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Apr 26, 2017 4:20 PM, "mateusz janek via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>Hi,</div><div><br></div><div>Before I'll begin, I want to say that I don't want to implement below 'feature' in a clang production code. I want to create my own custom build for my own needs.</div><div><br></div><div>Abstract:</div><div>I'm developing a hobby project which creates a lot of types in a compile time, in one .cpp file. Really a lot. I tried to compile next version, but it was compiling whole night and took ~30G of memory (16G RAM + swap) and wasn't able to finish. I know that almost all of these types are 'used' only once, they're kind of helpers.</div><div>Basically what I want to achieve is to decrease memory usage to not need to use the swap, because it increases compilation time a lot.</div><div><br></div><div>Question:</div><div>Is there a way to implement a removing no longer used types? E.g.</div><div><br></div><div>template <typename FooParam></div><div>struct Foo</div><div>{</div><div>    using FooResult = typename Bar<FooParam>::BarResult;</div><div>};</div><div><br></div><div>And I'd want to remove the 'Bar<FooParam>' type from a 'ASTContext' because I know that I won't need it anymore. (then, if there will again occur an initialization of very same 'Bar<FooParam>', I'm ok with that I'll need to create it from the scratch).</div><div>So basically is there any way to detect if type is still referenced somewhere, so I can remove it if it isn't?</div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>You will need ALL types (that are used at all) to be present at semantic analysis, since types are used to determine for example implicit casts (float to int, int to float, short to int, int to short - and even if your type can't be converted, it still needs to be present during that phase). Since Semantic analysis is done at the end of the compilation of a translation unit. And of course, types are used during translation from AST to IR, so need to be (at least somewhat) present during the IR generation phase too. [And the compiler WILL need to know what `Bar<FooParam>` is to find `Bar<FooParam>::BarResult`, even if that is then translated to `size_t` or `int`.<br><br></div><div>Also, are you sure that it's the number of types that is the real cause of the problem?<br><br></div><div>Can you provide a more complete example (preferrably one that compiles, but does not take "over night", in a few minutes would be good, that illustrates that it uses a lot more memory than a comparable piece of code with less types introduced in it).<br><br>--<br></div><div>Mats<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><br></div><div>I hope I've described my problem well. I know that in fact I'm asking for a explanation how types in clang are related to each other - that's a lot, but I'd really like to learn and understand that (:</div><div><br></div><div>Thanks in advance for help!</div><div><br></div><div>Stryku</div></div>
<br></div></div>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div></div>
<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>