[PATCH] D134589: [C++20][Modules] Elide unused guard variables in Itanium ABI module initializers.

Nathan Sidwell via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 26 07:28:18 PDT 2022


urnathan added a comment.

Richard & I discussed this, and decided it was a bad idea, as it means we could have an O(N^2) initialization walk, rather than O(N).

IIUC this is being motivated by NVPTX, which cannot support dynamically initialized global vars.  But in that case we know all the global init fns must be NOP.  However, I recommend not solving that problem piecemeal, but involve NVidia more directly. (There is an alternative design, relying on section ordering, but it is more brittle, and IIRC still requires idempotency vars in some cases.) We should not be pessimizing systems that have dynamic inits to cater for systems that lack them.

For GCC I (eventually) implemented optimizations where:
1 each CMI indicates whether it has a NOP global init fn. 
2 the global init was always emitted, but if it is NOP, it's a completely empty fn (thus importers are not required to implement the below optimization)
3 Importers need not emit calls to known-NOP global inits.

Step #1 took a bit of moving things around, as one only knew there were no global inits at a later point than the CMI was being written out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134589



More information about the cfe-commits mailing list