Skip to content

Commit 6826ff1

Browse files
committed
[5.9] Add static isValueTypeWithDeinit
because the SILType method has not been merged to 5.9.
1 parent b61a73d commit 6826ff1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/SIL/Utils/FieldSensitivePrunedLiveness.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ static StructDecl *getFullyReferenceableStruct(SILType ktypeTy) {
4747
return structDecl;
4848
}
4949

50+
static bool isValueTypeWithDeinit(SILType type) {
51+
// Do not look inside an aggregate type that has a user-deinit, for which
52+
// memberwise-destruction is not equivalent to aggregate destruction.
53+
if (auto *nominal = type.getNominalOrBoundGenericNominal()) {
54+
return nominal->getValueTypeDestructor() != nullptr;
55+
}
56+
return false;
57+
}
58+
5059
//===----------------------------------------------------------------------===//
5160
// MARK: TypeSubElementCount
5261
//===----------------------------------------------------------------------===//
@@ -70,7 +79,7 @@ TypeSubElementCount::TypeSubElementCount(SILType type, SILModule &mod,
7079
type.getFieldType(fieldDecl, mod, context), mod, context);
7180
number = numElements;
7281

73-
if (type.isValueTypeWithDeinit()) {
82+
if (isValueTypeWithDeinit(type)) {
7483
// 'self' has its own liveness represented as an additional field at the
7584
// end of the structure.
7685
++number;
@@ -355,7 +364,7 @@ void TypeTreeLeafTypeRange::constructFilteredProjections(
355364
callback(newValue, TypeTreeLeafTypeRange(start, next));
356365
start = next;
357366
}
358-
if (type.isValueTypeWithDeinit()) {
367+
if (isValueTypeWithDeinit(type)) {
359368
// 'self' has its own liveness
360369
++start;
361370
}

0 commit comments

Comments
 (0)