Skip to content

Commit 50821f6

Browse files
committed
Use LifetimeDependenceInfo while computing FunctionType's id
1 parent ab71c1e commit 50821f6

File tree

4 files changed

+37
-34
lines changed

4 files changed

+37
-34
lines changed

include/swift/AST/ExtInfo.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,16 @@ class LifetimeDependenceInfo {
174174
borrowLifetimeParamIndices(borrowLifetimeParamIndices),
175175
mutateLifetimeParamIndices(mutateLifetimeParamIndices) {}
176176

177-
operator bool() const { return empty(); }
177+
operator bool() const { return !empty(); }
178178

179179
bool empty() const {
180180
return inheritLifetimeParamIndices == nullptr &&
181181
borrowLifetimeParamIndices == nullptr &&
182182
mutateLifetimeParamIndices == nullptr;
183183
}
184184
std::string getString() const;
185+
186+
void Profile(llvm::FoldingSetNodeID &ID) const;
185187
};
186188

187189
// MARK: - UnexpectedClangTypeError
@@ -690,20 +692,21 @@ class ASTExtInfoBuilder {
690692
lifetimeDependenceInfo);
691693
}
692694

695+
void Profile(llvm::FoldingSetNodeID &ID) const {
696+
ID.AddInteger(bits);
697+
ID.AddPointer(clangTypeInfo.getType());
698+
ID.AddPointer(globalActor.getPointer());
699+
ID.AddPointer(thrownError.getPointer());
700+
lifetimeDependenceInfo.Profile(ID);
701+
}
702+
693703
bool isEqualTo(ASTExtInfoBuilder other, bool useClangTypes) const {
694704
return bits == other.bits &&
695705
(useClangTypes ? (clangTypeInfo == other.clangTypeInfo) : true) &&
696706
globalActor.getPointer() == other.globalActor.getPointer() &&
697707
thrownError.getPointer() == other.thrownError.getPointer() &&
698708
lifetimeDependenceInfo == other.lifetimeDependenceInfo;
699709
}
700-
701-
constexpr std::tuple<unsigned, const void *, const void *, const void *>
702-
getFuncAttrKey() const {
703-
return std::make_tuple(
704-
bits, clangTypeInfo.getType(), globalActor.getPointer(),
705-
thrownError.getPointer());
706-
}
707710
}; // end ASTExtInfoBuilder
708711

709712
// MARK: - ASTExtInfo
@@ -850,14 +853,11 @@ class ASTExtInfo {
850853
return builder.withLifetimeDependenceInfo(lifetimeDependenceInfo).build();
851854
}
852855

856+
void Profile(llvm::FoldingSetNodeID &ID) const { builder.Profile(ID); }
857+
853858
bool isEqualTo(ASTExtInfo other, bool useClangTypes) const {
854859
return builder.isEqualTo(other.builder, useClangTypes);
855860
}
856-
857-
constexpr std::tuple<unsigned, const void *, const void *, const void *>
858-
getFuncAttrKey() const {
859-
return builder.getFuncAttrKey();
860-
}
861861
}; // end ASTExtInfo
862862

863863
// MARK: - SILFunctionLanguage
@@ -1122,14 +1122,16 @@ class SILExtInfoBuilder {
11221122
return SILExtInfoBuilder(bits, clangTypeInfo, lifetimeDependenceInfo);
11231123
}
11241124

1125+
void Profile(llvm::FoldingSetNodeID &ID) const {
1126+
ID.AddInteger(bits);
1127+
ID.AddPointer(clangTypeInfo.getType());
1128+
lifetimeDependenceInfo.Profile(ID);
1129+
}
1130+
11251131
bool isEqualTo(SILExtInfoBuilder other, bool useClangTypes) const {
11261132
return bits == other.bits &&
11271133
(useClangTypes ? (clangTypeInfo == other.clangTypeInfo) : true);
11281134
}
1129-
1130-
constexpr std::pair<unsigned, const void *> getFuncAttrKey() const {
1131-
return std::make_pair(bits, clangTypeInfo.getType());
1132-
}
11331135
}; // end SILExtInfoBuilder
11341136

