[llvm] [ADT] Use "static inline" to initialize EmptyDivergenceDesc; (NFC) (PR #160445)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 23 22:59:03 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

In C++17, we can initialize a static member variable with "static
inline" as part of the class definition.  With this, we can eliminate
the out-of-line static initializer involving boilerplate template
code.


---
Full diff: https://github.com/llvm/llvm-project/pull/160445.diff


1 Files Affected:

- (modified) llvm/include/llvm/ADT/GenericUniformityImpl.h (+1-5) 


``````````diff
diff --git a/llvm/include/llvm/ADT/GenericUniformityImpl.h b/llvm/include/llvm/ADT/GenericUniformityImpl.h
index 3b9b7f2633771..141816c304397 100644
--- a/llvm/include/llvm/ADT/GenericUniformityImpl.h
+++ b/llvm/include/llvm/ADT/GenericUniformityImpl.h
@@ -310,7 +310,7 @@ template <typename ContextT> class GenericSyncDependenceAnalysis {
   const DivergenceDescriptor &getJoinBlocks(const BlockT *DivTermBlock);
 
 private:
-  static DivergenceDescriptor EmptyDivergenceDesc;
+  static inline DivergenceDescriptor EmptyDivergenceDesc;
 
   ModifiedPO CyclePO;
 
@@ -741,10 +741,6 @@ template <typename ContextT> class DivergencePropagator {
   }
 };
 
-template <typename ContextT>
-typename llvm::GenericSyncDependenceAnalysis<ContextT>::DivergenceDescriptor
-    llvm::GenericSyncDependenceAnalysis<ContextT>::EmptyDivergenceDesc;
-
 template <typename ContextT>
 llvm::GenericSyncDependenceAnalysis<ContextT>::GenericSyncDependenceAnalysis(
     const ContextT &Context, const DominatorTreeT &DT, const CycleInfoT &CI)

``````````

</details>


https://github.com/llvm/llvm-project/pull/160445


More information about the llvm-commits mailing list