diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-16 23:42:04 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-16 23:42:04 +0000 |
commit | f22912780dd565f5cc1f173a90f1460f2a0d28b1 (patch) | |
tree | c8b49bb68452295ee4df18777616288dcc229c22 | |
parent | a770a7ec5defa7c17674c51bb68edb0f29152d0b (diff) | |
download | bcm5719-llvm-f22912780dd565f5cc1f173a90f1460f2a0d28b1.tar.gz bcm5719-llvm-f22912780dd565f5cc1f173a90f1460f2a0d28b1.zip |
IR: Add a configuration point for MDNodeInfo::isEqual, NFC
This commit has no functionality change, but it adds a configuration
point for MDNodeInfo::isEqual to allow custom uniquing of subclasses of
MDNode, minimizing the diff of a follow-up.
llvm-svn: 266542
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index bd34ac2c78d..bd61648264d 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -211,6 +211,17 @@ public: template <class NodeTy> struct MDNodeKeyImpl; template <class NodeTy> struct MDNodeInfo; +/// Configuration point for MDNodeInfo::isEqual(). +template <class NodeTy> struct MDNodeSubsetEqualImpl { + typedef MDNodeKeyImpl<NodeTy> KeyTy; + static bool isSubsetEqual(const KeyTy &LHS, const NodeTy *RHS) { + return false; + } + static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS) { + return false; + } +}; + /// \brief DenseMapInfo for MDTuple. /// /// Note that we don't need the is-function-local bit, since that's implicit in @@ -845,6 +856,7 @@ template <> struct MDNodeKeyImpl<DIMacroFile> { /// \brief DenseMapInfo for MDNode subclasses. template <class NodeTy> struct MDNodeInfo { typedef MDNodeKeyImpl<NodeTy> KeyTy; + typedef MDNodeSubsetEqualImpl<NodeTy> SubsetEqualTy; static inline NodeTy *getEmptyKey() { return DenseMapInfo<NodeTy *>::getEmptyKey(); } @@ -858,10 +870,14 @@ template <class NodeTy> struct MDNodeInfo { static bool isEqual(const KeyTy &LHS, const NodeTy *RHS) { if (RHS == getEmptyKey() || RHS == getTombstoneKey()) return false; - return LHS.isKeyOf(RHS); + return SubsetEqualTy::isSubsetEqual(LHS, RHS) || LHS.isKeyOf(RHS); } static bool isEqual(const NodeTy *LHS, const NodeTy *RHS) { - return LHS == RHS; + if (LHS == RHS) + return true; + if (RHS == getEmptyKey() || RHS == getTombstoneKey()) + return false; + return SubsetEqualTy::isSubsetEqual(LHS, RHS); } }; |