projects
/
model-checker.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
promise: fix signed/unsigned warning
[model-checker.git]
/
cyclegraph.cc
diff --git
a/cyclegraph.cc
b/cyclegraph.cc
index 2280e76e3e208b8ac6ce6e2044433c1a866d2c85..33f8cda85cedacffdea92d344be05ddf4f4b10e4 100644
(file)
--- 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);
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,18
+116,22
@@
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..
hasCycles=checkReachable(rmwnode, fromnode);
}
if (!hasCycles) {
// With promises we could be setting up a cycle here if we aren't
// careful...avoid it..
hasCycles=checkReachable(rmwnode, fromnode);
}
- if(fromnode->addEdge(rmwnode))
+ if
(fromnode->addEdge(rmwnode))
rollbackvector.push_back(fromnode);
}
#if SUPPORT_MOD_ORDER_DUMP
void CycleGraph::dumpNodes(FILE *file) {
rollbackvector.push_back(fromnode);
}
#if SUPPORT_MOD_ORDER_DUMP
void CycleGraph::dumpNodes(FILE *file) {
-
for
(unsigned int i=0;i<nodeList.size();i++) {
+
for
(unsigned int i=0;i<nodeList.size();i++) {
CycleNode *cn=nodeList[i];
std::vector<CycleNode *> * edges=cn->getEdges();
const ModelAction *action=cn->getAction();
CycleNode *cn=nodeList[i];
std::vector<CycleNode *> * edges=cn->getEdges();
const ModelAction *action=cn->getAction();
@@
-133,22
+139,22
@@
void CycleGraph::dumpNodes(FILE *file) {
if (cn->getRMW()!=NULL) {
fprintf(file, "N%u -> N%u[style=dotted];\n", action->get_seq_number(), cn->getRMW()->getAction()->get_seq_number());
}
if (cn->getRMW()!=NULL) {
fprintf(file, "N%u -> N%u[style=dotted];\n", action->get_seq_number(), cn->getRMW()->getAction()->get_seq_number());
}
- for(unsigned int j=0;j<edges->size();j++) {
- CycleNode *dst=(*edges)[j];
+ for
(unsigned int j=0;j<edges->size();j++) {
+
CycleNode *dst=(*edges)[j];
const ModelAction *dstaction=dst->getAction();
const ModelAction *dstaction=dst->getAction();
- fprintf(file, "N%u -> N%u;\n", action->get_seq_number(), dstaction->get_seq_number());
- }
+
fprintf(file, "N%u -> N%u;\n", action->get_seq_number(), dstaction->get_seq_number());
+
}
}
}
void CycleGraph::dumpGraphToFile(const char *filename) {
char buffer[200];
}
}
void CycleGraph::dumpGraphToFile(const char *filename) {
char buffer[200];
- sprintf(buffer, "%s.dot",filename);
- FILE *file=fopen(buffer, "w");
- fprintf(file, "digraph %s {\n",filename);
+
sprintf(buffer, "%s.dot",filename);
+
FILE *file=fopen(buffer, "w");
+
fprintf(file, "digraph %s {\n",filename);
dumpNodes(file);
dumpNodes(file);
- fprintf(file,"}\n");
- fclose(file);
+
fprintf(file,"}\n");
+ fclose(file);
}
#endif
}
#endif