[llvm] [Analysis] Provide inlined `AnalysisKey` in `AnalysisInfoMixin` (PR #116046)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 13 05:34:32 PST 2024
https://github.com/paperchalice created https://github.com/llvm/llvm-project/pull/116046
The comment about it is 8 years ago, we have newer VS and C++17. Try to move analysis keys to `AnalysisInfoMixin`.
>From 5e3535acd3008260b033ffe01dbd114ed0808341 Mon Sep 17 00:00:00 2001
From: PaperChalice <liujunchang97 at outlook.com>
Date: Wed, 13 Nov 2024 21:25:45 +0800
Subject: [PATCH] [Analysis] Provide inlined `AnalysisKey` in
`AnalysisInfoMixin`
---
llvm/include/llvm/IR/PassManager.h | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index d269221fac0701..69643d6cab8fc2 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -95,21 +95,15 @@ struct AnalysisInfoMixin : PassInfoMixin<DerivedT> {
/// This ID is a pointer type that is guaranteed to be 8-byte aligned and thus
/// suitable for use in sets, maps, and other data structures that use the low
/// bits of pointers.
- ///
- /// Note that this requires the derived type provide a static \c AnalysisKey
- /// member called \c Key.
- ///
- /// FIXME: The only reason the mixin type itself can't declare the Key value
- /// is that some compilers cannot correctly unique a templated static variable
- /// so it has the same addresses in each instantiation. The only currently
- /// known platform with this limitation is Windows DLL builds, specifically
- /// building each part of LLVM as a DLL. If we ever remove that build
- /// configuration, this mixin can provide the static key as well.
static AnalysisKey *ID() {
static_assert(std::is_base_of<AnalysisInfoMixin, DerivedT>::value,
"Must pass the derived type as the template argument!");
return &DerivedT::Key;
}
+
+private:
+ /// Opaque, unique ID for this analysis type.
+ static constexpr AnalysisKey Key = {};
};
namespace detail {
More information about the llvm-commits
mailing list