From 1b56980845baaa04f98da7d0a85bbde26be3ed4b Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 28 Apr 2020 11:30:22 -0700 Subject: [PATCH] MustBeExecutedContextPrinter::runOnModule: Use unique_ptr to simplify/clarify ownership --- llvm/lib/Analysis/MustExecute.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp index bea973e8a94e3..6e3ff67bdddb9 100644 --- a/llvm/lib/Analysis/MustExecute.cpp +++ b/llvm/lib/Analysis/MustExecute.cpp @@ -357,26 +357,23 @@ 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. - SmallVector PDTs; - SmallVector DTs; - SmallVector LIs; + SmallVector, 8> PDTs; + SmallVector, 8> DTs; + SmallVector, 8> 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; + DTs.push_back(std::make_unique(const_cast(F))); + LIs.push_back(std::make_unique(*DTs.back())); + return LIs.back().get(); }; GetterTy DTGetter = [&](const Function &F) { - DominatorTree *DT = new DominatorTree(const_cast(F)); - DTs.push_back(DT); - return DT; + DTs.push_back(std::make_unique(const_cast(F))); + return DTs.back().get(); }; GetterTy PDTGetter = [&](const Function &F) { - PostDominatorTree *PDT = new PostDominatorTree(const_cast(F)); - PDTs.push_back(PDT); - return PDT; + PDTs.push_back( + std::make_unique(const_cast(F))); + return PDTs.back().get(); }; MustBeExecutedContextExplorer Explorer( /* ExploreInterBlock */ true, @@ -392,9 +389,6 @@ bool MustBeExecutedContextPrinter::runOnModule(Module &M) { } } - DeleteContainerPointers(PDTs); - DeleteContainerPointers(LIs); - DeleteContainerPointers(DTs); return false; }