Skip to content

Commit da283e2

Browse files
committed
SIL: Resilient types don't need to be treated as addressable-for-dependencies inside their resilience domain.
Outside of the resilience domain, they have to be treated as opaque and therefore potentially addressable-for-dependencies, but inside of the resilience domain, we may take advantage of knowing the type layout to load indirect parameters out of memory and break the (unnecessary) dependency on a fixed memory location. Fixes rdar://151268401. We do still however have problems when the type is actually `@_addressableForDependencies` inside of its resilience domain (rdar://151500074). I'll fix that in a follow up.
1 parent efe53f0 commit da283e2

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

include/swift/SIL/TypeLowering.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class TypeLowering {
266266
static constexpr RecursiveProperties forResilient() {
267267
return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsResilient,
268268
IsNotTypeExpansionSensitive, HasRawPointer, IsNotLexical,
269-
HasNoPack, IsAddressableForDependencies};
269+
HasNoPack, IsNotAddressableForDependencies};
270270
}
271271

272272
void addSubobject(RecursiveProperties other) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %target-swift-frontend -enable-experimental-feature AddressableTypes -enable-experimental-feature LifetimeDependence -enable-library-evolution -emit-sil -verify %s
2+
3+
internal struct Wrapper {
4+
let inner: Resilient
5+
6+
@lifetime(borrow self)
7+
borrowing func getSpan() -> RawSpan { self.inner.getSpan() }
8+
}
9+
10+
public struct Resilient {
11+
var field: AnyObject
12+
13+
@lifetime(borrow self)
14+
borrowing func getSpan() -> RawSpan { fatalError() }
15+
}
16+
17+
/*
18+
// TODO (rdar://151268401): We still get spurious errors about escaping `self`
19+
// in cases where the wrapped type is concretely addressable-for-dependencies.
20+
internal struct AFDWrapper {
21+
let inner: AFDResilient
22+
23+
@lifetime(borrow self)
24+
borrowing func getSpan() -> RawSpan { self.inner.getSpan() }
25+
}
26+
27+
@_addressableForDependencies
28+
public struct AFDResilient {
29+
@lifetime(borrow self)
30+
borrowing func getSpan() -> RawSpan { fatalError() }
31+
}
32+
*/

0 commit comments

Comments
 (0)