Little adjustment
[c11tester.git] / funcnode.cc
1 #include "action.h"
2 #include "history.h"
3 #include "funcnode.h"
4 #include "funcinst.h"
5 #include "predicate.h"
6 #include "concretepredicate.h"
7
8 #include "model.h"
9
10 FuncNode::FuncNode(ModelHistory * history) :
11         history(history),
12         exit_count(0),
13         marker(1),
14         func_inst_map(),
15         inst_list(),
16         entry_insts(),
17         predicate_tree_position(),
18         edge_table(32),
19         out_edges()
20 {
21         predicate_tree_entry = new Predicate(NULL, true);
22         predicate_tree_entry->add_predicate_expr(NOPREDICATE, NULL, true);
23         predicate_tree_exit = new Predicate(NULL, false, true);
24
25         // Memories that are reclaimed after each execution
26         action_list_buffer = new SnapList<action_list_t *>();
27         read_locations = new loc_set_t();
28         write_locations = new loc_set_t();
29         val_loc_map = new HashTable<uint64_t, loc_set_t *, uint64_t, 0>();
30         loc_may_equal_map = new HashTable<void *, loc_set_t *, uintptr_t, 0>();
31
32         //values_may_read_from = new value_set_t();
33 }
34
35 /* Reallocate snapshotted memories when new executions start */
36 void FuncNode::set_new_exec_flag()
37 {
38         action_list_buffer = new SnapList<action_list_t *>();
39         read_locations = new loc_set_t();
40         write_locations = new loc_set_t();
41         val_loc_map = new HashTable<uint64_t, loc_set_t *, uint64_t, 0>();
42         loc_may_equal_map = new HashTable<void *, loc_set_t *, uintptr_t, 0>();
43
44         //values_may_read_from = new value_set_t();
45 }
46
47 /* Check whether FuncInst with the same type, position, and location
48  * as act has been added to func_inst_map or not. If not, add it.
49  *
50  * Note: currently, actions with the same position are filtered out by process_action,
51  * so the collision list of FuncInst is not used. May remove it later. 
52  */
53 void FuncNode::add_inst(ModelAction *act)
54 {
55         ASSERT(act);
56         const char * position = act->get_position();
57
58         /* THREAD* actions, ATOMIC_LOCK, ATOMIC_TRYLOCK, and ATOMIC_UNLOCK
59          * actions are not tagged with their source line numbers
60          */
61         if (position == NULL)
62                 return;
63
64         if ( func_inst_map.contains(position) ) {
65                 FuncInst * inst = func_inst_map.get(position);
66
67                 ASSERT(inst->get_type() == act->get_type());
68                 int curr_execution_number = model->get_execution_number();
69
70                 /* Reset locations when new executions start */
71                 if (inst->get_execution_number() != curr_execution_number) {
72                         inst->set_location(act->get_location());
73                         inst->set_execution_number(curr_execution_number);
74                 }
75
76                 if (inst->get_location() != act->get_location())
77                         inst->not_single_location();
78
79                 return;
80         }
81
82         FuncInst * func_inst = new FuncInst(act, this);
83
84         func_inst_map.put(position, func_inst);
85         inst_list.push_back(func_inst);
86 }
87
88 /* Get the FuncInst with the same type, position, and location
89  * as act
90  *
91  * @return FuncInst with the same type, position, and location as act */
92 FuncInst * FuncNode::get_inst(ModelAction *act)
93 {
94         ASSERT(act);
95         const char * position = act->get_position();
96
97         /* THREAD* actions, ATOMIC_LOCK, ATOMIC_TRYLOCK, and ATOMIC_UNLOCK
98          * actions are not tagged with their source line numbers
99          */
100         if (position == NULL)
101                 return NULL;
102
103         FuncInst * inst = func_inst_map.get(position);
104         if (inst == NULL)
105                 return NULL;
106
107         action_type inst_type = inst->get_type();
108         action_type act_type = act->get_type();
109
110         // else if branch: an RMWRCAS action is converted to a RMW or READ action
111         if (inst_type == act_type)
112                 return inst;
113         else if (inst_type == ATOMIC_RMWRCAS &&
114                         (act_type == ATOMIC_RMW || act_type == ATOMIC_READ))
115                 return inst;
116
117         return NULL;
118 }
119
120
121 void FuncNode::add_entry_inst(FuncInst * inst)
122 {
123         if (inst == NULL)
124                 return;
125
126         mllnode<FuncInst *> * it;
127         for (it = entry_insts.begin(); it != NULL; it = it->getNext()) {
128                 if (inst == it->getVal())
129                         return;
130         }
131
132         entry_insts.push_back(inst);
133 }
134
135 /**
136  * @brief Convert ModelAdtion list to FuncInst list 
137  * @param act_list A list of ModelActions
138  */
139 void FuncNode::update_tree(action_list_t * act_list)
140 {
141         if (act_list == NULL || act_list->size() == 0)
142                 return;
143
144         HashTable<void *, value_set_t *, uintptr_t, 0> * write_history = history->getWriteHistory();
145
146         /* build inst_list from act_list for later processing */
147         func_inst_list_t inst_list;
148         action_list_t rw_act_list;
149
150         for (sllnode<ModelAction *> * it = act_list->begin(); it != NULL; it = it->getNext()) {
151                 ModelAction * act = it->getVal();
152                 FuncInst * func_inst = get_inst(act);
153                 void * loc = act->get_location();
154
155                 if (func_inst == NULL)
156                         continue;
157
158                 inst_list.push_back(func_inst);
159                 bool act_added = false;
160
161                 if (act->is_write()) {
162                         rw_act_list.push_back(act);
163                         act_added = true;
164                         if (!write_locations->contains(loc)) {
165                                 write_locations->add(loc);
166                                 history->update_loc_wr_func_nodes_map(loc, this);
167                         }
168                 }
169
170                 if (act->is_read()) {
171                         if (!act_added)
172                                 rw_act_list.push_back(act);
173
174                         /* If func_inst may only read_from a single location, then:
175                          *
176                          * The first time an action reads from some location,
177                          * import all the values that have been written to this
178                          * location from ModelHistory and notify ModelHistory
179                          * that this FuncNode may read from this location.
180                          */
181                         if (!read_locations->contains(loc) && func_inst->is_single_location()) {
182                                 read_locations->add(loc);
183                                 value_set_t * write_values = write_history->get(loc);
184                                 add_to_val_loc_map(write_values, loc);
185                                 history->update_loc_rd_func_nodes_map(loc, this);
186                         }
187                 }
188         }
189
190 //      model_print("function %s\n", func_name);
191 //      print_val_loc_map();
192
193         update_inst_tree(&inst_list);
194         update_predicate_tree(&rw_act_list);
195
196 //      print_predicate_tree();
197 }
198
199 /** 
200  * @brief Link FuncInsts in inst_list  - add one FuncInst to another's predecessors and successors
201  * @param inst_list A list of FuncInsts
202  */
203 void FuncNode::update_inst_tree(func_inst_list_t * inst_list)
204 {
205         if (inst_list == NULL)
206                 return;
207         else if (inst_list->size() == 0)
208                 return;
209
210         /* start linking */
211         sllnode<FuncInst *>* it = inst_list->begin();
212         sllnode<FuncInst *>* prev;
213
214         /* add the first instruction to the list of entry insts */
215         FuncInst * entry_inst = it->getVal();
216         add_entry_inst(entry_inst);
217
218         it = it->getNext();
219         while (it != NULL) {
220                 prev = it->getPrev();
221
222                 FuncInst * prev_inst = prev->getVal();
223                 FuncInst * curr_inst = it->getVal();
224
225                 prev_inst->add_succ(curr_inst);
226                 curr_inst->add_pred(prev_inst);
227
228                 it = it->getNext();
229         }
230 }
231
232 void FuncNode::update_predicate_tree(action_list_t * act_list)
233 {
234         if (act_list == NULL || act_list->size() == 0)
235                 return;
236
237         incr_marker();
238
239         /* Map a FuncInst to the its predicate */
240         HashTable<FuncInst *, Predicate *, uintptr_t, 0> inst_pred_map(128);
241
242         // Number FuncInsts to detect loops
243         HashTable<FuncInst *, uint32_t, uintptr_t, 0> inst_id_map(128);
244         uint32_t inst_counter = 0;
245
246         /* Only need to store the locations of read actions */
247         HashTable<void *, ModelAction *, uintptr_t, 0> loc_act_map(128);
248
249         sllnode<ModelAction *> *it = act_list->begin();
250         Predicate * curr_pred = predicate_tree_entry;
251         while (it != NULL) {
252                 ModelAction * next_act = it->getVal();
253                 FuncInst * next_inst = get_inst(next_act);
254                 next_inst->set_associated_act(next_act, marker);
255
256                 SnapVector<Predicate *> unset_predicates = SnapVector<Predicate *>();
257                 bool branch_found = follow_branch(&curr_pred, next_inst, next_act, &unset_predicates);
258
259                 // A branch with unset predicate expression is detected
260                 if (!branch_found && unset_predicates.size() != 0) {
261                         ASSERT(unset_predicates.size() == 1);
262                         Predicate * one_branch = unset_predicates[0];
263
264                         bool amended = amend_predicate_expr(&curr_pred, next_inst, next_act);
265                         if (amended)
266                                 continue;
267                         else {
268                                 curr_pred = one_branch;
269                                 branch_found = true;
270                         }
271                 }
272
273                 // Detect loops
274                 if (!branch_found && inst_id_map.contains(next_inst)) {
275                         FuncInst * curr_inst = curr_pred->get_func_inst();
276                         uint32_t curr_id = inst_id_map.get(curr_inst);
277                         uint32_t next_id = inst_id_map.get(next_inst);
278
279                         if (curr_id >= next_id) {
280                                 Predicate * old_pred = inst_pred_map.get(next_inst);
281                                 Predicate * back_pred = old_pred->get_parent();
282
283                                 curr_pred->add_backedge(back_pred);
284                                 curr_pred = back_pred;
285                                 continue;
286                         }
287                 }
288
289                 // Generate new branches
290                 if (!branch_found) {
291                         SnapVector<struct half_pred_expr *> half_pred_expressions;
292                         infer_predicates(next_inst, next_act, &loc_act_map, &half_pred_expressions);
293                         generate_predicates(&curr_pred, next_inst, &half_pred_expressions);
294                         continue;
295                 }
296
297                 if (next_act->is_write())
298                         curr_pred->set_write(true);
299
300                 if (next_act->is_read()) {
301                         loc_act_map.put(next_act->get_location(), next_act);
302                 }
303
304                 inst_pred_map.put(next_inst, curr_pred);
305                 if (!inst_id_map.contains(next_inst))
306                         inst_id_map.put(next_inst, inst_counter++);
307
308                 it = it->getNext();
309                 curr_pred->incr_expl_count();
310         }
311
312         curr_pred->set_exit(predicate_tree_exit);
313 }
314
315 /* Given curr_pred and next_inst, find the branch following curr_pred that
316  * contains next_inst and the correct predicate. 
317  * @return true if branch found, false otherwise.
318  */
319 bool FuncNode::follow_branch(Predicate ** curr_pred, FuncInst * next_inst,
320         ModelAction * next_act, SnapVector<Predicate *> * unset_predicates)
321 {
322         /* Check if a branch with func_inst and corresponding predicate exists */
323         bool branch_found = false;
324         ModelVector<Predicate *> * branches = (*curr_pred)->get_children();
325         for (uint i = 0; i < branches->size(); i++) {
326                 Predicate * branch = (*branches)[i];
327                 if (branch->get_func_inst() != next_inst)
328                         continue;
329
330                 /* Check against predicate expressions */
331                 bool predicate_correct = true;
332                 PredExprSet * pred_expressions = branch->get_pred_expressions();
333                 PredExprSetIter * pred_expr_it = pred_expressions->iterator();
334
335                 /* Only read and rmw actions my have unset predicate expressions */
336                 if (pred_expressions->getSize() == 0) {
337                         predicate_correct = false;
338                         unset_predicates->push_back(branch);
339                 }
340
341                 while (pred_expr_it->hasNext()) {
342                         pred_expr * pred_expression = pred_expr_it->next();
343                         uint64_t last_read, next_read;
344                         bool equality;
345
346                         switch(pred_expression->token) {
347                                 case NOPREDICATE:
348                                         predicate_correct = true;
349                                         break;
350                                 case EQUALITY:
351                                         FuncInst * to_be_compared;
352                                         ModelAction * last_act;
353
354                                         to_be_compared = pred_expression->func_inst;
355                                         last_act = to_be_compared->get_associated_act(marker);
356
357                                         last_read = last_act->get_reads_from_value();
358                                         next_read = next_act->get_reads_from_value();
359                                         equality = (last_read == next_read);
360                                         if (equality != pred_expression->value)
361                                                 predicate_correct = false;
362
363                                         break;
364                                 case NULLITY:
365                                         next_read = next_act->get_reads_from_value();
366                                         equality = ((void*)next_read == NULL);
367                                         if (equality != pred_expression->value)
368                                                 predicate_correct = false;
369                                         break;
370                                 default:
371                                         predicate_correct = false;
372                                         model_print("unkown predicate token\n");
373                                         break;
374                         }
375                 }
376
377                 if (predicate_correct) {
378                         *curr_pred = branch;
379                         branch_found = true;
380                         break;
381                 }
382         }
383
384         return branch_found;
385 }
386
387 /* Infer predicate expressions, which are generated in FuncNode::generate_predicates */
388 void FuncNode::infer_predicates(FuncInst * next_inst, ModelAction * next_act,
389         HashTable<void *, ModelAction *, uintptr_t, 0> * loc_act_map,
390         SnapVector<struct half_pred_expr *> * half_pred_expressions)
391 {
392         void * loc = next_act->get_location();
393
394         if (next_inst->is_read()) {
395                 /* read + rmw */
396                 if ( loc_act_map->contains(loc) ) {
397                         ModelAction * last_act = loc_act_map->get(loc);
398                         FuncInst * last_inst = get_inst(last_act);
399                         struct half_pred_expr * expression = new half_pred_expr(EQUALITY, last_inst);
400                         half_pred_expressions->push_back(expression);
401                 } else if ( next_inst->is_single_location() ){
402                         loc_set_t * loc_may_equal = loc_may_equal_map->get(loc);
403
404                         if (loc_may_equal != NULL) {
405                                 loc_set_iter * loc_it = loc_may_equal->iterator();
406                                 while (loc_it->hasNext()) {
407                                         void * neighbor = loc_it->next();
408                                         if (loc_act_map->contains(neighbor)) {
409                                                 ModelAction * last_act = loc_act_map->get(neighbor);
410                                                 FuncInst * last_inst = get_inst(last_act);
411
412                                                 struct half_pred_expr * expression = new half_pred_expr(EQUALITY, last_inst);
413                                                 half_pred_expressions->push_back(expression);
414                                         }
415                                 }
416                         }
417                 } else {
418                         // next_inst is not single location
419                         uint64_t read_val = next_act->get_reads_from_value();
420
421                         // only infer NULLITY predicate when it is actually NULL.
422                         if ( (void*)read_val == NULL) {
423                                 struct half_pred_expr * expression = new half_pred_expr(NULLITY, NULL);
424                                 half_pred_expressions->push_back(expression);
425                         }
426                 }
427         } else {
428                 /* Pure writes */
429                 // TODO: do anything here?
430         }
431 }
432
433 /* Able to generate complex predicates when there are multiple predciate expressions */
434 void FuncNode::generate_predicates(Predicate ** curr_pred, FuncInst * next_inst,
435         SnapVector<struct half_pred_expr *> * half_pred_expressions)
436 {
437         if (half_pred_expressions->size() == 0) {
438                 Predicate * new_pred = new Predicate(next_inst);
439                 (*curr_pred)->add_child(new_pred);
440                 new_pred->set_parent(*curr_pred);
441
442                 /* entry predicates and predicates containing pure write actions
443                  * have no predicate expressions */
444                 if ( (*curr_pred)->is_entry_predicate() )
445                         new_pred->add_predicate_expr(NOPREDICATE, NULL, true);
446                 else if (next_inst->is_write()) {
447                         /* next_inst->is_write() <==> pure writes */
448                         new_pred->add_predicate_expr(NOPREDICATE, NULL, true);
449                 }
450
451                 return;
452         }
453
454         SnapVector<Predicate *> predicates;
455
456         struct half_pred_expr * half_expr = (*half_pred_expressions)[0];
457         predicates.push_back(new Predicate(next_inst));
458         predicates.push_back(new Predicate(next_inst));
459
460         predicates[0]->add_predicate_expr(half_expr->token, half_expr->func_inst, true);
461         predicates[1]->add_predicate_expr(half_expr->token, half_expr->func_inst, false);
462
463         for (uint i = 1; i < half_pred_expressions->size(); i++) {
464                 half_expr = (*half_pred_expressions)[i];
465
466                 uint old_size = predicates.size();
467                 for (uint j = 0; j < old_size; j++) {
468                         Predicate * pred = predicates[j];
469                         Predicate * new_pred = new Predicate(next_inst);
470                         new_pred->copy_predicate_expr(pred);
471
472                         pred->add_predicate_expr(half_expr->token, half_expr->func_inst, true);
473                         new_pred->add_predicate_expr(half_expr->token, half_expr->func_inst, false);
474
475                         predicates.push_back(new_pred);
476                 }
477         }
478
479         for (uint i = 0; i < predicates.size(); i++) {
480                 Predicate * pred= predicates[i];
481                 (*curr_pred)->add_child(pred);
482                 pred->set_parent(*curr_pred);
483         }
484
485         /* Free memories allocated by infer_predicate */
486         for (uint i = 0; i < half_pred_expressions->size(); i++) {
487                 struct half_pred_expr * tmp = (*half_pred_expressions)[i];
488                 snapshot_free(tmp);
489         }
490 }
491
492 /* Amend predicates that contain no predicate expressions. Currenlty only amend with NULLITY predicates */
493 bool FuncNode::amend_predicate_expr(Predicate ** curr_pred, FuncInst * next_inst, ModelAction * next_act)
494 {
495         // there should only be only child
496         Predicate * unset_pred = (*curr_pred)->get_children()->back();
497         uint64_t read_val = next_act->get_reads_from_value();
498
499         // only generate NULLITY predicate when it is actually NULL.
500         if ( !next_inst->is_single_location() && (void*)read_val == NULL ) {
501                 Predicate * new_pred = new Predicate(next_inst);
502
503                 (*curr_pred)->add_child(new_pred);
504                 new_pred->set_parent(*curr_pred);
505
506                 unset_pred->add_predicate_expr(NULLITY, NULL, false);
507                 new_pred->add_predicate_expr(NULLITY, NULL, true);
508
509                 return true;
510         }
511
512         return false;
513 }
514
515 void FuncNode::add_to_val_loc_map(uint64_t val, void * loc)
516 {
517         loc_set_t * locations = val_loc_map->get(val);
518
519         if (locations == NULL) {
520                 locations = new loc_set_t();
521                 val_loc_map->put(val, locations);
522         }
523
524         update_loc_may_equal_map(loc, locations);
525         locations->add(loc);
526         // values_may_read_from->add(val);
527 }
528
529 void FuncNode::add_to_val_loc_map(value_set_t * values, void * loc)
530 {
531         if (values == NULL)
532                 return;
533
534         value_set_iter * it = values->iterator();
535         while (it->hasNext()) {
536                 uint64_t val = it->next();
537                 add_to_val_loc_map(val, loc);
538         }
539 }
540
541 void FuncNode::update_loc_may_equal_map(void * new_loc, loc_set_t * old_locations)
542 {
543         if ( old_locations->contains(new_loc) )
544                 return;
545
546         loc_set_t * neighbors = loc_may_equal_map->get(new_loc);
547
548         if (neighbors == NULL) {
549                 neighbors = new loc_set_t();
550                 loc_may_equal_map->put(new_loc, neighbors);
551         }
552
553         loc_set_iter * loc_it = old_locations->iterator();
554         while (loc_it->hasNext()) {
555                 // new_loc: { old_locations, ... }
556                 void * member = loc_it->next();
557                 neighbors->add(member);
558
559                 // for each i in old_locations, i : { new_loc, ... }
560                 loc_set_t * _neighbors = loc_may_equal_map->get(member);
561                 if (_neighbors == NULL) {
562                         _neighbors = new loc_set_t();
563                         loc_may_equal_map->put(member, _neighbors);
564                 }
565                 _neighbors->add(new_loc);
566         }
567 }
568
569 /* Every time a thread enters a function, set its position to the predicate tree entry */
570 void FuncNode::init_predicate_tree_position(thread_id_t tid)
571 {
572         int thread_id = id_to_int(tid);
573         if (predicate_tree_position.size() <= (uint) thread_id)
574                 predicate_tree_position.resize(thread_id + 1);
575
576         predicate_tree_position[thread_id] = predicate_tree_entry;
577 }
578
579 void FuncNode::set_predicate_tree_position(thread_id_t tid, Predicate * pred)
580 {
581         int thread_id = id_to_int(tid);
582         predicate_tree_position[thread_id] = pred;
583 }
584
585 /* @return The position of a thread in a predicate tree */
586 Predicate * FuncNode::get_predicate_tree_position(thread_id_t tid)
587 {
588         int thread_id = id_to_int(tid);
589         return predicate_tree_position[thread_id];
590 }
591
592 /* Make sure elements of thrd_inst_act_map are initialized properly when threads enter functions */
593 void FuncNode::init_inst_act_map(thread_id_t tid)
594 {
595         int thread_id = id_to_int(tid);
596         SnapVector<inst_act_map_t *> * thrd_inst_act_map = history->getThrdInstActMap(func_id);
597         uint old_size = thrd_inst_act_map->size();
598
599         if (thrd_inst_act_map->size() <= (uint) thread_id) {
600                 uint new_size = thread_id + 1;
601                 thrd_inst_act_map->resize(new_size);
602
603                 for (uint i = old_size; i < new_size; i++)
604                         (*thrd_inst_act_map)[i] = new inst_act_map_t(128);
605         }
606 }
607
608 /* Reset elements of thrd_inst_act_map when threads exit functions */
609 void FuncNode::reset_inst_act_map(thread_id_t tid)
610 {
611         int thread_id = id_to_int(tid);
612         SnapVector<inst_act_map_t *> * thrd_inst_act_map = history->getThrdInstActMap(func_id);
613
614         inst_act_map_t * map = (*thrd_inst_act_map)[thread_id];
615         map->reset();
616 }
617
618 void FuncNode::update_inst_act_map(thread_id_t tid, ModelAction * read_act)
619 {
620         int thread_id = id_to_int(tid);
621         SnapVector<inst_act_map_t *> * thrd_inst_act_map = history->getThrdInstActMap(func_id);
622
623         inst_act_map_t * map = (*thrd_inst_act_map)[thread_id];
624         FuncInst * read_inst = get_inst(read_act);
625         map->put(read_inst, read_act);
626 }
627
628 inst_act_map_t * FuncNode::get_inst_act_map(thread_id_t tid)
629 {
630         int thread_id = id_to_int(tid);
631         SnapVector<inst_act_map_t *> * thrd_inst_act_map = history->getThrdInstActMap(func_id);
632
633         return (*thrd_inst_act_map)[thread_id];
634 }
635
636 /* Add FuncNodes that this node may follow */
637 void FuncNode::add_out_edge(FuncNode * other)
638 {
639         if ( !edge_table.contains(other) ) {
640                 edge_table.put(other, OUT_EDGE);
641                 out_edges.push_back(other);
642                 return;
643         }
644
645         edge_type_t edge = edge_table.get(other);
646         if (edge == IN_EDGE) {
647                 edge_table.put(other, BI_EDGE);
648                 out_edges.push_back(other);
649         }
650 }
651
652 /* Compute the distance between this FuncNode and the target node.
653  * Return -1 if the target node is unreachable or the actual distance
654  * is greater than max_step.
655  */
656 int FuncNode::compute_distance(FuncNode * target, int max_step)
657 {
658         if (target == NULL)
659                 return -1;
660         else if (target == this)
661                 return 0;
662
663         SnapList<FuncNode *> queue;
664         HashTable<FuncNode *, int, uintptr_t, 0> distances(128);
665
666         queue.push_back(this);
667         distances.put(this, 0);
668
669         while (!queue.empty()) {
670                 FuncNode * curr = queue.front();
671                 queue.pop_front();
672                 int dist = distances.get(curr);
673
674                 if (max_step <= dist)
675                         return -1;
676
677                 ModelList<FuncNode *> * outEdges = curr->get_out_edges();
678                 mllnode<FuncNode *> * it;
679                 for (it = outEdges->begin(); it != NULL; it = it->getNext()) {
680                         FuncNode * out_node = it->getVal();
681
682                         /* This node has not been visited before */
683                         if ( !distances.contains(out_node) ) {
684                                 if (out_node == target)
685                                         return dist + 1;
686
687                                 queue.push_back(out_node);
688                                 distances.put(out_node, dist + 1);
689                         }
690                 }
691         }
692
693         /* Target node is unreachable */
694         return -1;
695 }
696
697 void FuncNode::print_predicate_tree()
698 {
699         model_print("digraph function_%s {\n", func_name);
700         predicate_tree_entry->print_pred_subtree();
701         predicate_tree_exit->print_predicate();
702         model_print("}\n");     // end of graph
703 }
704
705 void FuncNode::print_val_loc_map()
706 {
707 /*
708         value_set_iter * val_it = values_may_read_from->iterator();
709         while (val_it->hasNext()) {
710                 uint64_t value = val_it->next();
711                 model_print("val %llx: ", value);
712
713                 loc_set_t * locations = val_loc_map->get(value);
714                 loc_set_iter * loc_it = locations->iterator();
715                 while (loc_it->hasNext()) {
716                         void * location = loc_it->next();
717                         model_print("%p ", location);
718                 }
719                 model_print("\n");
720         }
721 */
722 }