Skip to content

Commit 3934652

Browse files
Merge pull request swiftlang#81581 from nate-chandler/rdar147207926
[TypeLowering] Record packs used in signatures.
2 parents 24f2975 + aa49b85 commit 3934652

File tree

3 files changed

+75
-3
lines changed

3 files changed

+75
-3
lines changed

lib/SIL/IR/SILInstruction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ bool SILInstruction::isDeallocatingStack() const {
13541354
}
13551355

13561356
static bool typeOrLayoutInvolvesPack(SILType ty, SILFunction const &F) {
1357-
return ty.hasAnyPack() || ty.isOrContainsPack(F);
1357+
return ty.isOrContainsPack(F);
13581358
}
13591359

13601360
bool SILInstruction::mayRequirePackMetadata(SILFunction const &F) const {

lib/SIL/IR/TypeLowering.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,12 +2290,14 @@ namespace {
22902290

22912291
TypeLowering *handleTrivial(CanType type,
22922292
RecursiveProperties properties) {
2293+
properties = mergeHasPack(HasPack_t(type->hasAnyPack()), properties);
22932294
auto silType = SILType::getPrimitiveObjectType(type);
22942295
return new (TC) TrivialTypeLowering(silType, properties, Expansion);
22952296
}
22962297

22972298
TypeLowering *handleReference(CanType type,
22982299
RecursiveProperties properties) {
2300+
properties = mergeHasPack(HasPack_t(type->hasAnyPack()), properties);
22992301
auto silType = SILType::getPrimitiveObjectType(type);
23002302
if (type.isForeignReferenceType() &&
23012303
type->getReferenceCounting() == ReferenceCounting::None)
@@ -2307,13 +2309,15 @@ namespace {
23072309

23082310
TypeLowering *handleMoveOnlyReference(CanType type,
23092311
RecursiveProperties properties) {
2312+
properties = mergeHasPack(HasPack_t(type->hasAnyPack()), properties);
23102313
auto silType = SILType::getPrimitiveObjectType(type);
23112314
return new (TC)
23122315
MoveOnlyReferenceTypeLowering(silType, properties, Expansion);
23132316
}
23142317

23152318
TypeLowering *handleMoveOnlyAddressOnly(CanType type,
23162319
RecursiveProperties properties) {
2320+
properties = mergeHasPack(HasPack_t(type->hasAnyPack()), properties);
23172321
if (!TC.Context.SILOpts.EnableSILOpaqueValues &&
23182322
!TypeLoweringForceOpaqueValueLowering) {
23192323
auto silType = SILType::getPrimitiveAddressType(type);
@@ -2326,13 +2330,15 @@ namespace {
23262330
}
23272331

23282332
TypeLowering *handleReference(CanType type) {
2333+
auto properties = RecursiveProperties::forReference();
2334+
properties = mergeHasPack(HasPack_t(type->hasAnyPack()), properties);
23292335
auto silType = SILType::getPrimitiveObjectType(type);
2330-
return new (TC) ReferenceTypeLowering(
2331-
silType, RecursiveProperties::forReference(), Expansion);
2336+
return new (TC) ReferenceTypeLowering(silType, properties, Expansion);
23322337
}
23332338

23342339
TypeLowering *handleAddressOnly(CanType type,
23352340
RecursiveProperties properties) {
2341+
properties = mergeHasPack(HasPack_t(type->hasAnyPack()), properties);
23362342
if (!TC.Context.SILOpts.EnableSILOpaqueValues &&
23372343
!TypeLoweringForceOpaqueValueLowering) {
23382344
auto silType = SILType::getPrimitiveAddressType(type);
@@ -2347,6 +2353,7 @@ namespace {
23472353

23482354
TypeLowering *handleInfinite(CanType type,
23492355
RecursiveProperties properties) {
2356+
properties = mergeHasPack(HasPack_t(type->hasAnyPack()), properties);
23502357
// Infinite types cannot actually be instantiated, so treat them as
23512358
// opaque for code generation purposes.
23522359
properties.setAddressOnly();
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend \
5+
// RUN: %t/Library.swift \
6+
// RUN: -emit-module \
7+
// RUN: -target %target-swift-5.9-abi-triple \
8+
// RUN: -enable-library-evolution \
9+
// RUN: -module-name Library \
10+
// RUN: -emit-module-path %t/Library.swiftmodule
11+
12+
// RUN: %target-build-swift \
13+
// RUN: %t/Downstream.swift \
14+
// RUN: -c \
15+
// RUN: -target %target-swift-5.9-abi-triple \
16+
// RUN: -parse-as-library \
17+
// RUN: -module-name main \
18+
// RUN: -lLibrary \
19+
// RUN: -I %t \
20+
// RUN: -o %t/Executable.o
21+
22+
//--- Library.swift
23+
24+
public struct Paq<each T> {
25+
public var uette: (repeat each T)
26+
}
27+
28+
public class Loq<each T> {
29+
}
30+
31+
// Enums don't take packs yet.
32+
33+
// public enum Orq<each T> {
34+
// case uette(repeat each T)
35+
// case uettette(repeat each T, repeat each T)
36+
// }
37+
38+
//--- Downstream.swift
39+
40+
import Library
41+
42+
struct Sleeve<T> {
43+
var impl: Paq<T>
44+
}
45+
46+
func bin<Moribund>(_ s: consuming Sleeve<Moribund>) {
47+
}
48+
49+
struct Laq<T> {
50+
var impl: Loq<T>
51+
var t: T
52+
}
53+
54+
@_silgen_name("bun")
55+
func bun<T>(_ l: consuming Laq<T>) {
56+
}
57+
58+
// Enums don't take packs yet.
59+
60+
// struct Etiq<T> {
61+
// var impl: Orq<T>
62+
// }
63+
//
64+
// func bon<Moribund>(_ i: consuming Etiq<Moribund>) {
65+
// }

0 commit comments

Comments
 (0)