summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/MustExecute.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2019-10-31 12:06:21 -0500
committerJohannes Doerfert <johannes@jdoerfert.de>2019-10-31 12:16:54 -0500
commitcb19ea45a71b74c72ad5e8ceaa42a0b6c8168576 (patch)
tree7c10faedc3d9f6a18d04a1cd0b06906075ee9b55 /llvm/lib/Analysis/MustExecute.cpp
parent764c8420e4b8fc11a9fa94d00f4ee617aa754cb2 (diff)
downloadbcm5719-llvm-cb19ea45a71b74c72ad5e8ceaa42a0b6c8168576.tar.gz
bcm5719-llvm-cb19ea45a71b74c72ad5e8ceaa42a0b6c8168576.zip
[FIX] Make LSan happy by *not* leaking memory
I left a memory leak in a printer pass which made LSan sad so I remove the memory leak now to make LSan happy. Reported and tested by vlad.tsyrklevich.
Diffstat (limited to 'llvm/lib/Analysis/MustExecute.cpp')
-rw-r--r--llvm/lib/Analysis/MustExecute.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp
index 585c984a00f..4c4cdcbbec2 100644
--- a/llvm/lib/Analysis/MustExecute.cpp
+++ b/llvm/lib/Analysis/MustExecute.cpp
@@ -355,15 +355,21 @@ ModulePass *llvm::createMustBeExecutedContextPrinter() {
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 = [](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 = [](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 @@ bool MustBeExecutedContextPrinter::runOnModule(Module &M) {
}
}
+ DeleteContainerPointers(PDTs);
+ DeleteContainerPointers(LIs);
+ DeleteContainerPointers(DTs);
return false;
}
OpenPOWER on IntegriCloud