cyclegraph: separate an 'addEdge(CycleNode *, CycleNode *) function
authorBrian Norris <banorris@uci.edu>
Fri, 25 Jan 2013 01:26:28 +0000 (17:26 -0800)
committerBrian Norris <banorris@uci.edu>
Fri, 25 Jan 2013 01:26:28 +0000 (17:26 -0800)
We need to represent edge addition as a low-level operation on
CycleNodes, not just on ModelActions.

cyclegraph.cc
cyclegraph.h

index 66f9f69548608d02baa36dbd09bbd9b8ac2feac7..62cef7c56079e2d2a46587a181340320a9fe0405 100644 (file)
@@ -62,6 +62,16 @@ void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to)
        CycleNode *fromnode = getNode(from);
        CycleNode *tonode = getNode(to);
 
+       addEdge(fromnode, tonode);
+}
+
+/**
+ * Adds an edge between two CycleNodes.
+ * @param fromnode The edge comes from this CycleNode
+ * @param tonode The edge points to this CycleNode
+ */
+void CycleGraph::addEdge(CycleNode *fromnode, CycleNode *tonode)
+{
        if (!hasCycles)
                hasCycles = checkReachable(tonode, fromnode);
 
@@ -117,11 +127,7 @@ void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw)
                }
        }
 
-       if (!hasCycles)
-               hasCycles = checkReachable(rmwnode, fromnode);
-
-       if (fromnode->addEdge(rmwnode))
-               rollbackvector.push_back(fromnode);
+       addEdge(fromnode, rmwnode);
 }
 
 #if SUPPORT_MOD_ORDER_DUMP
index 45e49fb7bec3950656054e02f92b06aa5cf3ae65..8668077ed271cc887c7a249f470a8345c54d1539 100644 (file)
@@ -40,6 +40,7 @@ class CycleGraph {
 
        SNAPSHOTALLOC
  private:
+       void addEdge(CycleNode *fromnode, CycleNode *tonode);
        void putNode(const ModelAction *act, CycleNode *node);
        CycleNode * getNode(const ModelAction *);
        HashTable<const CycleNode *, const CycleNode *, uintptr_t, 4, model_malloc, model_calloc, model_free> *discovered;