[PATCH] D69674: [FIX] Make LSan happy by *not* leaking memory
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 31 10:10:43 PDT 2019
jdoerfert created this revision.
Herald added subscribers: llvm-commits, bollu, hiraditya.
Herald added a project: LLVM.
https://reviews.llvm.org/D69674
Files:
llvm/lib/Analysis/MustExecute.cpp
Index: llvm/lib/Analysis/MustExecute.cpp
===================================================================
--- llvm/lib/Analysis/MustExecute.cpp
+++ llvm/lib/Analysis/MustExecute.cpp
@@ -355,15 +355,21 @@
bool MustBeExecutedContextPrinter::runOnModule(Module &M) {
// We provide non-PM analysis here because the old PM doesn't like to query
- // function passes from a module pass. Given that this is a printer, we don't
- // care much about memory leaks.
- GetterTy<LoopInfo> LIGetter = [this](const Function &F) {
+ // function passes from a module pass.
+ SmallVector<PostDominatorTree *, 8> PDTs;
+ SmallVector<DominatorTree *, 8> DTs;
+ SmallVector<LoopInfo *, 8> LIs;
+
+ GetterTy<LoopInfo> LIGetter = [&](const Function &F) {
DominatorTree *DT = new DominatorTree(const_cast<Function &>(F));
LoopInfo *LI = new LoopInfo(*DT);
+ DTs.push_back(DT);
+ LIs.push_back(LI);
return LI;
};
- GetterTy<PostDominatorTree> PDTGetter = [this](const Function &F) {
+ GetterTy<PostDominatorTree> PDTGetter = [&](const Function &F) {
PostDominatorTree *PDT = new PostDominatorTree(const_cast<Function &>(F));
+ PDTs.push_back(PDT);
return PDT;
};
MustBeExecutedContextExplorer Explorer(true, LIGetter, PDTGetter);
@@ -376,6 +382,9 @@
}
}
+ DeleteContainerPointers(PDTs);
+ DeleteContainerPointers(LIs);
+ DeleteContainerPointers(DTs);
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69674.227304.patch
Type: text/x-patch
Size: 1423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191031/df2a146f/attachment.bin>
More information about the llvm-commits
mailing list