check_recency: only allow newer stores to "overwrite"
[model-checker.git] / model.cc
index 4ae69665e4b84e3b04c2e852a120e85271c9c3c0..36c23bf1c17e6a56e73ab62001344aa630c32122 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -1663,20 +1663,14 @@ void ModelChecker::check_recency(ModelAction *curr, const ModelAction *rf)
         * accidentally clear by rolling back */
        if (is_infeasible())
                return;
+
        std::vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
        int tid = id_to_int(curr->get_tid());
-
-       //NOTE: this check seems left over from previous approach that added action to list late in the game...should be safe to remove
-       /* Skip checks */
-       if ((int)thrd_lists->size() <= tid)
-               return;
+       ASSERT(tid < (int)thrd_lists->size());
        action_list_t *list = &(*thrd_lists)[tid];
-
        action_list_t::reverse_iterator rit = list->rbegin();
+       ASSERT((*rit) == curr);
        /* Skip past curr */
-       for (; (*rit) != curr; rit++)
-               ;
-       /* go past curr now */
        rit++;
 
        action_list_t::reverse_iterator ritcopy = rit;
@@ -1700,27 +1694,17 @@ void ModelChecker::check_recency(ModelAction *curr, const ModelAction *rf)
                if (write == rf)
                        continue;
 
-               //NOTE: SHOULD MAKE SURE write is MOd after rf
-
-               /* Test to see whether this is a feasible write to read from */
-               /** NOTE: all members of read-from set should be
-                *  feasible, so we no longer check it here **/
+               /* Only look for "newer" writes */
+               if (!mo_graph->checkReachable(rf, write))
+                       continue;
 
                ritcopy = rit;
 
                bool feasiblewrite = true;
                /* now we need to see if this write works for everyone */
-
                for (int loop = params.maxreads; loop > 0; loop--, ritcopy++) {
                        ModelAction *act = *ritcopy;
-                       bool foundvalue = false;
-                       for (int j = 0; j < act->get_node()->get_read_from_past_size(); j++) {
-                               if (act->get_node()->get_read_from_past(j) == write) {
-                                       foundvalue = true;
-                                       break;
-                               }
-                       }
-                       if (!foundvalue) {
+                       if (!act->may_read_from(write)) {
                                feasiblewrite = false;
                                break;
                        }