[PATCH] D23488: ThinLTO: add early "dead-stripping" on the Index

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 16:21:43 PST 2016


tejohnson added a comment.

In https://reviews.llvm.org/D23488#627212, @pcc wrote:

> In https://reviews.llvm.org/D23488#627201, @mehdi_amini wrote:
>
> > In https://reviews.llvm.org/D23488#627136, @tejohnson wrote:
> >
> > > In https://reviews.llvm.org/D23488#627135, @mehdi_amini wrote:
> > >
> > > > As an alternative, have you considered having a bit "used" (or "do not dead strip") that would express in the summary exactly what we want?
> > >
> > >
> > > Yes, that would be another alternative, I thought about that but was hoping it could be avoided, but maybe not easily. The bit would probably need to be set for any variable that starts with "llvm." to be safely conservative (e.g. we should also consider anything in llvm.used or llvm.compiler.used as potentially live).
> >
> >
> > llvm.used is definitely a must-be root, llvm.compiler.used are supposed to be able to be dead-stripped at link-time.
>
>
> I think we will need logic for removing entries from llvm.compiler.used then. Consider this scenario:
>
> module A:
>
>   @llvm.compiler.used = [@f]
>  
>   define internal void @f() {
>     call void @g()
>     ret void
>   }
>  
>   declare void @g()
>
>
> module B:
>
>   define void @g() {
>     ret void
>   }
>
>
> In this case we can't dead strip f by internalizing as that would end up keeping the reference to the dead function g, we need to actually remove it.


Yes. And since the llvm.compiler.used symbols aren't supposed to be touched by the compiler, I'm not sure what the legality is of removing from there for this optimization done in the thin link + thinlto backend. Probably not worth special casing llvm.compiler.used  - just treat it conservatively (as gc roots).


https://reviews.llvm.org/D23488





More information about the llvm-commits mailing list