Merge pull request #13709 from ChrisXXXXXXX/patch-2

Separate node for every `if` and `case` body in the Yul CFG
This commit is contained in:
Daniel 2022-12-01 17:04:41 +01:00 committed by GitHub
commit a9f8a77817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,9 +51,15 @@ void ControlFlowBuilder::operator()(If const& _if)
{ {
visit(*_if.condition); visit(*_if.condition);
ControlFlowNode* node = m_currentNode; ControlFlowNode* node = m_currentNode;
(*this)(_if.body);
ControlFlowNode* ifEnd = newNode();
node->successors.emplace_back(ifEnd);
newConnectedNode(); newConnectedNode();
node->successors.emplace_back(m_currentNode); (*this)(_if.body);
m_currentNode->successors.emplace_back(ifEnd);
m_currentNode = ifEnd;
} }
void ControlFlowBuilder::operator()(Switch const& _switch) void ControlFlowBuilder::operator()(Switch const& _switch)
@ -68,8 +74,8 @@ void ControlFlowBuilder::operator()(Switch const& _switch)
for (Case const& case_: _switch.cases) for (Case const& case_: _switch.cases)
{ {
m_currentNode = initialNode; m_currentNode = initialNode;
(*this)(case_.body);
newConnectedNode(); newConnectedNode();
(*this)(case_.body);
m_currentNode->successors.emplace_back(finalNode); m_currentNode->successors.emplace_back(finalNode);
} }
m_currentNode = finalNode; m_currentNode = finalNode;
@ -282,4 +288,3 @@ void ControlFlowSideEffectsCollector::recordReachabilityAndQueue(
if (m_processedNodes[&_function].insert(_node).second) if (m_processedNodes[&_function].insert(_node).second)
m_pendingNodes.at(&_function).push_front(_node); m_pendingNodes.at(&_function).push_front(_node);
} }