[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

Hubert Tong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 17 13:00:32 PDT 2023


hubert.reinterpretcast added a comment.

In D150221#4350761 <https://reviews.llvm.org/D150221#4350761>, @rjmccall wrote:

> I'm not sure if it's better to represent that by using `__attribute__((used))` on every global variable or by setting something more globally in the module.  The latter seems more impervious to the LTO problem, at least.

`__attribute__((__used__))` has the advantage of being something that already exists. If the "more global" property can hook in as treating all variables as `__attribute__((__used__))` where the query for `__attribute__((__used__))` is implemented in the middle-end/back-end (including places where the symbol is marked as used with respect to linker garbage collection), then maybe it is not too intrusive in terms of implementation.

As for which aspect of `__attribute__((__used__))` is more important: The explicit user request we had was for the variables to be kept in an obvious manner in the symbol table. It seems multiple aspects of the `__attribute__((__used__))` semantics are helpful here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221



More information about the cfe-commits mailing list