Skip to content

Commit cc90879

Browse files
committed
Merge pull request #2710 from trentxintong/SFSO
Fix a memory leak in RRCM.
2 parents ade9af8 + 5b6437f commit cc90879

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/SILOptimizer/Transforms/RetainReleaseCodeMotion.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class CodeMotionContext {
189189
bool MultiIteration;
190190

191191
/// The allocator we are currently using.
192-
llvm::BumpPtrAllocator &BPA;
192+
llvm::SpecificBumpPtrAllocator<BlockState> &BPA;
193193

194194
/// Current function we are analyzing.
195195
SILFunction *F;
@@ -239,7 +239,7 @@ class CodeMotionContext {
239239

240240
public:
241241
/// Constructor.
242-
CodeMotionContext(llvm::BumpPtrAllocator &BPA, SILFunction *F,
242+
CodeMotionContext(llvm::SpecificBumpPtrAllocator<BlockState> &BPA, SILFunction *F,
243243
PostOrderFunctionInfo *PO, AliasAnalysis *AA,
244244
RCIdentityFunctionInfo *RCFI)
245245
: MultiIteration(true), BPA(BPA), F(F), PO(PO), AA(AA), RCFI(RCFI) {}
@@ -358,9 +358,9 @@ class RetainCodeMotionContext : public CodeMotionContext {
358358

359359
public:
360360
/// Constructor.
361-
RetainCodeMotionContext(llvm::BumpPtrAllocator &BPA, SILFunction *F,
362-
PostOrderFunctionInfo *PO, AliasAnalysis *AA,
363-
RCIdentityFunctionInfo *RCFI)
361+
RetainCodeMotionContext(llvm::SpecificBumpPtrAllocator<BlockState> &BPA,
362+
SILFunction *F, PostOrderFunctionInfo *PO,
363+
AliasAnalysis *AA, RCIdentityFunctionInfo *RCFI)
364364
: CodeMotionContext(BPA, F, PO, AA, RCFI) {
365365
MultiIteration = requireIteration();
366366
}
@@ -430,7 +430,7 @@ void RetainCodeMotionContext::initializeCodeMotionDataFlow() {
430430

431431
// Initialize all the data flow bit vector for all basic blocks.
432432
for (auto &BB : *F) {
433-
BlockStates[&BB] = new (BPA) RetainBlockState(&BB == &*F->begin(),
433+
BlockStates[&BB] = new (BPA.Allocate()) RetainBlockState(&BB == &*F->begin(),
434434
RCRootVault.size(), MultiIteration);
435435
}
436436
}
@@ -684,9 +684,9 @@ class ReleaseCodeMotionContext : public CodeMotionContext {
684684

685685
public:
686686
/// Constructor.
687-
ReleaseCodeMotionContext(llvm::BumpPtrAllocator &BPA, SILFunction *F,
688-
PostOrderFunctionInfo *PO, AliasAnalysis *AA,
689-
RCIdentityFunctionInfo *RCFI,
687+
ReleaseCodeMotionContext(llvm::SpecificBumpPtrAllocator<BlockState> &BPA,
688+
SILFunction *F, PostOrderFunctionInfo *PO,
689+
AliasAnalysis *AA, RCIdentityFunctionInfo *RCFI,
690690
bool FreezeEpilogueReleases,
691691
ConsumedArgToEpilogueReleaseMatcher &ERM)
692692
: CodeMotionContext(BPA, F, PO, AA, RCFI),
@@ -769,8 +769,8 @@ void ReleaseCodeMotionContext::initializeCodeMotionDataFlow() {
769769
if (Throw != F->end())
770770
Exits.insert(&*Throw);
771771
for (auto &BB : *F) {
772-
BlockStates[&BB] = new (BPA) ReleaseBlockState(Exits.count(&BB),
773-
RCRootVault.size(), MultiIteration);
772+
BlockStates[&BB] = new (BPA.Allocate()) ReleaseBlockState(Exits.count(&BB),
773+
RCRootVault.size(), MultiIteration);
774774
}
775775
}
776776

@@ -1047,7 +1047,7 @@ class RRCodeMotion : public SILFunctionTransform {
10471047
// to create critical edges.
10481048
bool EdgeChanged = splitAllCriticalEdges(*F, false, nullptr, nullptr);
10491049

1050-
llvm::BumpPtrAllocator BPA;
1050+
llvm::SpecificBumpPtrAllocator<BlockState> BPA;
10511051
auto *PO = PM->getAnalysis<PostOrderAnalysis>()->get(F);
10521052
auto *AA = PM->getAnalysis<AliasAnalysis>();
10531053
auto *RCFI = PM->getAnalysis<RCIdentityAnalysis>()->get(F);

0 commit comments

Comments
 (0)