[PATCH] D96838: Add GNU attribute 'retain'

Paul Robinson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 23 12:58:44 PST 2021


probinson added a comment.

> For ELF, `used` does not retain the entity, regardless of this patch.

That statement does not match my experience.

Note that there are two separate variables documented in the LangRef: `llvm.used` (which corresponds to source attribute `used` and is documented as affecting linker behavior) and `llvm.compiler.used` (which is a rare construct with no corresponding source attribute, and does not affect linker behavior).  So, according to LangRef, source attribute `used` maps to `llvm.used` which is documented as affecting linker behavior, and that's exactly the behavior I am seeing in my project.

But from a user perspective, the IR representation is irrelevant, I don't actually care what the description of `llvm.used` says.  I put attribute `used` on my data, and it is still there in the final executable.  That's how things have worked for a long time, and I am concerned that you are about to break it.  Note that I am not using groups or comdats or anything else funky; I'm declaring static variables in a custom section, adding attribute `used` and the necessary `__start_/__stop_` symbols, and everything works exactly as I want.

Maybe there is a different patch that more directly relates to my concern, and probably we should be having this conversation on the llvm-dev thread instead of in a patch that  not many people are paying attention to.  I'm very happy to move the discussion elsewhere if that would help.


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