[patch] Don't rauw an alias in llvm.used

Duncan Sands baldrick at free.fr
Tue Apr 16 03:16:21 PDT 2013


Hi Rafael,

On 16/04/13 05:57, Rafael EspĂ­ndola wrote:
> Clang has recently started producing internal but llvm.used aliases as
> a backward compatibility hack for static functions declared in an
> extern C context.

can you please give some examples.

Anyway, it sounds like an impedance mismatch between the nature of llvm.used,
which is adapted to recording that a particular bit of memory is used (the
memory represented by a global variable), and how llvm.used is being used by
clang: to record that a certain *name* (the name of a global variable) is being
used somewhere.

Thanks, Duncan.

> This found an interesting bug in GlobalOpt: It would replace the alias
> with the function in the initialization of llvm.used, allowing llvm to
> drop the alias.
>
> One option would be to just not call replaceAllUsesWith if the alias
> is in llvm.used. We would lose some optimizations and I am afraid of
> making it possible for users to add __attribute__((used)) to get this
> side effect. What we should do is replace all other users.
>
> This patch implements that, but I will be the first to admit that
> calling replaceAllUsesWith and then resetting llvm.used back is fairly
> ugly. The alternative however is to duplicate the COW logic for
> constants in replaceAllUsesWith. Should I give that a try?
>
> I was also fairly surprised to find stripPointerCasts "stripping"
> GloablAliases. Should we try to change that?
>
> Cheers,
> Rafael
>




More information about the llvm-commits mailing list