[llvm-dev] Weak symbol/alias semantics
Teresa Johnson via llvm-dev
llvm-dev at lists.llvm.org
Wed Jan 18 07:24:24 PST 2017
On Wed, Jan 18, 2017 at 7:16 AM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:
> >> The rule should be that the alias to aliasee link is never broken. The
> >> reason being that an alias at the file level is just another symbol with
> >> the same value.
> >> So if foo is an alias to bar, accessing that foo will always be the same
> >> as accessing that bar, regardless of either of them being weak. I say
> >> *that* foo and *that* bar because symbol resolution may pick another foo
> >> and another bar.
> > Are you just talking about the comdat case?
> No, that is always the case.
> > If this also applies to the
> > non-comdat case, I'm not sure how this works in the following situation
> > (copied from an example in my response just now to pcc):
> > If a module contains the following, and both @x and @y are non-prevailing
> > in that module:
> > @x = weak global ...
> > @y = weak alias @x
> > and the prevailing def for @x is in moduleX with a different value than
> > prevailing def for @y which comes from moduleY. Just because they are
> > aliased in this module doesn't mean they must be aliased elsewhere,
> > right?
> > For this case (weak non-prevailing alias to a weak non-prevailing def) I
> > think it should eventually become:
> > @x = external global
> > @y = external global
> When dropping @x and @y during IR linking? I agree.
> > Trying to understand how this fits with your comment that "The rule
> > be that the alias to aliasee link is never broken", unless that is just
> > referring to the case I mentioned just above about when they are both in
> > comdats.
> In the above example the "link/connection" is not broken. The original
> @x and @y still refer to the same data, it is just that neither is used
> in the final linked object.
Ok, thanks. But how does that property work the strongalias case from the
original email. E.g.:
@f = weak global ...
@strongalias = alias @f
What we had concluded was that it should be transformed into the following
when this copy of @f is non-prevailing:
@f = external global
@f.llvm.1 = internal global ... // Internalized copy of original @f
@strongalias = alias @fv.llvm.1
Maybe we are just using different terminology for the same thing, but in
this case it seems as though we have broken the link between the original
alias @f and aliasee @strongalias? Or is the point that we haven't broken
the link between the value in this module of @f (copied to @f.llvm.1) and
Teresa Johnson | Software Engineer | tejohnson at google.com | 408-460-2413
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev