[patch] Optimize more linkonce_odr values during LTO
Rafael EspĂndola
rafael.espindola at gmail.com
Fri Oct 18 15:40:22 PDT 2013
> - // 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.
Cheers,
Rafael
More information about the llvm-commits
mailing list