[PATCH] D96838: Add GNU attribute 'retain'

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 22 12:34:20 PST 2021


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



More information about the cfe-commits mailing list