Skip to content

Commit 5d98dc7

Browse files
committed
[llvm][GenericUniformity] Hack around strict is_invocable() checks
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. Differential Revision: https://reviews.llvm.org/D141865
1 parent 97cb619 commit 5d98dc7

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

llvm/include/llvm/ADT/GenericUniformityImpl.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,8 @@ template <typename ContextT> class GenericUniformityAnalysisImpl {
467467
ConstValueRefT Val) const;
468468
};
469469

470-
template <typename ContextT>
471-
void GenericUniformityInfo<ContextT>::ImplDeleter::operator()(
472-
GenericUniformityAnalysisImpl<ContextT> *Impl) {
470+
template <typename ImplT>
471+
void GenericUniformityAnalysisImplDeleter<ImplT>::operator()(ImplT *Impl) {
473472
delete Impl;
474473
}
475474

llvm/include/llvm/ADT/GenericUniformityInfo.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ namespace llvm {
2424
class TargetTransformInfo;
2525

2626
template <typename ContextT> class GenericUniformityAnalysisImpl;
27+
template <typename ImplT> struct GenericUniformityAnalysisImplDeleter {
28+
// Ugly hack around the fact that recent (> 15.0) clang will run into an
29+
// is_invocable() check in some GNU libc++'s unique_ptr implementation
30+
// and reject this deleter if you just make it callable with an ImplT *,
31+
// whether or not the type of ImplT is spelled out.
32+
using pointer = ImplT *;
33+
void operator()(ImplT *Impl);
34+
};
2735

2836
template <typename ContextT> class GenericUniformityInfo {
2937
public:
@@ -63,12 +71,9 @@ template <typename ContextT> class GenericUniformityInfo {
6371

6472
private:
6573
using ImplT = GenericUniformityAnalysisImpl<ContextT>;
66-
struct ImplDeleter {
67-
void operator()(GenericUniformityAnalysisImpl<ContextT> *Impl);
68-
};
6974

7075
FunctionT *F;
71-
std::unique_ptr<ImplT, ImplDeleter> DA;
76+
std::unique_ptr<ImplT, GenericUniformityAnalysisImplDeleter<ImplT>> DA;
7277

7378
GenericUniformityInfo(const GenericUniformityInfo &) = delete;
7479
GenericUniformityInfo &operator=(const GenericUniformityInfo &) = delete;

llvm/lib/Analysis/UniformityAnalysis.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ bool llvm::GenericUniformityAnalysisImpl<SSAContext>::usesValueFromCycle(
8787
// This ensures explicit instantiation of
8888
// GenericUniformityAnalysisImpl::ImplDeleter::operator()
8989
template class llvm::GenericUniformityInfo<SSAContext>;
90+
template struct llvm::GenericUniformityAnalysisImplDeleter<
91+
llvm::GenericUniformityAnalysisImpl<SSAContext>>;
9092

9193
//===----------------------------------------------------------------------===//
9294
// UniformityInfoAnalysis and related pass implementations

llvm/lib/CodeGen/MachineUniformityAnalysis.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ bool llvm::GenericUniformityAnalysisImpl<MachineSSAContext>::usesValueFromCycle(
113113
// This ensures explicit instantiation of
114114
// GenericUniformityAnalysisImpl::ImplDeleter::operator()
115115
template class llvm::GenericUniformityInfo<MachineSSAContext>;
116+
template struct llvm::GenericUniformityAnalysisImplDeleter<
117+
llvm::GenericUniformityAnalysisImpl<MachineSSAContext>>;
116118

117119
MachineUniformityInfo
118120
llvm::computeMachineUniformityInfo(MachineFunction &F,

0 commit comments

Comments
 (0)