[Global Opt] add SILFunction *InitializerF to SILGlobalVariable.

It is defaulted to nullptr. When it is set, we increment the SILFunction's
ref count to keep it alive.

It will be used in followon patches for globals that can be statically
initialized.


Swift SVN r21983
This commit is contained in:
Manman Ren
2014-09-16 21:50:56 +00:00
parent 3aa75d0c38
commit 53151b90bd
3 changed files with 21 additions and 0 deletions

View File

@@ -96,6 +96,11 @@ SILModule::SILModule(Module *SwiftModule, const DeclContext *associatedDC)
}
SILModule::~SILModule() {
// Decrement ref count for each SILGlobalVariable with static initializers.
for (SILGlobalVariable &v : silGlobals)
if (v.getInitializer())
v.getInitializer()->decrementRefCount();
for (SILFunction *F : InlinedFunctions)
F->decrementRefCount();