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

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 17 15:31:08 PDT 2023


rjmccall added a comment.

The hot-patch use case actually shouldn't care if the compiler/linker throws away unused things because it can't possibly affect how the patch interoperates with existing code.  This does rely on the unanalyzable-use part of the semantics, though, to stop the compiler from removing uses that could become significant after hot-patching.

Force-emitting every `static` in the translation unit can be very expensive; there are a lot of headers that declare all their constants as `static const`.  And removing dead globals is a pretty important optimization, e.g. to eliminate the string literals used by assertions that the compiler was able to fold to `true`.  So I don't think it's unreasonable for us to ask whether we should just be naively adding this option instead of figuring out a more targeted way of satisfying these users.


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