Skip to content

[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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions mlir/include/mlir/Analysis/DataFlowFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -560,6 +538,36 @@ class AnalysisState {
friend class DataFlowSolver;
};

//===----------------------------------------------------------------------===//
// DataFlowSolver definition
//===----------------------------------------------------------------------===//
// This method is defined outside `DataFlowSolver` and after `AnalysisState`
// to prevent issues around `AnalysisState` being used before it is defined.
template <typename AnchorT>
Copy link
Contributor

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:

Suggested change
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>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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
//===----------------------------------------------------------------------===//
Expand Down