mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 05:29:24 +00:00
Fix dom tree compare. Don't forget to compare children!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52984 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f35cfe11ef
commit
a45a9e416f
@ -107,6 +107,28 @@ public:
|
||||
return Children.size();
|
||||
}
|
||||
|
||||
void clearAllChildren() {
|
||||
Children.clear();
|
||||
}
|
||||
|
||||
bool compare(DomTreeNodeBase<NodeT> *Other) {
|
||||
if (getNumChildren() != Other->getNumChildren())
|
||||
return true;
|
||||
|
||||
SmallPtrSet<NodeT *, 4> OtherChildren;
|
||||
for(iterator I = Other->begin(), E = Other->end(); I != E; ++I) {
|
||||
NodeT *Nd = (*I)->getBlock();
|
||||
OtherChildren.insert(Nd);
|
||||
}
|
||||
|
||||
for(iterator I = begin(), E = end(); I != E; ++I) {
|
||||
NodeT *N = (*I)->getBlock();
|
||||
if (OtherChildren.count(N) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void setIDom(DomTreeNodeBase<NodeT> *NewIDom) {
|
||||
assert(IDom && "No immediate dominator?");
|
||||
if (IDom != NewIDom) {
|
||||
@ -312,36 +334,26 @@ public:
|
||||
/// dominator tree base. Otherwise return true.
|
||||
bool compare(DominatorTreeBase &Other) const {
|
||||
|
||||
// Collect nodes.
|
||||
const DomTreeNodeMapType &OtherDomTreeNodes = Other.DomTreeNodes;
|
||||
if (DomTreeNodes.size() != OtherDomTreeNodes.size())
|
||||
return true;
|
||||
|
||||
SmallPtrSet<const NodeT *,4> MyBBs;
|
||||
for (typename DomTreeNodeMapType::const_iterator
|
||||
I = this->DomTreeNodes.begin(),
|
||||
E = this->DomTreeNodes.end(); I != E; ++I) {
|
||||
const NodeT *BB = I->first;
|
||||
MyBBs.insert(BB);
|
||||
}
|
||||
NodeT *BB = I->first;
|
||||
typename DomTreeNodeMapType::const_iterator OI = OtherDomTreeNodes.find(BB);
|
||||
if (OI == OtherDomTreeNodes.end())
|
||||
return true;
|
||||
|
||||
SmallPtrSet<const NodeT *,4> OtherBBs;
|
||||
const DomTreeNodeMapType &OtherDomTreeNodes = Other.DomTreeNodes;
|
||||
for (typename DomTreeNodeMapType::const_iterator
|
||||
I = OtherDomTreeNodes.begin(),
|
||||
E = OtherDomTreeNodes.end(); I != E; ++I) {
|
||||
const NodeT *BB = I->first;
|
||||
OtherBBs.insert(BB);
|
||||
}
|
||||
DomTreeNodeBase<NodeT>* MyNd = I->second;
|
||||
DomTreeNodeBase<NodeT>* OtherNd = OI->second;
|
||||
|
||||
if (OtherBBs.size() != MyBBs.size())
|
||||
return true;
|
||||
|
||||
// Compare node sets.
|
||||
for (typename SmallPtrSet<const NodeT *,4>::const_iterator I = MyBBs.begin(),
|
||||
E = MyBBs.end(); I != E; ++I) {
|
||||
const NodeT *BB = *I;
|
||||
if (OtherBBs.erase(BB) == 0)
|
||||
if (MyNd->compare(OtherNd))
|
||||
return true;
|
||||
}
|
||||
if (!OtherBBs.empty())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user