mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Fix DFS number calculation for postdominators
The DFS number calculation for postdominators was broken. In the case of multiple exits that form the post dominator root nodes, do not iterate over all exits, but start from the virtual root node. Otherwise bbs, that are not post dominated by any exit but by the virtual root node, will never be assigned a DFS number. llvm-svn: 92967
This commit is contained in:
parent
944f9c4ac1
commit
fbc9ea7841
@ -585,29 +585,35 @@ protected:
|
||||
SmallVector<std::pair<DomTreeNodeBase<NodeT>*,
|
||||
typename DomTreeNodeBase<NodeT>::iterator>, 32> WorkStack;
|
||||
|
||||
for (unsigned i = 0, e = (unsigned)this->Roots.size(); i != e; ++i) {
|
||||
DomTreeNodeBase<NodeT> *ThisRoot = getNode(this->Roots[i]);
|
||||
WorkStack.push_back(std::make_pair(ThisRoot, ThisRoot->begin()));
|
||||
ThisRoot->DFSNumIn = DFSNum++;
|
||||
DomTreeNodeBase<NodeT> *ThisRoot = getRootNode();
|
||||
|
||||
while (!WorkStack.empty()) {
|
||||
DomTreeNodeBase<NodeT> *Node = WorkStack.back().first;
|
||||
typename DomTreeNodeBase<NodeT>::iterator ChildIt =
|
||||
WorkStack.back().second;
|
||||
if (!ThisRoot)
|
||||
return;
|
||||
|
||||
// If we visited all of the children of this node, "recurse" back up the
|
||||
// stack setting the DFOutNum.
|
||||
if (ChildIt == Node->end()) {
|
||||
Node->DFSNumOut = DFSNum++;
|
||||
WorkStack.pop_back();
|
||||
} else {
|
||||
// Otherwise, recursively visit this child.
|
||||
DomTreeNodeBase<NodeT> *Child = *ChildIt;
|
||||
++WorkStack.back().second;
|
||||
// Even in the case of multiple exits that form the post dominator root
|
||||
// nodes, do not iterate over all exits, but start from the virtual root
|
||||
// node. Otherwise bbs, that are not post dominated by any exit but by the
|
||||
// virtual root node, will never be assigned a DFS number.
|
||||
WorkStack.push_back(std::make_pair(ThisRoot, ThisRoot->begin()));
|
||||
ThisRoot->DFSNumIn = DFSNum++;
|
||||
|
||||
WorkStack.push_back(std::make_pair(Child, Child->begin()));
|
||||
Child->DFSNumIn = DFSNum++;
|
||||
}
|
||||
while (!WorkStack.empty()) {
|
||||
DomTreeNodeBase<NodeT> *Node = WorkStack.back().first;
|
||||
typename DomTreeNodeBase<NodeT>::iterator ChildIt =
|
||||
WorkStack.back().second;
|
||||
|
||||
// If we visited all of the children of this node, "recurse" back up the
|
||||
// stack setting the DFOutNum.
|
||||
if (ChildIt == Node->end()) {
|
||||
Node->DFSNumOut = DFSNum++;
|
||||
WorkStack.pop_back();
|
||||
} else {
|
||||
// Otherwise, recursively visit this child.
|
||||
DomTreeNodeBase<NodeT> *Child = *ChildIt;
|
||||
++WorkStack.back().second;
|
||||
|
||||
WorkStack.push_back(std::make_pair(Child, Child->begin()));
|
||||
Child->DFSNumIn = DFSNum++;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user