-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[NFC][mlir] Update DataFlowFramework.h to be compatible with clang c++23 #152040
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
base: main
Are you sure you want to change the base?
[NFC][mlir] Update DataFlowFramework.h to be compatible with clang c++23 #152040
Conversation
@llvm/pr-subscribers-mlir Author: Philip Lassen (philass) ChangesThis change makes it possible to compile For full context: Thanks for the suggested fix @fabianmcg! Full diff: https://github.com/llvm/llvm-project/pull/152040.diff 1 Files Affected:
diff --git a/mlir/include/mlir/Analysis/DataFlowFramework.h b/mlir/include/mlir/Analysis/DataFlowFramework.h
index 49862927caff2..470170c26e6cb 100644
--- a/mlir/include/mlir/Analysis/DataFlowFramework.h
+++ b/mlir/include/mlir/Analysis/DataFlowFramework.h
@@ -354,29 +354,7 @@ class DataFlowSolver {
/// Erase any analysis state associated with the given lattice anchor.
template <typename AnchorT>
- void eraseState(AnchorT anchor) {
- LatticeAnchor latticeAnchor(anchor);
-
- // Update equivalentAnchorMap.
- for (auto &&[TypeId, eqClass] : equivalentAnchorMap) {
- if (!eqClass.contains(latticeAnchor)) {
- continue;
- }
- llvm::EquivalenceClasses<LatticeAnchor>::member_iterator leaderIt =
- eqClass.findLeader(latticeAnchor);
-
- // Update analysis states with new leader if needed.
- if (*leaderIt == latticeAnchor && ++leaderIt != eqClass.member_end()) {
- analysisStates[*leaderIt][TypeId] =
- std::move(analysisStates[latticeAnchor][TypeId]);
- }
-
- eqClass.erase(latticeAnchor);
- }
-
- // Update analysis states.
- analysisStates.erase(latticeAnchor);
- }
+ void eraseState(AnchorT anchor);
/// Erase all analysis states.
void eraseAllStates() {
@@ -560,6 +538,31 @@ class AnalysisState {
friend class DataFlowSolver;
};
+template <typename AnchorT>
+void DataFlowSolver::eraseState(AnchorT anchor) {
+ LatticeAnchor latticeAnchor(anchor);
+
+ // Update equivalentAnchorMap.
+ for (auto &&[TypeId, eqClass] : equivalentAnchorMap) {
+ if (!eqClass.contains(latticeAnchor)) {
+ continue;
+ }
+ llvm::EquivalenceClasses<LatticeAnchor>::member_iterator leaderIt =
+ eqClass.findLeader(latticeAnchor);
+
+ // Update analysis states with new leader if needed.
+ if (*leaderIt == latticeAnchor && ++leaderIt != eqClass.member_end()) {
+ analysisStates[*leaderIt][TypeId] =
+ std::move(analysisStates[latticeAnchor][TypeId]);
+ }
+
+ eqClass.erase(latticeAnchor);
+ }
+
+ // Update analysis states.
+ analysisStates.erase(latticeAnchor);
+}
+
//===----------------------------------------------------------------------===//
// DataFlowAnalysis
//===----------------------------------------------------------------------===//
|
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.
Thank you for this! In general LGTM, I'll approve as soon as the comment is fixed.
@@ -560,6 +538,31 @@ class AnalysisState { | |||
friend class DataFlowSolver; | |||
}; | |||
|
|||
template <typename AnchorT> |
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.
Add a comment around the lines:
template <typename AnchorT> | |
//===----------------------------------------------------------------------===// | |
// DataFlowSolver definition | |
//===----------------------------------------------------------------------===// | |
// This is method is defined outside `DataFlowSolver` and after `AnalysisState` to prevent issues around `AnalysisState` being used before it is defined. | |
template <typename AnchorT> |
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.
Done!
Also, please don't reference people in the commit message, see https://discourse.llvm.org/t/forbidding-username-in-commits/86997 |
b2ba87f
to
8cad488
Compare
Also, please edit the commit message with a bigger description of the issue and solution to not force people to go to discourse. Thanks! |
Thanks for pointing me to the commit message rules. I updated with a more detailed description of the problem and the fix. Would you like me to delete the reference to the discourse all together? |
And if you do approve, could you also commit for me? I don't have llvm commit privileges. |
//===----------------------------------------------------------------------===// | ||
// DataFlowSolver definition | ||
//===----------------------------------------------------------------------===// | ||
// This is method is defined outside `DataFlowSolver` and after `AnalysisState` |
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.
// This is method is defined outside `DataFlowSolver` and after `AnalysisState` | |
// This method is defined outside `DataFlowSolver` and after `AnalysisState` |
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.
Good catch. Done!
8cad488
to
efc0f1f
Compare
This change makes
DataFlowFramework.h
compatible withclang++
and--std=c++23
.Previously clang was checking the templated
DataFlowSolver::eraseState
body before being instantiated. This resulted in issues with incomplete types, and happened at least withclang++-19
.This is fixed by moving the definition of
DataFlowSolver::eraseState
after theAnalysisState
's full class declaration.For full context: