[LLVMdev] RFC: ThinLTO Symbol Linkage and Renaming

Xinliang David Li xinliangli at gmail.com
Tue Jul 21 15:35:58 PDT 2015


>
> This scares me a little for linkonce -- there's a minor change to
> semantics if the importing module would have linked against a
> *different* definition of the same symbol -- but I'm not really
> sure it matters much.
>
>

This should not be an issue in practice as it exists non thinLTO
compilations too. For instance changing the optimization level of one
module can lead to different inline decisions and different copy of the
comdat function to be picked up in the end.



> >
>
> I wonder whether a prefix would be better?
>
> All the promotion/renaming scares me.  I feel like there may be
> dragons here we're not aware of.
>
>
The promotion scheme is similar to LIPO which has been exercised on large
number of huge C++ apps --  I think it is robust.



> The only concrete concern I have (once you switch to hidden
> visibility) is the interaction with non-LTO'd objects being linked
> into the same executable, but I wonder if I'm missing something
> else, too...
>
>
There is an limitation (also with LIPO, LTO) that you can not compile one
module say 'a.c' in thinLTO mode with the rest of the modules, and later
recompile 'a.c' into 'a.o' without thinLTO and tries to mix and match with
the rest of the real object files built with thinLTO unless 'a.c' is not
imported by any other modules or it does not have any statics to be
promoted.

thanks,

David




> >
> > 5  Linkage Change Summary Table
> >
> > The following table summarizes the linkage change that happen during
> ThinLTO backend compilations. Note that the only time the linkage changes
> in the original module is for the static promotion case (for Internal and
> Private linkages), where it changes to External as described in Section
> 4.3.1. In all other cases the linkage in the original module stays the
> same, and therefore is not noted in the table below.
> >
> > Note that there are no InternalLinkage, PrivateLinkage,
> AvailableExternallyLinkage, LinkOnce*Linkage, Weak*Linkage,
> AppendingLinkage and CommonLinkage declarations. There are no
> ExternalWeakLinkage definitions.
> >
> >
> +---------------------------------+------------------------------------------------+
> > |                                 |        Importing Module Linkage
>           |
> > |    Original Module
> +----------------------+-------------------------+
> > |                                 | Import definition    | Import as
> declaration   |
> >
> +----------------------------------------------------------------------------------+
> > | External (def)                  |  AvailableExternally |  External
>            |
> >
> +----------------------------------------------------------------------------------+
> > | External (decl)                 |  N/A                 |  External
>            |
> >
> +----------------+-----------------------------------------------------------------+
> > |                |  Promote[1]    |  AvailableExternally |  External
>            |
> > | Internal (def)
> +-----------------------------------------------------------------+
> > |                |  NoPromote     |  Internal            |  N/A (force
> import def) |
> >
> +----------------------------------------------------------------------------------+
> > |                |  Promote[1]    |  AvailableExternally |  External
>            |
> > | Private (def)
> +-----------------------------------------------------------------+
> > |                |  NoPromote     |  Private             |  N/A (force
> import def) |
> >
> +----------------+-----------------------------------------------------------------+
> > | AvailableExternally (def)       |  AvailableExternally |  External
>            |
> >
> +----------------------------------------------------------------------------------+
> > | LinkOnceAny (def)               |  LinkOnceAny         |  N/A (force
> import def) |
> >
> +----------------------------------------------------------------------------------+
> > | LinkOnceODR (def)               |  LinkOnceODR         |  N/A (force
> import def) |
> >
> +----------------------------------------------------------------------------------+
> > | WeakAny (def)                   |  N/A (never import)  |
> ExternalWeak           |
> >
> +----------------------------------------------------------------------------------+
> > | WeakODR (def)                   |  WeakODR             |
> ExternalWeak           |
> >
> +----------------------------------------------------------------------------------+
> > | Appending (def) (only variables)|  N/A (never import)  |  N/A (never
> import)     |
> >
> +----------------------------------------------------------------------------------+
> > | ExternalWeak (decl)             |  N/A                 |
> ExternalWeak           |
> >
> +----------------------------------------------------------------------------------+
> > | Common (def) (only variables)   |  Common              |  N/A (always
> import def)|
> >
> +---------------------------------+----------------------+-------------------------+
> >
> > [1] Linkage in original module changes to External
> >
> > --
> > Teresa Johnson |       Software Engineer |     tejohnson at google.com |
> 408-460-2413
> >
> <ThinLTOSymbolLinkageandRenaming.pdf>_______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150721/357930e0/attachment.html>


More information about the llvm-dev mailing list