From 8bfca9bf950597e9967e62e02f7a5048e6cf4896 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 5 Oct 2012 17:03:01 -0700 Subject: [PATCH] cyclegraph: flag cycles for reflexive edges The cyclegraph shouldn't fail (i.e., ASSERT()) when reflexive edges are added; instead, they should be declared as cycles. --- cyclegraph.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cyclegraph.cc b/cyclegraph.cc index 2280e76..e1d5b3c 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -43,11 +43,14 @@ CycleNode * CycleGraph::getNode(const ModelAction *action) { void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) { ASSERT(from); ASSERT(to); - ASSERT(from != 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); @@ -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); - ASSERT(from != 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.. -- 2.34.1