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

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Apr 15 20:57:27 PDT 2013


Clang has recently started producing internal but llvm.used aliases as
a backward compatibility hack for static functions declared in an
extern C context.

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 3709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130415/b4af4726/attachment.obj>


More information about the llvm-commits mailing list