<div dir="ltr">I talked about this with Nick in person months ago, and my understanding is that GlobalOpt is also an enabling optimization that needs to run early.  For example, if we can eliminate an initializer to an internal global with no other stores to it, we can propagate the result.<div>
<br></div><div>Maybe we should run it twice.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 1, 2014 at 11:01 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@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 class="">On 30 April 2014 19:48, Nico Weber <<a href="mailto:thakis@chromium.org">thakis@chromium.org</a>> wrote:<br>

> Hi,<br>
><br>
> I'd like to fix PR19590, which is about llvm.global_ctors containing<br>
> functions that end up being empty after optimization (which causes the<br>
> linker to add useless init_array entries to the output binary).<br>
> globalopt removes empty functions from llvm.global_ctors, but by the<br>
> time the function becomes empty globalopt has already run and it<br>
> doesn't run again.<br>
><br>
> I'm wondering what the best fix is:<br>
> 1. Should globalopt run once more after all other passes have run?<br>
> 2. Or should the llvm.global_ctors optimization code in globalopt be<br>
> moved into a helper function somewhere that's called from both<br>
> globalopt and a new optimization pass cdtoropt that does nothing but<br>
> remove empty functions from llvm.global_ctors and llvm.global_dtors?<br>
> Then only this new pass would be added after all other passes. (This<br>
> new pass should run very quickly, it doesn't have to do much.)<br>
<br>
</div>How late do you need to move globalopt to get this to work? Do you get<br>
any performance regressions if you just move it there?<br>
<br>
Cheers,<br>
Rafael<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>