[llvm] [GlobalOpt] Don't replace aliasee with alias that has weak linkage (PR #91483)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu May 16 17:33:47 PDT 2024
efriedma-quic wrote:
linkonce_odr on a function means you can replace a call to the function with the function's body (i.e. inlining). linkonce_odr on a function alias should mean the same thing, I think: a call to the alias can be replaced with the aliasee function's body. This allows a lot of useful optimizations, but it doesn't allow anything more that that. In particular, if you have an internal symbol `@f1`, and `@f2 = linkonce_odr hidden alias void (), ptr @f1`, the "odr-ness" only means that you can replace a call to `@f2` with a call to `@f1`. It doesn't allow replacing a call to `@f1` with a call to `@f2`, which is the transform that was causing trouble here. We sometimes refer to this as "derefinement".
Granted, the usage of linkonce_odr for aliases pointing to __tls_init stretches this definition of "equivalence" to its extreme limit; the different aliases don't do the same thing. It only works because the C++ standard explicitly allows reordering the initialization of thread-local variables.
https://github.com/llvm/llvm-project/pull/91483
More information about the llvm-commits
mailing list