[llvm] 89e2fe3 - MustBeExecutedContextExplorer::InstructionIteratorMap: use unique_ptr for values in this map to simplify memory management
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 12:37:14 PDT 2020
Author: David Blaikie
Date: 2020-04-28T12:26:53-07:00
New Revision: 89e2fe32100410e6e6cd3c46e5a3d87ea94b141c
URL: https://github.com/llvm/llvm-project/commit/89e2fe32100410e6e6cd3c46e5a3d87ea94b141c
DIFF: https://github.com/llvm/llvm-project/commit/89e2fe32100410e6e6cd3c46e5a3d87ea94b141c.diff
LOG: MustBeExecutedContextExplorer::InstructionIteratorMap: use unique_ptr for values in this map to simplify memory management
Added:
Modified:
llvm/include/llvm/Analysis/MustExecute.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/MustExecute.h b/llvm/include/llvm/Analysis/MustExecute.h
index 16da0c0a4650..181fdacad233 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 @@ struct MustBeExecutedContextExplorer {
DenseMap<const Function*, Optional<bool>> IrreducibleControlMap;
/// Map from instructions to associated must be executed iterators.
- DenseMap<const Instruction *, MustBeExecutedIterator *>
+ DenseMap<const Instruction *, std::unique_ptr<MustBeExecutedIterator>>
InstructionIteratorMap;
/// A unique end iterator.
More information about the llvm-commits
mailing list