Skip to content

Commit 9486514

Browse files
committed
IRGen: Fix type layout cache leak
rdar://59687311
1 parent af97fd1 commit 9486514

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/IRGen/TypeLayout.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,3 +2144,21 @@ TypeLayoutCache::getOrCreateResilientEntry(SILType ty) {
21442144
resilientEntries.InsertNode(newEntry, insertPos);
21452145
return newEntry;
21462146
}
2147+
2148+
TypeLayoutCache::~TypeLayoutCache() {
2149+
for (auto &entry : scalarEntries) {
2150+
entry.~ScalarTypeLayoutEntry();
2151+
}
2152+
for (auto &entry : archetypeEntries) {
2153+
entry.~ArchetypeLayoutEntry();
2154+
}
2155+
for (auto &entry : alignedGroupEntries) {
2156+
entry.~AlignedGroupEntry();
2157+
}
2158+
for (auto &entry : enumEntries) {
2159+
entry.~EnumTypeLayoutEntry();
2160+
}
2161+
for (auto &entry : resilientEntries) {
2162+
entry.~ResilientTypeLayoutEntry();
2163+
}
2164+
}

lib/IRGen/TypeLayout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ class TypeLayoutCache {
432432
llvm::FoldingSet<ResilientTypeLayoutEntry> resilientEntries;
433433

434434
TypeLayoutEntry emptyEntry;
435-
436435
public:
436+
~TypeLayoutCache();
437437
ScalarTypeLayoutEntry *getOrCreateScalarEntry(const TypeInfo &ti,
438438
SILType representative);
439439

0 commit comments

Comments
 (0)