[llvm] [Support] Store dominator tree nodes in a vector (PR #101705)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 4 06:07:07 PDT 2024
================
@@ -333,35 +336,71 @@ class DominatorTreeBase {
if (!std::is_permutation(Roots.begin(), Roots.end(), Other.Roots.begin()))
return true;
- const DomTreeNodeMapType &OtherDomTreeNodes = Other.DomTreeNodes;
- if (DomTreeNodes.size() != OtherDomTreeNodes.size())
- return true;
-
- for (const auto &DomTreeNode : DomTreeNodes) {
- NodeT *BB = DomTreeNode.first;
- typename DomTreeNodeMapType::const_iterator OI =
- OtherDomTreeNodes.find(BB);
- if (OI == OtherDomTreeNodes.end())
+ size_t NumNodes = 0;
+ // All node we have must exist and be equal in the other tree
+ for (const auto &Node : DomTreeNodes) {
+ if (!Node)
+ continue;
+ if (Node->compare(Other.getNode(Node->getBlock())))
return true;
+ NumNodes++;
+ }
- DomTreeNodeBase<NodeT> &MyNd = *DomTreeNode.second;
- DomTreeNodeBase<NodeT> &OtherNd = *OI->second;
+ // If we the other tree has more nodes than we have, they're not equal
----------------
nikic wrote:
```suggestion
// If the other tree has more nodes than we have, they're not equal.
```
https://github.com/llvm/llvm-project/pull/101705
More information about the llvm-commits
mailing list