On Thu, May 1, 2014 at 11:12 AM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:> On 1 May 2014 14:08, Reid Kleckner <rnk at google.com> wrote: >> 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. >> >> Maybe we should run it twice. > > That is probably fine, we just have to make sure compile time doesn't > surfer too much.Looking at GlobalOpt, it seems to do full symbolic evaluation of all constructors, which is more than what's needed here. Just walking llvm.global_ctors and removing calls to functions that are just "ret" is all that's needed. Unless folks think that's a terrible idea, I'll try to write a lightweight pass for doing just that.
> Looking at GlobalOpt, it seems to do full symbolic evaluation of all > constructors, which is more than what's needed here. Just walking > llvm.global_ctors and removing calls to functions that are just "ret" > is all that's needed. Unless folks think that's a terrible idea, I'll > try to write a lightweight pass for doing just that.Not a bad idea, we just normally avoid small passes like that. Looking at -O2, looks like we run -globaldce really late, maybe this could be done in it? Cheers, Rafael
On Thu, May 1, 2014 at 11:19 AM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:>> Looking at GlobalOpt, it seems to do full symbolic evaluation of all >> constructors, which is more than what's needed here. Just walking >> llvm.global_ctors and removing calls to functions that are just "ret" >> is all that's needed. Unless folks think that's a terrible idea, I'll >> try to write a lightweight pass for doing just that. > > Not a bad idea, we just normally avoid small passes like that.That's good to know, thanks. Is there a some kind of 'philosophical overview' document for llvm's pass design somewhere that explains things like this?> Looking > at -O2, looks like we run -globaldce really late, maybe this could be > done in it?I'll take a look, thanks!> > Cheers, > Rafael