mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-02 07:17:36 +00:00
IR: Detect whether to call recalculateHash() via SFINAE, NFC
Rather than relying on updating switch statements correctly, detect whether `setHash()` exists in the subclass. If so, call `recalculateHash()` and `setHash(0)` appropriately. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226531 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -825,6 +825,20 @@ private:
|
||||
MDNode *uniquify();
|
||||
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 *N, std::false_type) {}
|
||||
template <class NodeTy>
|
||||
static void dispatchResetHash(NodeTy *N, std::true_type) {
|
||||
N->setHash(0);
|
||||
}
|
||||
template <class NodeTy>
|
||||
static void dispatchResetHash(NodeTy *N, std::false_type) {}
|
||||
|
||||
public:
|
||||
typedef const MDOperand *op_iterator;
|
||||
typedef iterator_range<op_iterator> op_range;
|
||||
|
||||
Reference in New Issue
Block a user