Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions llvm/include/llvm/IR/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1410,18 +1410,14 @@ class MDNode : public Metadata {
void eraseFromStore();

template <class NodeTy> struct HasCachedHash;
template <class NodeTy>
static void dispatchRecalculateHash(NodeTy *N, std::true_type) {
N->recalculateHash();
}
template <class NodeTy>
static void dispatchRecalculateHash(NodeTy *, std::false_type) {}
template <class NodeTy>
static void dispatchResetHash(NodeTy *N, std::true_type) {
N->setHash(0);
}
template <class NodeTy>
static void dispatchResetHash(NodeTy *, std::false_type) {}
template <class NodeTy> static void dispatchRecalculateHash(NodeTy *N) {
if constexpr (HasCachedHash<NodeTy>::value)
N->recalculateHash();
}
template <class NodeTy> static void dispatchResetHash(NodeTy *N) {
if constexpr (HasCachedHash<NodeTy>::value)
N->setHash(0);
}

/// Merge branch weights from two direct callsites.
static MDNode *mergeDirectCallProfMetadata(MDNode *A, MDNode *B,
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/IR/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,8 +1007,7 @@ MDNode *MDNode::uniquify() {
#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
case CLASS##Kind: { \
CLASS *SubclassThis = cast<CLASS>(this); \
std::bool_constant<HasCachedHash<CLASS>::value> ShouldRecalculateHash; \
dispatchRecalculateHash(SubclassThis, ShouldRecalculateHash); \
dispatchRecalculateHash(SubclassThis); \
return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \
}
#include "llvm/IR/Metadata.def"
Expand Down Expand Up @@ -1064,8 +1063,7 @@ void MDNode::storeDistinctInContext() {
llvm_unreachable("Invalid subclass of MDNode");
#define HANDLE_MDNODE_LEAF(CLASS) \
case CLASS##Kind: { \
std::bool_constant<HasCachedHash<CLASS>::value> ShouldResetHash; \
dispatchResetHash(cast<CLASS>(this), ShouldResetHash); \
dispatchResetHash(cast<CLASS>(this)); \
break; \
}
#include "llvm/IR/Metadata.def"
Expand Down