[PATCH] D126341: Order implicitly instantiated global variable's initializer by the reverse instantiation order

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 2 12:48:47 PDT 2022


rnk added a comment.

Well, I guess we're out of luck, but that seems like a very poorly considered requirement from the standard. If we can't use comdats for inline variables, every time you include a header with a dynamically initialized variable, it will generate extra initialization code in every TU that cannot be optimized away. This reminds me of the problems people used to have where every TU including <iostream> emitted extra initialization code.

I think we have two options:

1. Full conformance: Stop using comdats altogether and suffer costs in code size and startup time
2. Partial / compromised conformance: Provide ordering guarantees between global_ctors entries so that we can ensure that inline variables in headers have the expected initialization order


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126341



More information about the cfe-commits mailing list