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

Eric Christopher echristo at gmail.com
Tue Aug 13 17:15:53 PDT 2013


On Tue, Aug 13, 2013 at 4:20 PM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:
> Hi,
>
>     Driver::IsUsingLTO()  returns true when "-emit-llvm" is seen, which is
> quite awkward if we need to differentiate following two commands, where
> 1) is just go through regular passes and stop at llc, while 2) needs to go
> through
> pre-ipo passes.
>
>    1) clang -emit-llvm a.c -c , and
>    2) clang -flto a.c -c
>
>  With this tiny patch is to differentiate these two situations.

This is a laudable goal, though i'm not sure what we gain here. I.e.
Sadly, using -flto to grab bitcode out has been "the way" to do it for
long enough that it's fairly baked in.

>
>  However, it changes the semantic of this command:
>
>    clang -emit-llvm a.c # NOTE: no -c.
>
>  I'm wondering if this command make sense or not.

Me too. :)

>
>  Without my change, Clang will first generate a BC files, and then invoke
> LTO and finally get a.out.
>

That's an interesting choice, I'm not sure it's wrong, but it's
somewhat surprising.

>  With this change, clang will first generate a BC, and feed the resulting
> BC to linker without explicitly saying  LTO needs to be turned on; it works
> fine on Darwin as Apple LD will invoke LTO if it see a BC file, however,
> Other-Unixes + GNU-gold will complains as it see a "corrupted" object file.
>

This part kind of sucks.

-eric



More information about the llvm-commits mailing list