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

Shuxin Yang shuxin.llvm at gmail.com
Tue Aug 13 17:29:18 PDT 2013


Hi, Eric:

  Thank you for the code review.

On 8/13/13 5:15 PM, Eric Christopher wrote:
> 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.

There are couple of reasons for differentiating them.

For instance, vectorization should not be conducted in 2) because it is 
too early to kick in --
after aggressive inter-procedural optimization, some symbolic trip-count
will become constant, and some functions are inlined, enabling more 
opportunities etc...

In short,  2) tries to eliminate as much as redundancy without increase 
code size,
and basically, most loop transformations, no matter it's on a single 
loop, or a loop nest,
must be disabled in 2).

Thank you again for the code review.

Shuxin

>
>>   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