mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixup! Implementation of Lengauer-Tarjan algorithm to find dominators
This commit is contained in:
parent
56cabdc69a
commit
a9a09bea6d
@ -40,10 +40,10 @@ class Dominator
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Dominator(Vertex _entry, size_t _numVertices)
|
Dominator(Vertex _entry, size_t _numVertices):
|
||||||
|
m_vertex(_numVertices),
|
||||||
|
m_immediateDominator(lengauerTarjanDominator(_entry, _numVertices))
|
||||||
{
|
{
|
||||||
m_vertex = std::vector<Vertex>(_numVertices);
|
|
||||||
m_immediateDominator = lengauerTarjanDominator(_entry, _numVertices);
|
|
||||||
buildDominatorTree();
|
buildDominatorTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,18 +97,18 @@ public:
|
|||||||
{
|
{
|
||||||
solAssert(!m_vertex.empty());
|
solAssert(!m_vertex.empty());
|
||||||
// The entry node always dominates all other nodes
|
// The entry node always dominates all other nodes
|
||||||
std::vector<Vertex> dominators = std::vector<Vertex>{m_vertex[0]};
|
std::vector<Vertex> dominators{m_vertex[0]};
|
||||||
|
|
||||||
size_t idomIdx = m_immediateDominator[m_vertexIndex[_v]];
|
size_t idomIdx = m_immediateDominator[m_vertexIndex[_v]];
|
||||||
if (idomIdx == 0)
|
if (idomIdx == 0)
|
||||||
return std::move(dominators);
|
return dominators;
|
||||||
|
|
||||||
while (idomIdx != 0)
|
while (idomIdx != 0)
|
||||||
{
|
{
|
||||||
dominators.emplace_back(m_vertex[idomIdx]);
|
dominators.emplace_back(m_vertex[idomIdx]);
|
||||||
idomIdx = m_immediateDominator[idomIdx];
|
idomIdx = m_immediateDominator[idomIdx];
|
||||||
}
|
}
|
||||||
return std::move(dominators);
|
return dominators;
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildDominatorTree() {
|
void buildDominatorTree() {
|
||||||
|
Loading…
Reference in New Issue
Block a user