Skip to content

Commit 02459d0

Browse files
committed
[TypeLowering] Mark lexical when marking non-trivial.
In addition to starting all RecursiveProperties values which are NonTrivial as Lexical, also mark instances of the structs which are modified to become NonTrivial to simultaneously become Lexical.
1 parent f3cc081 commit 02459d0

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lib/SIL/IR/TypeLowering.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,6 +2099,7 @@ namespace {
20992099
if (D->isCxxNonTrivial()) {
21002100
properties.setAddressOnly();
21012101
properties.setNonTrivial();
2102+
properties.setLexical(IsLexical);
21022103
}
21032104

21042105
auto subMap = structType->getContextSubstitutionMap(&TC.M, D);
@@ -2158,6 +2159,9 @@ namespace {
21582159
// may be added resiliently later.
21592160
if (D->isIndirect()) {
21602161
properties.setNonTrivial();
2162+
properties.setLexical(IsLexical);
2163+
properties =
2164+
applyLifetimeAnnotation(D->getLifetimeAnnotation(), properties);
21612165
return new (TC) LoadableEnumTypeLowering(enumType, properties,
21622166
Expansion);
21632167
}
@@ -2173,6 +2177,9 @@ namespace {
21732177
// Indirect elements only make the type nontrivial.
21742178
if (elt->isIndirect()) {
21752179
properties.setNonTrivial();
2180+
properties.setLexical(IsLexical);
2181+
properties =
2182+
applyLifetimeAnnotation(elt->getLifetimeAnnotation(), properties);
21762183
continue;
21772184
}
21782185

test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import TypeClassification
55
// Make sure that "StructWithDestructor" is marked as non-trivial by checking for a
66
// "destroy_addr".
77
// CHECK-LABEL: sil [ossa] @$s4main24testStructWithDestructoryyF
8-
// CHECK: [[AS:%.*]] = alloc_stack $StructWithDestructor
8+
// CHECK: [[AS:%.*]] = alloc_stack [lexical] $StructWithDestructor
99
// CHECK: [[FN:%.*]] = function_ref @{{_ZN20StructWithDestructorC1Ev|\?\?0StructWithDestructor@@QEAA@XZ}} : $@convention(c) () -> @out StructWithDestructor
1010
// CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out StructWithDestructor
1111
// CHECK: destroy_addr [[AS]]
@@ -20,7 +20,7 @@ public func testStructWithDestructor() {
2020
// Make sure that "HasMemberWithDestructor" is marked as non-trivial by checking
2121
// for a "destroy_addr".
2222
// CHECK-LABEL: sil [ossa] @$s4main33testStructWithSubobjectDestructoryyF : $@convention(thin) () -> ()
23-
// CHECK: [[AS:%.*]] = alloc_stack $StructWithSubobjectDestructor
23+
// CHECK: [[AS:%.*]] = alloc_stack [lexical] $StructWithSubobjectDestructor
2424
// CHECK: [[FN:%.*]] = function_ref @{{_ZN29StructWithSubobjectDestructorC1Ev|\?\?0StructWithSubobjectDestructor@@QEAA@XZ}} : $@convention(c) () -> @out StructWithSubobjectDestructor
2525
// CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out StructWithSubobjectDestructor
2626
// CHECK: destroy_addr [[AS]]
@@ -32,7 +32,7 @@ public func testStructWithSubobjectDestructor() {
3232
}
3333

3434
// CHECK-LABEL: sil [ossa] @$s4main37testStructWithCopyConstructorAndValueSbyF
35-
// CHECK: [[AS:%.*]] = alloc_stack $StructWithCopyConstructorAndValue
35+
// CHECK: [[AS:%.*]] = alloc_stack [lexical] $StructWithCopyConstructorAndValue
3636
// CHECK: [[FN:%.*]] = function_ref @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue
3737
// CHECK: apply [[FN]]([[AS]], %{{.*}}) : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue
3838
// CHECK: [[OBJ_VAL_ADDR:%.*]] = struct_element_addr [[AS]] : $*StructWithCopyConstructorAndValue, #StructWithCopyConstructorAndValue.value
@@ -53,7 +53,7 @@ public func testStructWithCopyConstructorAndValue() -> Bool {
5353
}
5454

5555
// CHECK-LABEL: sil [ossa] @$s4main46testStructWithSubobjectCopyConstructorAndValueSbyF : $@convention(thin) () -> Bool
56-
// CHECK: [[MEMBER_0:%.*]] = alloc_stack $StructWithCopyConstructorAndValue
56+
// CHECK: [[MEMBER_0:%.*]] = alloc_stack [lexical] $StructWithCopyConstructorAndValue
5757
// CHECK: [[MAKE_MEMBER_FN:%.*]] = function_ref @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue
5858
// CHECK: apply [[MAKE_MEMBER_FN]]([[MEMBER_0]], %{{.*}}) : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue
5959
// CHECK: [[AS:%.*]] = alloc_stack $StructWithSubobjectCopyConstructorAndValue
@@ -87,7 +87,7 @@ public func testStructWithSubobjectCopyConstructorAndValue() -> Bool {
8787

8888
// testStructWithCopyConstructorAndSubobjectCopyConstructorAndValue()
8989
// CHECK-LABEL: sil [ossa] @$s4main041testStructWithCopyConstructorAndSubobjectefG5ValueSbyF : $@convention(thin) () -> Bool
90-
// CHECK: [[MEMBER_0:%.*]] = alloc_stack $StructWithCopyConstructorAndValue
90+
// CHECK: [[MEMBER_0:%.*]] = alloc_stack [lexical] $StructWithCopyConstructorAndValue
9191
// CHECK: [[CREATE_MEMBER_FN:%.*]] = function_ref @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue
9292
// CHECK: apply [[CREATE_MEMBER_FN]]([[MEMBER_0]], %{{.*}}) : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue
9393
// CHECK: [[AS:%.*]] = alloc_stack $StructWithCopyConstructorAndSubobjectCopyConstructorAndValue

0 commit comments

Comments
 (0)