cyclegraph: flag cycles for reflexive edges
authorBrian Norris <banorris@uci.edu>
Sat, 6 Oct 2012 00:03:01 +0000 (17:03 -0700)
committerBrian Norris <banorris@uci.edu>
Sat, 6 Oct 2012 00:10:49 +0000 (17:10 -0700)
The cyclegraph shouldn't fail (i.e., ASSERT()) when reflexive edges are
added; instead, they should be declared as cycles.

cyclegraph.cc

index 2280e76e3e208b8ac6ce6e2044433c1a866d2c85..e1d5b3c50ef1a243eac7c2955e55d0b4a6b0e67d 100644 (file)
@@ -43,11 +43,14 @@ CycleNode * CycleGraph::getNode(const ModelAction *action) {
 void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) {
        ASSERT(from);
        ASSERT(to);
 void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) {
        ASSERT(from);
        ASSERT(to);
-       ASSERT(from != to);
 
        CycleNode *fromnode=getNode(from);
        CycleNode *tonode=getNode(to);
 
 
        CycleNode *fromnode=getNode(from);
        CycleNode *tonode=getNode(to);
 
+       if (!hasCycles) {
+               // Reflexive edges are cycles
+               hasCycles = (from == to);
+       }
        if (!hasCycles) {
                // Check for Cycles
                hasCycles=checkReachable(tonode, fromnode);
        if (!hasCycles) {
                // Check for Cycles
                hasCycles=checkReachable(tonode, fromnode);
@@ -85,7 +88,6 @@ void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) {
 void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) {
        ASSERT(from);
        ASSERT(rmw);
 void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) {
        ASSERT(from);
        ASSERT(rmw);
-       ASSERT(from != rmw);
 
        CycleNode *fromnode=getNode(from);
        CycleNode *rmwnode=getNode(rmw);
 
        CycleNode *fromnode=getNode(from);
        CycleNode *rmwnode=getNode(rmw);
@@ -114,6 +116,10 @@ void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) {
        }
 
 
        }
 
 
+       if (!hasCycles) {
+               // Reflexive edges are cycles
+               hasCycles = (from == rmw);
+       }
        if (!hasCycles) {
                // With promises we could be setting up a cycle here if we aren't
                // careful...avoid it..
        if (!hasCycles) {
                // With promises we could be setting up a cycle here if we aren't
                // careful...avoid it..