11351137
// MARK: - SILExtInfo
@@ -1243,14 +1245,12 @@ class SILExtInfo {
12431245
return builder.withUnimplementable(isUnimplementable).build();
12441246
}
12451247

1248+
void Profile(llvm::FoldingSetNodeID &ID) const { builder.Profile(ID); }
1249+
12461250
bool isEqualTo(SILExtInfo other, bool useClangTypes) const {
12471251
return builder.isEqualTo(other.builder, useClangTypes);
12481252
}
12491253

1250-
constexpr std::pair<unsigned, const void *> getFuncAttrKey() const {
1251-
return builder.getFuncAttrKey();
1252-
}
1253-
12541254
llvm::Optional<UnexpectedClangTypeError> checkClangType() const;
12551255
};
12561256

include/swift/AST/LifetimeDependence.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class LifetimeDependenceSpecifier {
9393
assert(specifierKind == SpecifierKind::Ordered);
9494
return value.Ordered.index;
9595
}
96+
9697
std::string getParamString() const {
9798
switch (specifierKind) {
9899
case SpecifierKind::Named:

lib/AST/ASTContext.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4177,11 +4177,7 @@ void FunctionType::Profile(llvm::FoldingSetNodeID &ID,
41774177
profileParams(ID, params);
41784178
ID.AddPointer(result.getPointer());
41794179
if (info.has_value()) {
4180-
auto infoKey = info.value().getFuncAttrKey();
4181-
ID.AddInteger(std::get<0>(infoKey));
4182-
ID.AddPointer(std::get<1>(infoKey));
4183-
ID.AddPointer(std::get<2>(infoKey));
4184-
ID.AddPointer(std::get<3>(infoKey));
4180+
info->Profile(ID);
41854181
}
41864182
}
41874183

@@ -4306,11 +4302,7 @@ void GenericFunctionType::Profile(llvm::FoldingSetNodeID &ID,
43064302
profileParams(ID, params);
43074303
ID.AddPointer(result.getPointer());
43084304
if (info.has_value()) {
4309-
auto infoKey = info.value().getFuncAttrKey();
4310-
ID.AddInteger(std::get<0>(infoKey));
4311-
ID.AddPointer(std::get<1>(infoKey));
4312-
ID.AddPointer(std::get<2>(infoKey));
4313-
ID.AddPointer(std::get<3>(infoKey));
4305+
info->Profile(ID);
43144306
}
43154307
}
43164308

@@ -4446,9 +4438,7 @@ void SILFunctionType::Profile(
44464438
ProtocolConformanceRef conformance, SubstitutionMap patternSubs,
44474439
SubstitutionMap invocationSubs) {
44484440
id.AddPointer(genericParams.getPointer());
4449-
auto infoKey = info.getFuncAttrKey();
4450-
id.AddInteger(infoKey.first);
4451-
id.AddPointer(infoKey.second);
4441+
info.Profile(id);
44524442
id.AddInteger(unsigned(coroutineKind));
44534443
id.AddInteger(unsigned(calleeConvention));
44544444
id.AddInteger(params.size());

lib/AST/ExtInfo.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ std::string LifetimeDependenceInfo::getString() const {
8989
return lifetimeDependenceString;
9090
}
9191

92+
void LifetimeDependenceInfo::Profile(llvm::FoldingSetNodeID &ID) const {
93+
if (inheritLifetimeParamIndices) {
94+
inheritLifetimeParamIndices->Profile(ID);
95+
}
96+
if (borrowLifetimeParamIndices) {
97+
borrowLifetimeParamIndices->Profile(ID);
98+
}
99+
if (mutateLifetimeParamIndices) {
100+
mutateLifetimeParamIndices->Profile(ID);
101+
}
102+
}
103+
92104
// MARK: - UnexpectedClangTypeError
93105

94106
llvm::Optional<UnexpectedClangTypeError>

0 commit comments

Comments
 (0)