[PATCH] D96838: Add GNU attribute 'retain'

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 21 19:02:23 PST 2021


MaskRay added a comment.

In D96838#2578073 <https://reviews.llvm.org/D96838#2578073>, @rjmccall wrote:

> GCC 11 hasn't been released yet, so can we still engage with GCC about the semantics of this attribute?  This is a very low-level attribute, and I don't understand why it was made separate instead of just having `used` add the appropriate section flag on targets that support it.

GCC did overload `used` with the linker garbage collection semantics. Then after discussions (e.g. https://gcc.gnu.org/pipermail/gcc-patches/2021-February/565478.html) they decided to pick the earliest suggestion: add `retain`.

This makes sense to me: `used` can emit a function which is only used by inline assembly, but the user intention can still be that the whole thing can be GCable.

IIUC macOS's always enabled `.subsections_via_symbols` means always -ffunction-sections/-fdata-sections, so there is no GC preciseness concern.
However, the current Windows behavior (`.drectve` include a linker option to force retaining the whole section) can unnecessarily retain the full section.


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