Skip to content

Commit

Permalink
Remove more than half the stack usage of CFG traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
dberlin committed Feb 6, 2019
1 parent 7febc9c commit c959955
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/llvmir2hll/graphs/cfg/cfg_traversal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool CFGTraversal::getCurrRetVal() const {
}

/**
* @brief A recursive implementation of performTraversal().
* @brief A non-recursive implementation of performTraversal().
*
* @param[in] node Node to be traversed.
* @param[in] stmtIter Iterator to a statement in @a node to be checked.
Expand All @@ -168,7 +168,7 @@ bool CFGTraversal::getCurrRetVal() const {
*/
bool CFGTraversal::performTraversalImpl(ShPtr<CFG::Node> node,
CFG::stmt_iterator stmtIter) {
if (stmtIter != node->stmt_end()) {
while (stmtIter != node->stmt_end()) {
// We're not at the end of the node, so check the statement under
// stmtIter.

Expand All @@ -182,15 +182,15 @@ bool CFGTraversal::performTraversalImpl(ShPtr<CFG::Node> node,
return getCurrRetVal();
}

return performTraversalImpl(node, ++stmtIter);
++stmtIter;
}

// We have reached the end of the node, so check node's successors.
return traverseNodeSuccessors(node);
}

/**
* @brief A recursive implementation of performReverseTraversal().
* @brief A non-recursive implementation of performReverseTraversal().
*
* @param[in] node Node to be traversed.
* @param[in] stmtRIter Reverse iterator to a statement in @a node to be
Expand All @@ -202,7 +202,7 @@ bool CFGTraversal::performTraversalImpl(ShPtr<CFG::Node> node,
bool CFGTraversal::performReverseTraversalImpl(ShPtr<CFG::Node> node,
CFG::stmt_reverse_iterator stmtRIter) {

if (stmtRIter != node->stmt_rend()) {
while (stmtRIter != node->stmt_rend()) {
// We're not at the start of the node, so check the statement under
// stmtRIter.

Expand All @@ -216,7 +216,7 @@ bool CFGTraversal::performReverseTraversalImpl(ShPtr<CFG::Node> node,
return getCurrRetVal();
}

return performReverseTraversalImpl(node, ++stmtRIter);
++stmtRIter;
}

// We have reached the start of the node, so check node's predecessors.
Expand Down

0 comments on commit c959955

Please sign in to comment.