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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to