Commits

Manman Ren committed 18042db194f
[Global Opt] update SILGlobalOpt to use static initializer if possible. This is off by default and is a modified version of r21996 (reverted in r22001). Update SILGlobalOpt to remove "once" call from addressor and set the InitializerF for SILGlboalVariable if legal. For calls to addressor in non-cold block, we check the addressor to find out the globalinit_func and the associated SILGlobalVariable. If legal, we set InitializerF of SILGlobalVariable and remove "once" call from addressor. The current rules for legality: 1> the addressor contains a single "once" call and it calls globalinit_func. 2> the globalinit_func is called by "once" from a single location. When we inline the addressor, the globalinit_func will be called by "once" from multiple locations. After we remove the "once" from the addressor, the inlined version will mistakely initialize the global variable again. 3> the globalinit_func is trivial as defined by SILGlobalVariable::canBeStaticInitializer(). Update IRGen to generate constant initializers for global variables with static initializers (i.e non-null InitializerF). Joe's suggestion on having the static initializer to return the result instead of storing it is not implemented in this commit. But we do verify that a static initializer has a single store to the global variable. The suggestion is tracked in rdar://18382039. Implement rdar://16621368, rdar://18169093. Swift SVN r22083