mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 19:08:21 +08:00
[NFC][mlir] Update DataFlowFramework.h to be compatible with clang c++23 (#152040)
This change makes `DataFlowFramework.h` compatible with `clang++` 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 with `clang++-19`. This is fixed by moving the definition of `DataFlowSolver::eraseState` after the `AnalysisState`'s full class declaration. For full context: - https://discourse.llvm.org/t/what-is-the-status-of-c-23-support-in-mlir/87674/12
This commit is contained in:
@@ -354,29 +354,7 @@ public:
|
||||
|
||||
/// 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,36 @@ private:
|
||||
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>
|
||||
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
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Reference in New Issue
Block a user