Skip to content

Commit f47cd8a

Browse files
committed
Fix leak in BasicCalleeAnalysis.
Each time we delete the pass manager, we delete the analyses it holds. In this analysis we were holding onto memory that wasn't getting released when the analysis was deleted. Fixes rdar://problem/26245872.
1 parent 9b9513b commit f47cd8a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

include/swift/SILOptimizer/Analysis/BasicCalleeAnalysis.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class CalleeCache {
118118

119119
class BasicCalleeAnalysis : public SILAnalysis {
120120
SILModule &M;
121-
CalleeCache *Cache;
121+
std::unique_ptr<CalleeCache> Cache;
122122

123123
public:
124124
BasicCalleeAnalysis(SILModule *M)
@@ -129,17 +129,15 @@ class BasicCalleeAnalysis : public SILAnalysis {
129129
}
130130

131131
virtual void invalidate(SILAnalysis::InvalidationKind K) {
132-
if (K & InvalidationKind::Functions) {
133-
delete Cache;
134-
Cache = nullptr;
135-
}
132+
if (K & InvalidationKind::Functions)
133+
Cache.reset();
136134
}
137135

138136
virtual void invalidate(SILFunction *F, InvalidationKind K) { invalidate(K); }
139137

140138
CalleeList getCalleeList(FullApplySite FAS) {
141139
if (!Cache)
142-
Cache = new CalleeCache(M);
140+
Cache = llvm::make_unique<CalleeCache>(M);
143141

144142
return Cache->getCalleeList(FAS);
145143
}

0 commit comments

Comments
 (0)