[llvm] 95e5707 - OpenMPOpt::RuntimeFunctionInfo::UsesMap: Use unique_ptr for values to simplify memory management
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 12:37:16 PDT 2020
Author: David Blaikie
Date: 2020-04-28T12:26:53-07:00
New Revision: 95e570725a1423fcb7d6c1aa7eeed64c4a806436
URL: https://github.com/llvm/llvm-project/commit/95e570725a1423fcb7d6c1aa7eeed64c4a806436
DIFF: https://github.com/llvm/llvm-project/commit/95e570725a1423fcb7d6c1aa7eeed64c4a806436.diff
LOG: OpenMPOpt::RuntimeFunctionInfo::UsesMap: Use unique_ptr for values to simplify memory management
Added:
Modified:
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 0907aa01eddc..dbd06a6c299b 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -62,7 +62,6 @@ struct OpenMPOpt {
/// Generic information that describes a runtime function
struct RuntimeFunctionInfo {
- ~RuntimeFunctionInfo() { DeleteContainerSeconds(UsesMap); }
/// The kind, as described by the RuntimeFunction enum.
RuntimeFunction Kind;
@@ -87,16 +86,19 @@ struct OpenMPOpt {
/// Return the vector of uses in function \p F.
UseVector &getOrCreateUseVector(Function *F) {
- UseVector *&UV = UsesMap[F];
+ std::unique_ptr<UseVector> &UV = UsesMap[F];
if (!UV)
- UV = new UseVector();
+ UV = std::make_unique<UseVector>();
return *UV;
}
/// Return the vector of uses in function \p F or `nullptr` if there are
/// none.
const UseVector *getUseVector(Function &F) const {
- return UsesMap.lookup(&F);
+ auto I = UsesMap.find(&F);
+ if (I != UsesMap.end())
+ return I->second.get();
+ return nullptr;
}
/// Return how many functions contain uses of this runtime function.
@@ -134,7 +136,7 @@ struct OpenMPOpt {
private:
/// Map from functions to all uses of this runtime function contained in
/// them.
- DenseMap<Function *, UseVector *> UsesMap;
+ DenseMap<Function *, std::unique_ptr<UseVector>> UsesMap;
};
/// Run all OpenMP optimizations on the underlying SCC/ModuleSlice.
More information about the llvm-commits
mailing list