@@ -67,34 +67,6 @@ static bool allUsesInSameBlock(AllocStackInst *ASI) {
67
67
return numDeallocStacks == 1 ;
68
68
}
69
69
70
- // / We don't handle empty tuples and empty structs.
71
- // /
72
- // / Locations with empty types don't even need a store to count as
73
- // / "initialized". We don't handle such cases.
74
- static bool isEmptyType (SILType ty, SILFunction *function) {
75
- if (auto tupleTy = ty.getAs <TupleType>()) {
76
- // A tuple is empty if it either has no elements or if all elements are
77
- // empty.
78
- for (unsigned idx = 0 , num = tupleTy->getNumElements (); idx < num; ++idx) {
79
- if (!isEmptyType (ty.getTupleElementType (idx), function))
80
- return false ;
81
- }
82
- return true ;
83
- }
84
- if (StructDecl *structDecl = ty.getStructOrBoundGenericStruct ()) {
85
- // Also, a struct is empty if it either has no fields or if all fields are
86
- // empty.
87
- SILModule &module = function->getModule ();
88
- TypeExpansionContext typeEx = function->getTypeExpansionContext ();
89
- for (VarDecl *field : structDecl->getStoredProperties ()) {
90
- if (!isEmptyType (ty.getFieldType (field, module , typeEx), function))
91
- return false ;
92
- }
93
- return true ;
94
- }
95
- return false ;
96
- }
97
-
98
70
} // anonymous namespace
99
71
} // namespace swift
100
72
@@ -117,7 +89,7 @@ MemoryLocations::Location::Location(SILValue val, unsigned index, int parentIdx)
117
89
118
90
void MemoryLocations::Location::updateFieldCounters (SILType ty, int increment) {
119
91
SILFunction *function = representativeValue->getFunction ();
120
- if (!isEmptyType (ty, function)) {
92
+ if (!ty. isEmpty (* function)) {
121
93
numFieldsNotCoveredBySubfields += increment;
122
94
if (!ty.isTrivial (*function))
123
95
numNonTrivialFieldsNotCovered += increment;
@@ -215,7 +187,11 @@ void MemoryLocations::analyzeLocation(SILValue loc) {
215
187
if (!handleTrivialLocations && loc->getType ().isTrivial (*function))
216
188
return ;
217
189
218
- if (isEmptyType (loc->getType (), function))
190
+ // / We don't handle empty tuples and empty structs.
191
+ // /
192
+ // / Locations with empty types don't even need a store to count as
193
+ // / "initialized". We don't handle such cases.
194
+ if (loc->getType ().isEmpty (*function))
219
195
return ;
220
196
221
197
unsigned currentLocIdx = locations.size ();
@@ -400,7 +376,7 @@ bool MemoryLocations::analyzeAddrProjection(
400
376
SingleValueInstruction *projection, unsigned parentLocIdx,unsigned fieldNr,
401
377
SmallVectorImpl<SILValue> &collectedVals, SubLocationMap &subLocationMap) {
402
378
403
- if (isEmptyType ( projection->getType (), projection->getFunction ()))
379
+ if (projection->getType (). isEmpty (* projection->getFunction ()))
404
380
return false ;
405
381
406
382
auto key = std::make_pair (parentLocIdx, fieldNr);
0 commit comments