[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin

Hal Finkel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 14 08:18:58 PDT 2017


hfinkel added a comment.

In https://reviews.llvm.org/D30920#700557, @mehdi_amini wrote:

> In https://reviews.llvm.org/D30920#700433, @tejohnson wrote:
>
> > In https://reviews.llvm.org/D30920#700133, @pcc wrote:
> >
> > > In https://reviews.llvm.org/D30920#700077, @tejohnson wrote:
> > >
> > > > Until everything is converted to using size attributes, it seems like a correct fix for the bug is to accept these options in the gold-plugin and pass through the LTO API to the PassManagerBuilder.
> > >
> > >
> > > Not necessarily. There is no requirement (from a correctness perspective) that `-Os` at link time should exactly match the behaviour of `-Os` at compile time.
> >
> >
> > Sure, but there is certainly a perception that optimization flags affecting the non-LTO pipeline should similarly affect the LTO pipeline. LTO should be transparent to the user, so if -Os behaves one way without LTO, it seems problematic to me if it behaves a different way with LTO.
> >
> > That being said, agree that the best way to enforce that is to pass the relevant flags through the IR. (On the flip side, if the user passes -O1 to the link step, it does get passed through to the plugin and affects the LTO optimization pipeline...)
>
>
> I agree that I don't like the discrepancy: the driver should *not* drop -Os silently if it passes down -O1/-O2/-O3, a warning is the minimum.


I don't like the discrepancy either, and I agree that we should be passing these other flags through the IR as well (even though, in the face of inlining, there is some ambiguity as to what the flags would mean). That having been said, I don't see the value in the warning. Forcing users to endure a warning solely because they use LTO and use -Os or -Oz for all of their compilation steps, is not friendly. The information has been captured already so there's nothing to warn about. You might worry about the opposite situation (the user uses only -Os or -Oz on the link step, but not for the compile steps), and that will have no effect. That, however, should be the expected behavior (optimization is associated with compiling, not linking, except perhaps for specifically called-out exceptions). The fact that our other optimization level don't work that way is a bug, not a feature, that we should fix instead of further exposing to our users.


https://reviews.llvm.org/D30920





More information about the cfe-commits mailing list