snapshot: print stack trace on segfault
[cdsspec-compiler.git] / cyclegraph.cc
index 62330624d6f08a233292ddfee1269380e8869beb..26235d651e10ecb5e2178d281048ea6ce5007893 100644 (file)
@@ -55,7 +55,11 @@ void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) {
        //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 tonode is also a rmw, don't do this check as the execution is
+       //doomed and we'll catch the problem elsewhere, but we want to allow
+       //for the possibility of sending to's write value to rmwnode
+
+       if (rmwnode!=NULL&&!to->is_rmw()) {
                if (!hasCycles) {
                        // Check for Cycles
                        hasCycles=checkReachable(tonode, rmwnode);
@@ -85,17 +89,19 @@ void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) {
        }
 
        /* Transfer all outgoing edges from the from node to the rmw node */
-       /* This process should not add a cycle because either: 
+       /* This process should not add a cycle because either:
         * (1) The rmw should not have any incoming edges yet if it is the
         * new node or
-        * (2) the fromnode is the new node and therefore it should not 
+        * (2) the fromnode is the new node and therefore it should not
         * have any outgoing edges.
         */
        std::vector<CycleNode *> * edges=fromnode->getEdges();
        for(unsigned int i=0;i<edges->size();i++) {
                CycleNode * tonode=(*edges)[i];
-               rollbackvector.push_back(rmwnode);
-               rmwnode->addEdge(tonode);
+               if (tonode!=rmwnode) {
+                       rollbackvector.push_back(rmwnode);
+                       rmwnode->addEdge(tonode);
+               }
        }
        rollbackvector.push_back(fromnode);