Skip to content

Commit 32208fa

Browse files
committed
SILGen: Use maximal resilience expansion to decide if we need an ivar destroyer
1 parent c69b7f4 commit 32208fa

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,8 @@ bool SILGenModule::hasNonTrivialIVars(ClassDecl *cd) {
956956
auto *vd = dyn_cast<VarDecl>(member);
957957
if (!vd || !vd->hasStorage()) continue;
958958

959-
// FIXME: Expansion
960959
auto &ti = Types.getTypeLowering(vd->getType(),
961-
ResilienceExpansion::Minimal);
960+
ResilienceExpansion::Maximal);
962961
if (!ti.isTrivial())
963962
return true;
964963
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
// RUN: %empty-directory(%t)
3+
// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -enable-sil-ownership %S/../Inputs/resilient_struct.swift
4+
// RUN: %target-swift-emit-silgen -I %t -enable-sil-ownership -enable-resilience %s | %FileCheck %s
5+
6+
import resilient_struct
7+
8+
public class Base {}
9+
10+
public struct MyResilientInt {
11+
var i: Int
12+
13+
public init(i: Int) { self.i = i }
14+
}
15+
16+
public class NeedsIVarDetroyer : Base {
17+
var x = ResilientInt(i: 0)
18+
}
19+
20+
public class DoesNotNeedIVarDestroyer : Base {
21+
var x = MyResilientInt(i: 0)
22+
}
23+
24+
// CHECK-LABEL: sil_vtable NeedsIVarDetroyer {
25+
// CHECK-NEXT: #Base.init!allocator.1: (Base.Type) -> () -> Base
26+
// CHECK-NEXT: #NeedsIVarDetroyer.x!getter.1: (NeedsIVarDetroyer) -> () -> resilient_struct.ResilientInt
27+
// CHECK-NEXT: #NeedsIVarDetroyer.x!setter.1: (NeedsIVarDetroyer) -> (resilient_struct.ResilientInt) -> ()
28+
// CHECK-NEXT: #NeedsIVarDetroyer.x!modify.1: (NeedsIVarDetroyer) -> () -> ()
29+
// CHECK-NEXT: #NeedsIVarDetroyer.deinit!deallocator.1
30+
// CHECK-NEXT: #NeedsIVarDetroyer!ivardestroyer.1
31+
// CHECK-NEXT: }
32+
33+
// CHECK-LABEL: sil_vtable DoesNotNeedIVarDestroyer {
34+
// CHECK-NEXT: #Base.init!allocator.1: (Base.Type) -> () -> Base
35+
// CHECK-NEXT: #DoesNotNeedIVarDestroyer.x!getter.1: (DoesNotNeedIVarDestroyer) -> () -> MyResilientInt
36+
// CHECK-NEXT: #DoesNotNeedIVarDestroyer.x!setter.1: (DoesNotNeedIVarDestroyer) -> (MyResilientInt) -> ()
37+
// CHECK-NEXT: #DoesNotNeedIVarDestroyer.x!modify.1: (DoesNotNeedIVarDestroyer) -> () -> ()
38+
// CHECK-NEXT: #DoesNotNeedIVarDestroyer.deinit!deallocator.1
39+
// CHECK-NEXT: }

0 commit comments

Comments
 (0)