From 89e2fe32100410e6e6cd3c46e5a3d87ea94b141c Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 28 Apr 2020 12:17:36 -0700 Subject: [PATCH] MustBeExecutedContextExplorer::InstructionIteratorMap: use unique_ptr for values in this map to simplify memory management --- llvm/include/llvm/Analysis/MustExecute.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/llvm/include/llvm/Analysis/MustExecute.h b/llvm/include/llvm/Analysis/MustExecute.h index 16da0c0..181fdac 100644 --- a/llvm/include/llvm/Analysis/MustExecute.h +++ b/llvm/include/llvm/Analysis/MustExecute.h @@ -416,11 +416,6 @@ struct MustBeExecutedContextExplorer { ExploreCFGBackward(ExploreCFGBackward), LIGetter(LIGetter), DTGetter(DTGetter), PDTGetter(PDTGetter), EndIterator(*this, nullptr) {} - /// Clean up the dynamically allocated iterators. - ~MustBeExecutedContextExplorer() { - DeleteContainerSeconds(InstructionIteratorMap); - } - /// Iterator-based interface. \see MustBeExecutedIterator. ///{ using iterator = MustBeExecutedIterator; @@ -428,15 +423,15 @@ struct MustBeExecutedContextExplorer { /// Return an iterator to explore the context around \p PP. iterator &begin(const Instruction *PP) { - auto *&It = InstructionIteratorMap[PP]; + auto &It = InstructionIteratorMap[PP]; if (!It) - It = new iterator(*this, PP); + It.reset(new iterator(*this, PP)); return *It; } /// Return an iterator to explore the cached context around \p PP. const_iterator &begin(const Instruction *PP) const { - return *InstructionIteratorMap.lookup(PP); + return *InstructionIteratorMap.find(PP)->second; } /// Return an universal end iterator. @@ -544,7 +539,7 @@ private: DenseMap> IrreducibleControlMap; /// Map from instructions to associated must be executed iterators. - DenseMap + DenseMap> InstructionIteratorMap; /// A unique end iterator. -- 2.7.4