[llvm-dev] Weak symbol/alias semantics
Rafael Avila de Espindola via llvm-dev
llvm-dev at lists.llvm.org
Wed Jan 18 07:16:02 PST 2017
>> 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 the
> prevailing def for @y which comes from moduleY. Just because they are
> aliased in this module doesn't mean they must be aliased elsewhere,
> 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 should
> 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
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.
More information about the llvm-dev