[PATCH][Clang Driver] Driver::IsUsingLTO no longer return true when seeing -emit-llvm

Chandler Carruth chandlerc at google.com
Thu Aug 22 14:40:56 PDT 2013


I haven't been following this thread either. I am now.

Generally, design discussions would be better served to be on the dev list.

On Thu, Aug 22, 2013 at 1:52 PM, Nick Lewycky <nlewycky at google.com> wrote:

> As Eric suggested, I was surprised to discover we have a -emit-llvm flag,
> then more surprised that it didn't bother to pass the right linker flags
> when linking. I think I called it "a broken copy of -flto", arguing that we
> should delete it entirely, in favour of -flto.
>
> As for telling the compiler "I want to build with LTO", we already have
> -O4 which is presently equivalent to -O3 -flto. Let's keep that? In the
> future, -O4 should select the pre-IPO optimizations. (I would also like a
> "-Olto" flag specifically so that I can select the pre-IPO optimization
> stack, even if I'm generating native code directly, for debugging and
> benchmarking and also to keep separate the concerns of selecting an optz'n
> stack and selecting the output format.)
>
> I won't block a patch that changes/removes -flto, but my fingers will
> still be typing it for years to come. I don't want it, but I could live
> with it.
>

I think there is no path forward for supporting LTO on the commandline that
allows all of the existing users to continue using the command lines they
have. We should abandon that hope.

First, -O4 is a *very* bad name. LTO is not about how hard we optimize but
about *where* we optimize. I sent out a proposal to eventually make -ON
saturate at 3 (possibly with a warning) and there was no real arguments
against this a long time ago. I still think that is the correct design
there.

As Shuxin said, we have two *overlapping* use cases:

1) I want to do LTO.

2) I want to get the IR out for some development purpose (I do not care
what optimization model is being requested).

The only sensible flag for requesting LTO is '-flto'. Requesting LTO is the
only sensible use of that flag.

If you want IR to debug something or see the IR, you don't want to change
the compilation or optimization model, you just want to get IR. This is
exactly what '-emit-llvm' does and should provide.

If people are surprised by the fact that '-emit-llvm' happens to be a no-op
when using '-flto', they will learn something about or LTO.

If people are surprised that passing '-flto' changes the optimization
strategy to be better aligned with running the optimizer at link time, they
have gotten what they asked for and need to change what they are asking for.

-Chandler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130822/3389125d/attachment.html>


More information about the llvm-commits mailing list