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 LIGetter = [this](const Function &F) { + // function passes from a module pass. + SmallVector PDTs; + SmallVector DTs; + SmallVector LIs; + + GetterTy LIGetter = [&](const Function &F) { DominatorTree *DT = new DominatorTree(const_cast(F)); LoopInfo *LI = new LoopInfo(*DT); + DTs.push_back(DT); + LIs.push_back(LI); return LI; }; - GetterTy PDTGetter = [this](const Function &F) { + GetterTy PDTGetter = [&](const Function &F) { PostDominatorTree *PDT = new PostDominatorTree(const_cast(F)); + PDTs.push_back(PDT); return PDT; }; MustBeExecutedContextExplorer Explorer(true, LIGetter, PDTGetter); @@ -376,6 +382,9 @@ } } + DeleteContainerPointers(PDTs); + DeleteContainerPointers(LIs); + DeleteContainerPointers(DTs); return false; }