[PATCH] D141865: [llvm][GenericUniformity] Hack around strict is_invocable() checks

Krzysztof Drewniak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 16 10:41:58 PST 2023


krzysz00 created this revision.
Herald added a project: All.
krzysz00 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

With recent (> 15, as far as I can tell, possibly > 16) clang, c++17,
and GNU's libstdc++ (versions 9 and 10 and maybe others), LLVM fails
to compile due to an is_invocable() check in unique_ptr::reset().

To resolve this issue, add a template argument to ImplDeleter to make
things work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141865

Files:
  llvm/include/llvm/ADT/GenericUniformityImpl.h
  llvm/include/llvm/ADT/GenericUniformityInfo.h


Index: llvm/include/llvm/ADT/GenericUniformityInfo.h
===================================================================
--- llvm/include/llvm/ADT/GenericUniformityInfo.h
+++ llvm/include/llvm/ADT/GenericUniformityInfo.h
@@ -63,12 +63,16 @@
 
 private:
   using ImplT = GenericUniformityAnalysisImpl<ContextT>;
-  struct ImplDeleter {
-    void operator()(GenericUniformityAnalysisImpl<ContextT> *Impl);
+  // Ugly hack around the fact that recent (> 15.0) clang will run into an
+  // is_invocable() check in some GNU libc++'s unique_ptr implementation
+  // and reject this deleter if you just make it callable with an ImplT *,
+  // whether or not the type of ImplT is spelled out.
+  template <typename DelT = ImplT> struct ImplDeleter {
+    void operator()(DelT *Impl);
   };
 
   FunctionT *F;
-  std::unique_ptr<ImplT, ImplDeleter> DA;
+  std::unique_ptr<ImplT, ImplDeleter<ImplT>> DA;
 
   GenericUniformityInfo(const GenericUniformityInfo &) = delete;
   GenericUniformityInfo &operator=(const GenericUniformityInfo &) = delete;
Index: llvm/include/llvm/ADT/GenericUniformityImpl.h
===================================================================
--- llvm/include/llvm/ADT/GenericUniformityImpl.h
+++ llvm/include/llvm/ADT/GenericUniformityImpl.h
@@ -468,8 +468,9 @@
 };
 
 template <typename ContextT>
-void GenericUniformityInfo<ContextT>::ImplDeleter::operator()(
-    GenericUniformityAnalysisImpl<ContextT> *Impl) {
+template <typename DelT>
+void GenericUniformityInfo<ContextT>::ImplDeleter<DelT>::operator()(
+    DelT *Impl) {
   delete Impl;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141865.489601.patch
Type: text/x-patch
Size: 1570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230116/5860e09e/attachment.bin>


More information about the llvm-commits mailing list