[patch] Optimize more linkonce_odr values during LTO
Nick Lewycky
nicholas at mxc.ca
Sun Oct 20 13:44:47 PDT 2013
Rafael EspĂndola wrote:
>> - // FIXME: Check if the address is used.
>> - return false;
>> + GlobalStatus GS;
>> + if (GlobalStatus::analyzeGlobal(&GV, GS))
>> + return false;
>> +
>> + return !GS.IsCompared;
>>
>> Why isn't this redundant with hasUnusedAddr()? Is the problem just that
>> internalize runs first then globalopt runs second, so we don't have the
>> unnamed_addr attribute yet?
>
> Close, but there is a bit more. As you pointed out, internalize runs
> first, but we cannot, for example, just add a bit of internalize logic
> to global opt.
>
> The critical issue is that internalize at this point in the code knows
> something that nothing else in llvm does: there is no other reference
> to this symbol from a relocatable object (.o). The transformation
> itself would be valid in global opt, but in general converting
> linkonce_odr to internal linkage means code bloat. It is internalize
> unique position that lets us know that it is profitable.
Aha!
LGTM
This stuff is getting complicated. :) Could you put a file-level comment
in internalize which points out that it's the only place which has this
information from the linker in the LTO case? I already feel sorry for
the next person who has to reason about why all the pieces are laid out
exactly the way they are.
Nick
More information about the llvm-commits
mailing list