-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Analysis] Provide inlined AnalysisKey in AnalysisInfoMixin
#116046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-llvm-ir Author: None (paperchalice) ChangesThe comment about it is 8 years ago, we have newer VS and C++17. Try to move analysis keys to Full diff: https://github.com/llvm/llvm-project/pull/116046.diff 1 Files Affected:
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 {
|
|
CC @fsfod because you are working on dynamic library support on Windows. |
|
I remember I had to work around with a clang-cl bug that was fixed in v19 to get these to export correctly. |
compnerd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A local build in DLL mode would definitely be good to run against the minimum supported VS (which I believe is 2019).
If that compiler is able to deal with this properly, addressing this makes sense. I do wonder if this is going to break any out-of-tree analysis passes though due to the redeclaration.
|
Should be fine if |
Can you post more details on which version of clang-cl is broken? |
|
I should said the issue with the my new DLL build setup not the old existing system that filters exports with a python script, The current changes from this PR doesn't make it any worse or regress the new DLL build setup at least. The original issue i had was this field wasn't getting imported from a extern explicit template instantiation declaration annotated with dllimport. I double checked building with clang-cl 19 and this wasn't fixed so idk if I got confused with some other dllexport bug. |
a616a82 to
551e734
Compare
551e734 to
2a9ae65
Compare
|
Unfortunately the address is still not unique in pass plugin and I can't reproduce it locally. |
|
There is still something like: llvm-project/llvm/include/llvm/IR/PassManager.h Lines 642 to 644 in 0ee5924
which would be an issue in future... |
The comment about it is 8 years ago, we have newer VS and C++17. Try to move analysis keys to
AnalysisInfoMixin.If this change is feasible on Windows, I will remove analysis keys in analysis passes later.