[llvm-dev] Request For Comments: used attribute semantics (original) (raw)

Snider, Todd via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 18 12:27:36 PST 2018


Hi All,

The semantics for the used attribute is not consistent in the llvm/clang source code base from one vendor implementation to another.

Is there another attribute besides the used attribute, which can be applied to a function or data object, that can be interpreted to mean that the function or data object definition must be kept in the compiled object file, but may be removed at link-time if the function/data object is not referenced elsewhere in the application? Does the GCC's "externally_visible" attribute fit this description?

Alternatively, if we were to assume that the used attribute is interpreted to mean that a function/data object definition is kept in the compiled object file, but not necessarily retained in the linked output file, then is there another function/variable attribute that can be interpreted to mean that the definition function/data object must be retained in the linked output file? If not, I speculate that it would be useful to introduce a new function/variable attribute (retain?) that behaves exactly like the used attribute in terms of emitting a definition of a function/data object to the compiled object file even if it doesn't appear to be referenced, but will also inform the linker that the section in which the function/data object is defined must be retained in the linked output file.

Thoughts? Opinions? Concerns?

~ Todd -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181218/fa875628/attachment.html>



More information about the llvm-dev mailing list