<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 12, 2013 at 6:07 PM, Manman Ren <span dir="ltr"><<a href="mailto:manman.ren@gmail.com" target="_blank" class="cremed">manman.ren@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hi Chandler,</div><div><br></div><div>I don't quite get why you think sharing is not buying us anything...</div>

<div>It reduces the memory footprint of the source modules (there is sharing among the source modules) and the number of MDNodes created for the destination module (we do not need to re-create the MDNodes that can be shared).</div>

<div><br></div><div>The amount of sharing may not be that much but it still exists.</div><div><br></div><div>I had some experiments earlier on building clang with "-flto -g", if we dis-allow sharing between source modules and destination module, the memory footprint for MDNodes will increase by 15%.</div>
</blockquote></div><br>So, in my naive view, we do something like the following:</div><div class="gmail_extra"><br></div><div class="gmail_extra">0) load a source module</div><div class="gmail_extra">1) load another source module</div>
<div class="gmail_extra">2) merge the second module into the first</div><div class="gmail_extra">3) delete the second module</div><div class="gmail_extra">4) while there are more source modules, goto 1</div><div class="gmail_extra">
<br></div><div class="gmail_extra">This would mean that by not sharing the individual source module would use 15% more memory, but based on your OP numbers the final linked memory usage should still be 40% smaller. That seems like an easy win with very low complexity?</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Perhaps I just am being naive about how the LTO step works or there are other complications. I just wanted to make sure we considered the easy path of the module owning the metadata before introducing something to walk all metadata and delete unreachable bits.</div>
</div>