inst_list.push_back(func_inst);
- if (func_inst->is_write())
+ /* NOTE: for rmw actions, func_inst and act may have different
+ * action types because of action type conversion in ModelExecution
+ * func_inst->is_write() <==> pure writes (excluding rmw) */
+ if (func_inst->is_write()) {
+ // model_print("write detected\n");
rw_act_list.push_back(act);
+ }
+ /* func_inst->is_read() <==> read + rmw */
if (func_inst->is_read()) {
rw_act_list.push_back(act);
/* If func_inst may only read_from a single location, then:
*
- * The first time an action reads from some location, import all the values that have
- * been written to this location from ModelHistory and notify ModelHistory that this
- * FuncNode may read from this location.
+ * The first time an action reads from some location,
+ * import all the values that have been written to this
+ * location from ModelHistory and notify ModelHistory
+ * that this FuncNode may read from this location.
*/
void * loc = act->get_location();
if (!read_locations->contains(loc) && func_inst->is_single_location()) {
continue;
}
+ if (next_act->is_write())
+ curr_pred->set_write(true);
+
inst_pred_map.put(next_inst, curr_pred);
if (!inst_id_map.contains(next_inst))
inst_id_map.put(next_inst, inst_counter++);
PredExprSet * pred_expressions = branch->get_pred_expressions();
PredExprSetIter * pred_expr_it = pred_expressions->iterator();
+ /* Only read and rmw actions my have unset predicate expressions */
if (pred_expressions->getSize() == 0) {
predicate_correct = false;
unset_predicates->push_back(branch);
return branch_found;
}
+/* Infer predicate expressions, which are generated in FuncNode::generate_predicates */
void FuncNode::infer_predicates(FuncInst * next_inst, ModelAction * next_act,
HashTable<void *, ModelAction *, uintptr_t, 0> * loc_act_map,
SnapVector<struct half_pred_expr *> * half_pred_expressions)
void * loc = next_act->get_location();
if (next_inst->is_read()) {
+ /* read + rmw */
if ( loc_act_map->contains(loc) ) {
ModelAction * last_act = loc_act_map->get(loc);
FuncInst * last_inst = get_inst(last_act);
}
}
} else {
- // TODO: when next_act is a write action, do anything?
+ /* Pure writes */
+ // TODO: do anything here?
}
}
(*curr_pred)->add_child(new_pred);
new_pred->set_parent(*curr_pred);
- /* entry predicates and predicates containing write actions
+ /* entry predicates and predicates containing pure write actions
* have no predicate expressions */
if ( (*curr_pred)->is_entry_predicate() )
new_pred->add_predicate_expr(NOPREDICATE, NULL, true);
- else if (next_inst->is_write())
+ else if (next_inst->is_write()) {
+ /* next_inst->is_write() <==> pure writes */
new_pred->add_predicate_expr(NOPREDICATE, NULL, true);
+ }
return;
}
}
}
+/* Every time a thread enters a function, set its position to the predicate tree entry */
void FuncNode::init_predicate_tree_position(thread_id_t tid)
{
int thread_id = id_to_int(tid);
predicate_tree_position[thread_id] = pred;
}
+/* @return The position of a thread in a predicate tree */
Predicate * FuncNode::get_predicate_tree_position(thread_id_t tid)
{
int thread_id = id_to_int(tid);
return predicate_tree_position[thread_id];
}
+/* Make sure elements of thrd_inst_act_map are initialized properly when threads enter functions */
void FuncNode::init_inst_act_map(thread_id_t tid)
{
int thread_id = id_to_int(tid);
}
}
+/* Reset elements of thrd_inst_act_map when threads exit functions */
void FuncNode::reset_inst_act_map(thread_id_t tid)
{
int thread_id = id_to_int(tid);
void update_tree(action_list_t * act_list);
void update_inst_tree(func_inst_list_t * inst_list);
-
void update_predicate_tree(action_list_t * act_list);
bool follow_branch(Predicate ** curr_pred, FuncInst * next_inst, ModelAction * next_act, HashTable<FuncInst *, ModelAction *, uintptr_t, 0> * inst_act_map, SnapVector<Predicate *> * unset_predicates);
- void infer_predicates(FuncInst * next_inst, ModelAction * next_act, HashTable<void *, ModelAction *, uintptr_t, 0> * loc_act_map, SnapVector<struct half_pred_expr *> * half_pred_expressions);
- void generate_predicates(Predicate ** curr_pred, FuncInst * next_inst, SnapVector<struct half_pred_expr *> * half_pred_expressions);
- bool amend_predicate_expr(Predicate ** curr_pred, FuncInst * next_inst, ModelAction * next_act);
void incr_exit_count() { exit_count++; }
uint32_t get_exit_count() { return exit_count; }
/* Possible entry atomic actions in this function */
func_inst_list_mt entry_insts;
+ void infer_predicates(FuncInst * next_inst, ModelAction * next_act, HashTable<void *, ModelAction *, uintptr_t, 0> * loc_act_map, SnapVector<struct half_pred_expr *> * half_pred_expressions);
+ void generate_predicates(Predicate ** curr_pred, FuncInst * next_inst, SnapVector<struct half_pred_expr *> * half_pred_expressions);
+ bool amend_predicate_expr(Predicate ** curr_pred, FuncInst * next_inst, ModelAction * next_act);
+
/* Store action_lists when calls to update_tree are deferred */
ModelList<action_list_t *> action_list_buffer;
/* read_locations: set of locations read by this FuncNode
* val_loc_map: keep track of locations that have the same values written to;
- * loc_may_equal_map: deduced from val_loc_map;
- */
+ * loc_may_equal_map: look up locations that may share the same value as key;
+ * deduced from val_loc_map; */
loc_set_t * read_locations;
HashTable<uint64_t, loc_set_t *, uint64_t, 0> * val_loc_map;
HashTable<void *, loc_set_t *, uintptr_t, 0> * loc_may_equal_map;
// value_set_t * values_may_read_from;
- /* run-time position in the predicate tree for each thread */
+ /* Run-time position in the predicate tree for each thread */
ModelVector<Predicate *> predicate_tree_position;
+ /* A run-time map from FuncInst to ModelAction for each thread; needed by NewFuzzer */
SnapVector<inst_act_map_t *> * thrd_inst_act_map;
};
bool is_entry_predicate() { return entry_predicate; }
void set_entry_predicate() { entry_predicate = true; }
+ /* Whether func_inst does write or not */
+ bool is_write() { return does_write; }
+ void set_write(bool is_write) { does_write = is_write; }
+
void print_predicate();
void print_pred_subtree();
private:
FuncInst * func_inst;
bool entry_predicate;
+ bool does_write;
- /* may have multiple predicate expressions */
+ /* May have multiple predicate expressions */
PredExprSet pred_expressions;
ModelVector<Predicate *> children;
- /* only a single parent may exist */
+ /* Only a single parent may exist */
Predicate * parent;
- /* may have multiple back edges, e.g. nested loops */
+ /* May have multiple back edges, e.g. nested loops */
PredSet backedges;
};