Skip to content

Commit

Permalink
Merge pull request #492 from dberlin/remove-stack-space
Browse files Browse the repository at this point in the history
Remove more than half the stack usage of CFG traversal
  • Loading branch information
s3rvac authored Feb 7, 2019
2 parents 5469b90 + c959955 commit e3c7ce4
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 e3c7ce4

Please sign in to comment.