+/**
+ * Updates the cyclegraph with the constraints imposed from the current read.
+ * @param curr The current action. Must be a read.
+ * @param rf The action that curr reads from. Must be a write.
+ */
+void ModelChecker::r_modification_order(ModelAction * curr, const ModelAction *rf) {
+ std::vector<action_list_t> *thrd_lists = &(*obj_thrd_map)[curr->get_location()];
+ unsigned int i;
+ ASSERT(curr->is_read());
+
+ /* Iterate over all threads */
+ for (i = 0; i < thrd_lists->size(); i++) {
+ /* Iterate over actions in thread, starting from most recent */
+ action_list_t *list = &(*thrd_lists)[i];
+ action_list_t::reverse_iterator rit;
+ for (rit = list->rbegin(); rit != list->rend(); rit++) {
+ ModelAction *act = *rit;
+
+ /* Include at most one act per-thread that "happens before" curr */
+ if (act->happens_before(curr)) {
+ if (act->is_read()) {
+ const ModelAction * prevreadfrom=act->get_reads_from();
+ if (rf!=prevreadfrom)
+ cyclegraph->addEdge(rf, prevreadfrom);
+ } else if (rf!=act) {
+ cyclegraph->addEdge(rf, act);
+ }
+ break;
+ }
+ }
+ }
+}
+
+/**
+ * Updates the cyclegraph with the constraints imposed from the current write.
+ * @param curr The current action. Must be a write.
+ */
+void ModelChecker::w_modification_order(ModelAction * curr) {
+ std::vector<action_list_t> *thrd_lists = &(*obj_thrd_map)[curr->get_location()];
+ unsigned int i;
+ ASSERT(curr->is_write());
+
+ if (curr->is_seqcst()) {
+ /* We have to at least see the last sequentially consistent write,
+ so we are initialized. */
+ ModelAction * last_seq_cst=get_last_seq_cst(curr->get_location());
+ if (last_seq_cst!=NULL)
+ cyclegraph->addEdge(curr, last_seq_cst);
+ }
+
+ /* Iterate over all threads */
+ for (i = 0; i < thrd_lists->size(); i++) {
+ /* Iterate over actions in thread, starting from most recent */
+ action_list_t *list = &(*thrd_lists)[i];
+ action_list_t::reverse_iterator rit;
+ for (rit = list->rbegin(); rit != list->rend(); rit++) {
+ ModelAction *act = *rit;
+
+ /* Include at most one act per-thread that "happens before" curr */
+ if (act->happens_before(curr)) {
+ if (act->is_read()) {
+ cyclegraph->addEdge(curr, act->get_reads_from());
+ } else
+ cyclegraph->addEdge(curr, act);
+ break;
+ }
+ }
+ }
+}
+
+/**
+ * Performs various bookkeeping operations for the current ModelAction. For
+ * instance, adds action to the per-object, per-thread action vector and to the
+ * action trace list of all thread actions.
+ *
+ * @param act is the ModelAction to add.
+ */
+void ModelChecker::add_action_to_lists(ModelAction *act)