rjmccall added a comment.

Yeah, both COFF and Mach-O have longstanding ways to protect linker 
dead-stripping, and the compiler already has to manually trigger them on those 
targets for `used`, so it's certainly implementable to also trigger them for 
`retain`-without-`used`.  I just don't think it's a very good feature.  It 
seems to me that the use cases of `retain`-without-`used` all basically boil 
down to "Definition A relies on Definition B in some way that isn't just a 
symbol reference."  `retain`-without-`used` is at best a very rough way of 
achieving that underlying goal of forcing Definition B to be emitted if 
something requires Definition A, and what we really want is a way to express 
that dependence so that the compiler/linker can still strip Definition B if 
Definition A is also stripped.

Also in this space, I think we still don't have a way to express 
`llvm.compiler_used` in the source language, i.e. "feel free to dead-strip this 
if it's never referenced, but if it is referenced, there will be funny uses of 
it that the compiler can't reason about".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96838/new/

https://reviews.llvm.org/D96838

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to