Skip to content

Commit 2fb823e

Browse files
committed
Merge pull request #2573 from trentxintong/MemLeak
Fix a memory leak in DSE
2 parents e8a8f7d + 46436d5 commit 2fb823e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/SILOptimizer/Transforms/DeadStoreElimination.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ enum class ProcessKind {
323323
TypeExpansionAnalysis *TE;
324324

325325
/// The allocator we are using.
326-
llvm::BumpPtrAllocator &BPA;
326+
llvm::SpecificBumpPtrAllocator<BlockState> &BPA;
327327

328328
/// The epilogue release matcher we are using.
329329
ConsumedArgToEpilogueReleaseMatcher& ERM;
@@ -429,7 +429,7 @@ enum class ProcessKind {
429429
/// Constructor.
430430
DSEContext(SILFunction *F, SILModule *M, SILPassManager *PM,
431431
AliasAnalysis *AA, TypeExpansionAnalysis *TE,
432-
llvm::BumpPtrAllocator &BPA,
432+
llvm::SpecificBumpPtrAllocator<BlockState> &BPA,
433433
ConsumedArgToEpilogueReleaseMatcher &ERM)
434434
: Mod(M), F(F), PM(PM), AA(AA), TE(TE), BPA(BPA), ERM(ERM) {}
435435

@@ -1154,7 +1154,7 @@ bool DSEContext::run() {
11541154
// Initialize the BBToLocState mapping.
11551155
unsigned LocationNum = this->getLocationVault().size();
11561156
for (auto &B : *F) {
1157-
auto *State = new (BPA) BlockState(&B, LocationNum, Optimistic);
1157+
auto *State = new (BPA.Allocate()) BlockState(&B, LocationNum, Optimistic);
11581158
BBToLocState[&B] = State;
11591159
State->initStoreSetAtEndOfBlock(*this);
11601160
}
@@ -1234,7 +1234,7 @@ class DeadStoreElimination : public SILFunctionTransform {
12341234
auto *RCFI = PM->getAnalysis<RCIdentityAnalysis>()->get(F);
12351235

12361236
// The allocator we are using.
1237-
llvm::BumpPtrAllocator BPA;
1237+
llvm::SpecificBumpPtrAllocator<BlockState> BPA;
12381238

12391239
// The epilogue release matcher we are using.
12401240
ConsumedArgToEpilogueReleaseMatcher ERM(RCFI, F);

0 commit comments

Comments
 (0)