Skip to content

Commit 580f2e4

Browse files
Merge pull request #84635 from nate-chandler/rdar161606892
[VariadicGenerics] Fix memeffect of metadata accessor.
2 parents a9e43a4 + 0c685d0 commit 580f2e4

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

include/swift/IRGen/GenericRequirement.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ class GenericRequirement {
109109
bool isAnyWitnessTable() const {
110110
return kind == Kind::WitnessTable || kind == Kind::WitnessTablePack;
111111
}
112+
113+
bool isAnyPack() const {
114+
return kind == Kind::MetadataPack || kind == Kind::WitnessTablePack;
115+
}
116+
112117
bool isValue() const {
113118
return kind == Kind::Value;
114119
}

lib/IRGen/GenMeta.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,8 +2995,9 @@ void irgen::emitLazyMetadataAccessor(IRGenModule &IGM,
29952995
if (IGM.getOptions().optimizeForSize())
29962996
accessor->addFnAttr(llvm::Attribute::NoInline);
29972997

2998-
bool isReadNone = (genericArgs.Types.size() <=
2999-
NumDirectGenericTypeMetadataAccessFunctionArgs);
2998+
bool isReadNone =
2999+
!genericArgs.hasPacks && (genericArgs.Types.size() <=
3000+
NumDirectGenericTypeMetadataAccessFunctionArgs);
30003001

30013002
emitCacheAccessFunction(
30023003
IGM, accessor, /*cache*/ nullptr, /*cache type*/ nullptr,

lib/IRGen/GenericArguments.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,17 @@ struct GenericArguments {
5050
/// The values to use to initialize the arguments structure.
5151
SmallVector<llvm::Value *, 8> Values;
5252
SmallVector<llvm::Type *, 8> Types;
53+
bool hasPacks = false;
5354

54-
void collectTypes(IRGenModule &IGM, NominalTypeDecl *nominal) {
55+
void collectTypes(IRGenModule &IGM, NominalTypeDecl *nominal) {
5556
GenericTypeRequirements requirements(IGM, nominal);
5657
collectTypes(IGM, requirements);
5758
}
5859

5960
void collectTypes(IRGenModule &IGM,
6061
const GenericTypeRequirements &requirements) {
6162
for (auto &requirement : requirements.getRequirements()) {
63+
hasPacks = hasPacks || requirement.isAnyPack();
6264
Types.push_back(requirement.getType(IGM));
6365
}
6466
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-frontend %s -target %target-swift-5.9-abi-triple -emit-irgen | %IRGenFileCheck %s
2+
3+
// CHECK: Attrs: noinline nounwind{{$}}
4+
// CHECK-NEXT: define {{.*}}@"$s13rdar1616068921PVMa"
5+
6+
public struct P<each T> {
7+
public var teas: (repeat each T)
8+
}

0 commit comments

Comments
 (0)