From: weiyu Date: Fri, 9 Aug 2019 01:45:42 +0000 (-0700) Subject: fix bug X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c22006fbddb0f954f658252f1c6dd336d069c77d;p=c11tester.git fix bug --- diff --git a/funcnode.cc b/funcnode.cc index 7adc5376..d60fbe1c 100644 --- a/funcnode.cc +++ b/funcnode.cc @@ -112,8 +112,8 @@ void FuncNode::update_tree(action_list_t * act_list) /* build inst_list from act_list for later processing */ func_inst_list_t inst_list; - func_inst_list_t read_inst_list; - HashTable read_val_map; + action_list_t read_act_list; + HashTable act_inst_map(128); for (sllnode * it = act_list->begin(); it != NULL; it = it->getNext()) { ModelAction * act = it->getVal(); @@ -128,13 +128,13 @@ void FuncNode::update_tree(action_list_t * act_list) // act->print(); if (func_inst->is_read()) { - read_inst_list.push_back(func_inst); - read_val_map.put(func_inst, act->get_reads_from_value()); + read_act_list.push_back(act); + act_inst_map.put(act, func_inst); } } update_inst_tree(&inst_list); - update_predicate_tree(&read_inst_list, &read_val_map); + update_predicate_tree(&read_act_list, &act_inst_map); } /** @@ -221,27 +221,32 @@ void FuncNode::clear_read_map(uint32_t tid) thrd_read_map[tid]->reset(); } -void FuncNode::update_predicate_tree(func_inst_list_t * inst_list, HashTable * read_val_map) +void FuncNode::update_predicate_tree(action_list_t * act_list, HashTable * act_inst_map) { - if (inst_list == NULL || inst_list->size() == 0) + if (act_list == NULL || act_list->size() == 0) return; + /* if (predicate_tree_initialized) { return; } predicate_tree_initialized = true; */ - HashTable loc_inst_map(128); /* map a FuncInst to the parent of its predicate */ HashTable inst_pred_map(128); + HashTable read_val_map(128); + HashTable loc_inst_map(128); - sllnode *it = inst_list->begin(); + sllnode *it = act_list->begin(); Predicate * curr_pred = predicate_tree_entry; while (it != NULL) { - FuncInst * curr_inst = it->getVal(); + ModelAction * curr_act = it->getVal(); + FuncInst * curr_inst = act_inst_map->get(curr_act); Predicate * old_pred = curr_pred; - bool branch_found = follow_branch(&curr_pred, curr_inst, read_val_map, &loc_inst_map); + read_val_map.put(curr_inst, curr_act->get_reads_from_value()); + + bool branch_found = follow_branch(&curr_pred, curr_inst, &read_val_map, &loc_inst_map); // check back edges if (!branch_found) { @@ -276,8 +281,8 @@ void FuncNode::update_predicate_tree(func_inst_list_t * inst_list, HashTableadd_parent(curr_pred); FuncInst * last_inst = loc_inst_map.get(curr_inst->get_location()); - uint64_t last_read = read_val_map->get(last_inst); - if ( last_read == read_val_map->get(curr_inst) ) + uint64_t last_read = read_val_map.get(last_inst); + if ( last_read == read_val_map.get(curr_inst) ) curr_pred = new_pred1; else curr_pred = new_pred2; @@ -325,7 +330,7 @@ bool FuncNode::follow_branch(Predicate ** curr_pred, FuncInst * next_inst, PredExprSetIter * pred_expr_it = pred_expressions->iterator(); while (pred_expr_it->hasNext()) { pred_expr * pred_expression = pred_expr_it->next(); - uint64_t last_read, curr_read; + uint64_t last_read, next_read; FuncInst * last_inst; bool equality; @@ -333,8 +338,9 @@ bool FuncNode::follow_branch(Predicate ** curr_pred, FuncInst * next_inst, case EQUALITY: last_inst = loc_inst_map->get(next_inst->get_location()); last_read = read_val_map->get(last_inst); - curr_read = read_val_map->get(next_inst); - equality = (last_read == curr_read); + next_read = read_val_map->get(next_inst); + equality = (last_read == next_read); + if (equality == pred_expression->value) { *curr_pred = branch; // model_print("predicate: token: %d, location: %p, value: %d - ", pred_expression->token, pred_expression->location, pred_expression->value); next_inst->print(); diff --git a/funcnode.h b/funcnode.h index bfb3fac7..62a3bc50 100644 --- a/funcnode.h +++ b/funcnode.h @@ -36,7 +36,7 @@ public: void clear_read_map(uint32_t tid); /* TODO: generate EQUALITY or NULLITY predicate based on write_history in history.cc */ - void update_predicate_tree(func_inst_list_t * inst_list, HashTable * read_val_map); + void update_predicate_tree(action_list_t * act_list, HashTable * act_inst_map); bool follow_branch(Predicate ** curr_pred, FuncInst * next_inst, HashTable * read_val_map, HashTable* loc_inst_map); void print_predicate_tree();