[llvm] Revert "[IR] Simplify HasCachedHash with is_detected (NFC) (#159510)" (PR #159622)
Jordan Rupprecht via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 18 11:33:07 PDT 2025
https://github.com/rupprecht created https://github.com/llvm/llvm-project/pull/159622
This reverts commit d6b7ac830ab4c1b26a1b2eecd15306eccf9cea90. Build breakages reported on the PR hint at not working with certain versions of the host compiler.
>From 3d9ff9777b8d50c5520ea5ab9017fc6c7e6b08da Mon Sep 17 00:00:00 2001
From: Jordan Rupprecht <rupprecht at google.com>
Date: Thu, 18 Sep 2025 11:31:35 -0700
Subject: [PATCH] Revert "[IR] Simplify HasCachedHash with is_detected (NFC)
(#159510)"
This reverts commit d6b7ac830ab4c1b26a1b2eecd15306eccf9cea90. Build breakages reported on the PR hint at not working with certain versions of the host compiler.
---
llvm/lib/IR/Metadata.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 09e25ceaf59c3..fc78a5b299f49 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -986,10 +986,15 @@ static T *uniquifyImpl(T *N, DenseSet<T *, InfoT> &Store) {
}
template <class NodeTy> struct MDNode::HasCachedHash {
+ using Yes = char[1];
+ using No = char[2];
+ template <class U, U Val> struct SFINAE {};
+
template <class U>
- using check = decltype(static_cast<void (U::*)(unsigned)>(&U::setHash));
+ static Yes &check(SFINAE<void (U::*)(unsigned), &U::setHash> *);
+ template <class U> static No &check(...);
- static constexpr bool value = is_detected<check, NodeTy>::value;
+ static const bool value = sizeof(check<NodeTy>(nullptr)) == sizeof(Yes);
};
MDNode *MDNode::uniquify() {
More information about the llvm-commits
mailing list