Chandler Carruth via llvm-dev
2017-Jan-20 09:11 UTC
[llvm-dev] RFC: Need One True Way to check for -Oz/-Os (minsize, optsize) in passes...
Right now we have a healthy mixture of two ways to respond to -Oz and -Os in LLVM: 1) Pass this info to the PassManagerBuilder and then toggle some flag to the pass to change thresholds. 2) When running over IR, inspect it for the minsize or optsize attribute. Regardless of the particulars of what these mean and/or how they relate to -O2 vs -O3 for example, I'd really like to at least get to *one* way of doing this. The only way that is really compatible with LTO use cases is to use the function attributes, so I'd suggest we actively work toward that. That sound good to others? Thoughts? If folks like this, I will attempt to update the few places where we get this wrong. I already have some patches but wanted to make sure everyone likes this direction. -Chandler -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170120/10391b60/attachment.html>
James Molloy via llvm-dev
2017-Jan-20 09:15 UTC
[llvm-dev] RFC: Need One True Way to check for -Oz/-Os (minsize, optsize) in passes...
Hey Chandler, Thanks for bringing this up. As I see it: The advantage of (1) is that it allows easier exploration of IR - I can run the optimizer in -O2, optsize and minsize mode all without going back to clang. The advantage of (2) is that it works with LTO… and I think that must trump all other concerns, as you said. In fact, the advantage of (1) I just stated could be gained by simply “opt -force-attribute=*:minsize” (do we have a wildcard match for -force-attribute? if we don’t, we should). So while unwieldy, it does work (and ideally should be documented!) So I agree, (2) sounds best. Cheers, James> On 20 Jan 2017, at 09:11, Chandler Carruth <chandlerc at gmail.com> wrote: > > Right now we have a healthy mixture of two ways to respond to -Oz and -Os in LLVM: > > 1) Pass this info to the PassManagerBuilder and then toggle some flag to the pass to change thresholds. > 2) When running over IR, inspect it for the minsize or optsize attribute. > > Regardless of the particulars of what these mean and/or how they relate to -O2 vs -O3 for example, I'd really like to at least get to *one* way of doing this. > > The only way that is really compatible with LTO use cases is to use the function attributes, so I'd suggest we actively work toward that. That sound good to others? Thoughts? > > If folks like this, I will attempt to update the few places where we get this wrong. I already have some patches but wanted to make sure everyone likes this direction. > > -Chandler
Chandler Carruth via llvm-dev
2017-Jan-20 09:29 UTC
[llvm-dev] RFC: Need One True Way to check for -Oz/-Os (minsize, optsize) in passes...
On Fri, Jan 20, 2017 at 1:15 AM James Molloy <James.Molloy at arm.com> wrote:> Hey Chandler, > > Thanks for bringing this up. As I see it: > > The advantage of (1) is that it allows easier exploration of IR - I can > run the optimizer in -O2, optsize and minsize mode all without going back > to clang. > > The advantage of (2) is that it works with LTO… and I think that must > trump all other concerns, as you said. In fact, the advantage of (1) I just > stated could be gained by simply “opt -force-attribute=*:minsize” (do we > have a wildcard match for -force-attribute? if we don’t, we should). So > while unwieldy, it does work (and ideally should be documented!) >If we go with (2), I'm happy to work on a mechanism in the opt tool to essentially automate this process to implement '-Oz' so that it won't be any harder than it is today. But I suspect it would be better to spell the option differently to make it clear that it will *transform* the IR to get this, not just a mode setting. Maybe a dedicated pass that is essentially the force attribute you describe, but canned for forcing these attributes globally when not already present on functions. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170120/b80c30ce/attachment.html>
Hal Finkel via llvm-dev
2017-Jan-20 12:25 UTC
[llvm-dev] RFC: Need One True Way to check for -Oz/-Os (minsize, optsize) in passes...
On 01/20/2017 03:11 AM, Chandler Carruth via llvm-dev wrote:> Right now we have a healthy mixture of two ways to respond to -Oz and > -Os in LLVM: > > 1) Pass this info to the PassManagerBuilder and then toggle some flag > to the pass to change thresholds. > 2) When running over IR, inspect it for the minsize or optsize attribute. > > Regardless of the particulars of what these mean and/or how they > relate to -O2 vs -O3 for example, I'd really like to at least get to > *one* way of doing this. > > The only way that is really compatible with LTO use cases is to use > the function attributes, so I'd suggest we actively work toward that. > That sound good to others? Thoughts?I actually thought that (2) was already the accepted answer to this question. Regardless, it should be (2). -Hal> > If folks like this, I will attempt to update the few places where we > get this wrong. I already have some patches but wanted to make sure > everyone likes this direction. > > -Chandler > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- Hal Finkel Lead, Compiler Technology and Programming Languages Leadership Computing Facility Argonne National Laboratory -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170120/c312efb4/attachment.html>