cyclegraph: mergeNodes(): return early if we violate RMW
authorBrian Norris <banorris@uci.edu>
Wed, 6 Feb 2013 22:42:00 +0000 (14:42 -0800)
committerBrian Norris <banorris@uci.edu>
Wed, 6 Feb 2013 22:42:00 +0000 (14:42 -0800)
To be consistent, and to prevent unecessary merging work, we should
simply return from the mergeNodes() function as soon as we know it has
failed.

cyclegraph.cc

index b138372..89fc36c 100644 (file)
@@ -147,8 +147,10 @@ bool CycleGraph::mergeNodes(CycleNode *w_node, CycleNode *p_node,
 
        /* Transfer the RMW */
        CycleNode *promise_rmw = p_node->getRMW();
-       if (promise_rmw && promise_rmw != w_node->getRMW() && w_node->setRMW(promise_rmw))
+       if (promise_rmw && promise_rmw != w_node->getRMW() && w_node->setRMW(promise_rmw)) {
                hasCycles = true;
+               return false;
+       }
 
        /* Transfer back edges to w_node */
        while (p_node->getNumBackEdges() > 0) {