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

Krzysztof Drewniak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 08:57:59 PST 2023


krzysz00 added a comment.

Unfortunately, moving the deleter inside by this diff

  diff --git a/llvm/include/llvm/ADT/GenericUniformityImpl.h b/llvm/include/llvm/ADT/GenericUniformityImpl.h
  index 06d9b417ebde..f0f1f8e79c8e 100644
  --- a/llvm/include/llvm/ADT/GenericUniformityImpl.h
  +++ b/llvm/include/llvm/ADT/GenericUniformityImpl.h
  @@ -467,8 +467,9 @@ private:
                              ConstValueRefT Val) const;
   };
   
  +template <typename ContextT>
   template <typename ImplT>
  -void GenericUniformityAnalysisImplDeleter<ImplT>::operator()(ImplT *Impl) {
  +void GenericUniformityInfo<ContextT>::ImplDeleter<ImplT>::operator()(ImplT *Impl) {
     delete Impl;
   }
   
  diff --git a/llvm/include/llvm/ADT/GenericUniformityInfo.h b/llvm/include/llvm/ADT/GenericUniformityInfo.h
  index 24807bdc1c35..86d3d82f807a 100644
  --- a/llvm/include/llvm/ADT/GenericUniformityInfo.h
  +++ b/llvm/include/llvm/ADT/GenericUniformityInfo.h
  @@ -24,14 +24,6 @@ namespace llvm {
   class TargetTransformInfo;
   
   template <typename ContextT> class GenericUniformityAnalysisImpl;
  -template <typename ImplT> struct GenericUniformityAnalysisImplDeleter {
  -  // 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.
  -  using pointer = ImplT *;
  -  void operator()(ImplT *Impl);
  -};
   
   template <typename ContextT> class GenericUniformityInfo {
   public:
  @@ -72,8 +64,17 @@ public:
   private:
     using ImplT = GenericUniformityAnalysisImpl<ContextT>;
   
  +  template <typename ImplT> struct ImplDeleter {
  +    // 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.
  +    using pointer = ImplT *;
  +    void operator()(ImplT *Impl);
  +  };
  +
     FunctionT *F;
  -  std::unique_ptr<ImplT, GenericUniformityAnalysisImplDeleter<ImplT>> DA;
  +  std::unique_ptr<ImplT, ImplDeleter<ImplT>> DA;
   
     GenericUniformityInfo(const GenericUniformityInfo &) = delete;
     GenericUniformityInfo &operator=(const GenericUniformityInfo &) = delete;
  diff --git a/llvm/lib/Analysis/UniformityAnalysis.cpp b/llvm/lib/Analysis/UniformityAnalysis.cpp
  index 8ed5af8a8d1c..2b2cb3648d62 100644
  --- a/llvm/lib/Analysis/UniformityAnalysis.cpp
  +++ b/llvm/lib/Analysis/UniformityAnalysis.cpp
  @@ -87,8 +87,8 @@ bool llvm::GenericUniformityAnalysisImpl<SSAContext>::usesValueFromCycle(
   // This ensures explicit instantiation of
   // GenericUniformityAnalysisImpl::ImplDeleter::operator()
   template class llvm::GenericUniformityInfo<SSAContext>;
  -template struct llvm::GenericUniformityAnalysisImplDeleter<
  -    llvm::GenericUniformityAnalysisImpl<SSAContext>>;
  +template struct llvm::GenericUniformityInfo<SSAContext>::ImplDeleter<
  +  llvm::GenericUniformityAnalysisImpl<SSAContext>>;
   
   //===----------------------------------------------------------------------===//
   //  UniformityInfoAnalysis and related pass implementations
  diff --git a/llvm/lib/CodeGen/MachineUniformityAnalysis.cpp b/llvm/lib/CodeGen/MachineUniformityAnalysis.cpp
  index 2fe5e40a58c2..d6d0cd48af8b 100644
  --- a/llvm/lib/CodeGen/MachineUniformityAnalysis.cpp
  +++ b/llvm/lib/CodeGen/MachineUniformityAnalysis.cpp
  @@ -113,7 +113,7 @@ bool llvm::GenericUniformityAnalysisImpl<MachineSSAContext>::usesValueFromCycle(
   // This ensures explicit instantiation of
   // GenericUniformityAnalysisImpl::ImplDeleter::operator()
   template class llvm::GenericUniformityInfo<MachineSSAContext>;
  -template struct llvm::GenericUniformityAnalysisImplDeleter<
  +template struct llvm::GenericUniformityInfo<MachineSSAContext>::ImplDeleter<
       llvm::GenericUniformityAnalysisImpl<MachineSSAContext>>;
   
   MachineUniformityInfo

makes the build error come back.

So, even if it's ugly, it fixes the build.

And working build trumps nice names (and I needed the build un-broken, so I wasn't going to sit around and wait for more review)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141865/new/

https://reviews.llvm.org/D141865



More information about the llvm-commits mailing list