[LLVMdev] [RFC] Alias should not point to declarations

Chris Lattner
Wed, 30 Oct 2013 19:50:32 -0000

On Oct 30, 2013, at 12:35 PM, Rafael Espíndola <rafael.espindola at
gmail.com> wrote:

> A long time ago (before r97733) we used to model the weakref attribute
> by outputting a new declaration and a weak alias to it. This was
> fairly buggy and we now implement weakref directly in clang, with the
> same logic an assembler uses to implement .weakref (which is what gcc
> prints).

This makes sense to me, but I'm not an expert on ELF aliases.

If you're working in this area, there is something that has been bugging me
for years about GlobalAlias: because we require the type of the alias and
aliasee to match, we have to allow constant exprs in the aliasee (see
GlobalAlias::getAliasedGlobal).

This representation is bad for several reasons.  I think it would be much better
to change GlobalAlias to allow the aliasee to have a different type than the
alias itself, and then require the aliasee to be an actual GlobalValue,
disallowing constexprs completely.

-Chris