File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -996,6 +996,12 @@ namespace {
996
996
// If we have a raw layout struct who is fixed size, it means the
997
997
// layout of the struct is fully concrete.
998
998
if (rawLayout) {
999
+ // Defer to this fixed type info for type layout if the raw layout
1000
+ // specifies size and alignment.
1001
+ if (rawLayout->getSizeAndAlignment ()) {
1002
+ return IGM.typeLayoutCache .getOrCreateTypeInfoBasedEntry (*this , T);
1003
+ }
1004
+
999
1005
auto likeType = rawLayout->getResolvedLikeType (decl)->getCanonicalType ();
1000
1006
SILType loweredLikeType = IGM.getLoweredType (likeType);
1001
1007
@@ -1112,6 +1118,10 @@ namespace {
1112
1118
// layout of the struct is dependent on the archetype of the thing it's
1113
1119
// like.
1114
1120
if (rawLayout) {
1121
+ // Note: We don't have to handle the size and alignment case here for
1122
+ // raw layout because those are always fixed, so only dependent layouts
1123
+ // will be non-fixed.
1124
+
1115
1125
auto likeType = rawLayout->getResolvedLikeType (decl)->getCanonicalType ();
1116
1126
SILType loweredLikeType = IGM.getLoweredType (likeType);
1117
1127
Original file line number Diff line number Diff line change @@ -6,6 +6,13 @@ extension Foo where T == Int32 {
6
6
7
7
public func foo( _: borrowing Foo < Int32 > ) { }
8
8
9
+ @_rawLayout ( size: 4 , alignment: 4 )
10
+ public struct Int32Fake : ~ Copyable {
11
+ var address : UnsafeMutablePointer < Int32 > {
12
+ . init( Builtin . unprotectedAddressOfBorrow ( self ) )
13
+ }
14
+ }
15
+
9
16
@_rawLayout ( like: T)
10
17
public struct UnsafeCell < T> : ~ Copyable {
11
18
var address : UnsafeMutablePointer < T > {
Original file line number Diff line number Diff line change 5
5
@_rawLayout ( like: Int32)
6
6
public struct Foo < T> : ~ Copyable { }
7
7
8
+ // CHECK-LABEL: @"$s{{[A-Za-z0-9_]*}}5MyIntVWV" = {{.*}} %swift.vwtable
9
+ // size
10
+ // CHECK-SAME: , {{i64|i32}} 4
11
+ // stride
12
+ // CHECK-SAME: , {{i64|i32}} 4
13
+ // flags: alignment 3, noncopyable
14
+ // CHECK-SAME: , <i32 0x800003>
15
+ struct MyInt : ~ Copyable {
16
+ let x : Int32Fake
17
+ }
18
+
8
19
// CHECK-LABEL: @"$s{{[A-Za-z0-9_]*}}9BadBufferVWV" = {{.*}} %swift.vwtable
9
20
// size
10
21
// CHECK-SAME: , {{i64|i32}} 48
@@ -38,3 +49,9 @@ public func something2() -> Int64? {
38
49
let buf = BadBuffer ( )
39
50
return buf. buf. address [ 1 ]
40
51
}
52
+
53
+ // Force emission of MyInt's descriptor to be lazy...
54
+ public func something3( ) -> Int32 {
55
+ let x = MyInt ( x: Int32Fake ( ) )
56
+ return x. x. address. pointee
57
+ }
You can’t perform that action at this time.
0 commit comments