Skip to content

Commit ade98f4

Browse files
authored
Merge pull request #15486 from gottesmm/pr-37d155196450aa04e1fd3a5963ebcb06c2fab76b
[globalopt] Eliminate indentation by inverting a condition into an ea…
2 parents c7a59c3 + a99b65c commit ade98f4

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

lib/SILOptimizer/IPO/GlobalOpt.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -804,30 +804,29 @@ void SILGlobalOpt::optimizeInitializer(SILFunction *AddrF,
804804
}
805805

806806
SILGlobalVariable *SILGlobalOpt::getVariableOfGlobalInit(SILFunction *AddrF) {
807-
if (AddrF->isGlobalInit()) {
808-
// If the addressor contains a single "once" call, it calls globalinit_func,
809-
// and the globalinit_func is called by "once" from a single location,
810-
// continue; otherwise bail.
811-
BuiltinInst *CallToOnce;
812-
auto *InitF = findInitializer(Module, AddrF, CallToOnce);
813-
814-
if (!InitF || !InitF->getName().startswith("globalinit_")
815-
|| InitializerCount[InitF] > 1)
816-
return nullptr;
807+
if (!AddrF->isGlobalInit())
808+
return nullptr;
817809

818-
// If the globalinit_func is trivial, continue; otherwise bail.
819-
SingleValueInstruction *dummyInitVal;
820-
auto *SILG = getVariableOfStaticInitializer(InitF, dummyInitVal);
821-
if (!SILG || !SILG->isDefinition())
822-
return nullptr;
810+
// If the addressor contains a single "once" call, it calls globalinit_func,
811+
// and the globalinit_func is called by "once" from a single location,
812+
// continue; otherwise bail.
813+
BuiltinInst *CallToOnce;
814+
auto *InitF = findInitializer(Module, AddrF, CallToOnce);
823815

824-
return SILG;
825-
}
826-
return nullptr;
816+
if (!InitF || !InitF->getName().startswith("globalinit_")
817+
|| InitializerCount[InitF] > 1)
818+
return nullptr;
819+
820+
// If the globalinit_func is trivial, continue; otherwise bail.
821+
SingleValueInstruction *dummyInitVal;
822+
auto *SILG = getVariableOfStaticInitializer(InitF, dummyInitVal);
823+
if (!SILG || !SILG->isDefinition())
824+
return nullptr;
825+
826+
return SILG;
827827
}
828828

829829
static bool canBeChangedExternally(SILGlobalVariable *SILG) {
830-
831830
// Don't assume anything about globals which are imported from other modules.
832831
if (isAvailableExternally(SILG->getLinkage()))
833832
return true;

0 commit comments

Comments
 (0)