+
+ CycleNode * rmwnode=fromnode->getRMW();
+
+ //If the fromnode has a rmwnode that is not the tonode, we
+ //should add an edge between its rmwnode and the tonode
+
+ if (rmwnode!=NULL&&rmwnode!=tonode) {
+ if (!hasCycles) {
+ // Check for Cycles
+ hasCycles=checkReachable(tonode, rmwnode);
+ }
+ rmwnode->addEdge(tonode);
+ }
+}
+
+/** Handles special case of a RMW action. The ModelAction rmw reads
+ * from the ModelAction from. The key differences are: (1) no write
+ * can occur in between the rmw and the from action. Only one RMW
+ * action can read from a given write.
+ */
+void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) {
+ CycleNode *fromnode=getNode(from);
+ CycleNode *rmwnode=getNode(rmw);
+
+ /* Two RMW actions cannot read from the same write. */
+ if (fromnode->setRMW(rmwnode)) {
+ hasCycles=true;
+ }
+
+ /* Transfer all outgoing edges from the from node to the rmw node */
+ /* This process cannot add a cycle because rmw should not have any
+ incoming edges yet.*/
+ std::vector<CycleNode *> * edges=fromnode->getEdges();
+ for(unsigned int i=0;i<edges->size();i++) {
+ CycleNode * tonode=(*edges)[i];
+ rmwnode->addEdge(tonode);
+ }
+
+ fromnode->addEdge(rmwnode);