26 #include "pips_config.h"
51 #include "pips-libs.h"
52 #ifdef HAVE_PIPS_points_to_LIBRARY
56 #define print_points_to_relations(l) NULL
59 #include "pips-libs.h"
70 void (*cell_reference_with_address_of_cell_reference_translation_func)
116 size_t current_max_path_length,
120 void (*cell_reference_with_address_of_cell_reference_translation_func)
136 (*cell_reference_conversion_func)(tmp_ref, &sink_ref, &sink_desc);
153 pips_debug(5,
"Null pointer, may approximation: ignore, assuming code is correct\n");
168 bool exact_translation_p;
170 (*cell_reference_with_address_of_cell_reference_translation_func)
171 (input_ref, input_desc,
173 current_max_path_length,
174 &build_ref, &build_desc,
175 &exact_translation_p);
176 *exact_p = *exact_p && exact_translation_p;
226 size_t * p_current_max_path_length,
252 (*cell_reference_conversion_func)(tmp_ref, &source_ref, &source_desc);
258 size_t source_path_length =
gen_length(source_indices);
259 bool exact_prec =
false;
266 if ( (source_path_length >= *p_current_max_path_length)
267 && (*cell_reference_preceding_p_func)(source_ref, source_desc, input_ref,
270 pips_debug(8,
"exact_prec is %s\n", exact_prec?
"true":
"false");
271 if (source_path_length > *p_current_max_path_length ) {
280 if(!
ENDP(matching_list)) {
284 *p_current_max_path_length = source_path_length;
285 *exact_p = exact_prec;
288 *exact_p = *exact_p && exact_prec;
299 return matching_list;
367 void (*cell_reference_with_address_of_cell_reference_translation_func)
375 debug_on(
"EVAL_CELL_WITH_POINTS_TO_DEBUG_LEVEL");
382 size_t input_path_length =
gen_length(input_indices);
402 else if (input_path_length == 0) {
409 size_t current_max_path_length = 0;
411 (input_ref, input_desc,
412 ¤t_max_path_length,
414 cell_reference_conversion_func,
415 cell_reference_preceding_p_func);
418 fprintf(stderr,
"matching points-to list:\n");
420 fprintf(stderr,
"\ncurrent_max_path_length = %d\n", (
int) current_max_path_length);
421 fprintf(stderr,
"*exact_p is %s\n", *exact_p?
"true":
"false");
424 if(
ENDP(matching_list)) {
426 (
"NULL or undefined pointer dereferencing... or insufficient points-to information for reference \"%s\".\n",
429 cell_reference_with_address_of_cell_reference_translation_func,
430 cell_reference_conversion_func);
436 current_max_path_length,
440 cell_reference_with_address_of_cell_reference_translation_func,
441 cell_reference_conversion_func);
464 cell_reference_preceding_p_func,
465 cell_reference_with_address_of_cell_reference_translation_func,
466 cell_reference_conversion_func);
467 *exact_p = *exact_p && r_exact_p;
508 list * l_in_remnants,
532 *l_in_remnants =
NIL;
546 bool intersection_test_exact_p =
false;
547 bool inclusion_test_exact_p =
true;
551 (*simple_cell_conversion_func)(first_cell_in, &converted_first_cell_in, &first_cell_in_desc);
552 (*simple_cell_conversion_func)(second_cell_in, &converted_second_cell_in, &second_cell_in_desc);
554 if ((*cells_intersection_p_func)(eff_cell, eff_desc,
555 converted_first_cell_in, first_cell_in_desc,
556 &intersection_test_exact_p))
558 pips_debug(4,
"non empty intersection with first cell (%sexact)\n",
559 intersection_test_exact_p?
"":
"non ");
561 && intersection_test_exact_p
562 && (*cells_inclusion_p_func)(eff_cell, eff_desc,
563 converted_first_cell_in, first_cell_in_desc,
564 &inclusion_test_exact_p)
565 && inclusion_test_exact_p)
569 pips_debug(4,
"exact value candidate found\n");
570 *exact_aliased_pv = pv_in;
577 pips_debug(4,
"better exact value candidate found\n");
579 *exact_aliased_pv = pv_in;
583 pips_debug(4,
"not kept as exact candidate\n");
589 pips_debug(5,
"potentially non exact value candidate found\n");
594 && (*cells_intersection_p_func)(eff_cell, eff_desc,
595 converted_second_cell_in, second_cell_in_desc,
596 &intersection_test_exact_p))
598 pips_debug(4,
"non empty intersection with second value_of cell "
599 "(%sexact)\n", intersection_test_exact_p?
"":
"non ");
601 && intersection_test_exact_p
602 && (*cells_inclusion_p_func)(eff_cell, eff_desc,
603 second_cell_in, second_cell_in_desc,
604 &inclusion_test_exact_p)
605 && inclusion_test_exact_p)
609 pips_debug(4,
"exact value candidate found\n");
610 *exact_aliased_pv = pv_in;
614 pips_debug(4,
"better exact value candidate found\n");
616 *exact_aliased_pv = pv_in;
620 pips_debug(4,
"not kept as exact candidate\n");
626 pips_debug(5,
"potentially non exact value candidate found\n");
679 void (*cell_with_address_of_cell_translation_func)
685 void (*cell_with_value_of_cell_translation_func)
700 list l_remnants = l_pv;
704 bool anywhere_p =
false;
713 pips_debug(5,
"anywhere, undefined or null case\n");
730 &pv_exact, &tmp_l_remnants,
731 cells_intersection_p_func,
732 cells_inclusion_p_func,
733 simple_cell_conversion_func);
738 l_remnants = tmp_l_remnants;
745 int nb_common_indices =
752 bool exact_translation_p;
761 pips_debug(5,
"potential dereferencement of an undefined pointer -> returning undefined\n");
770 pips_debug(5,
"potential dereferencement of a null pointer -> returning null\n");
790 (*simple_cell_conversion_func)(c2, &converted_c2, &converted_d2);
795 (*cell_with_value_of_cell_translation_func)
797 converted_c2, converted_d2,
799 &c, &d, &exact_translation_p);
803 (*cell_with_address_of_cell_translation_func)
805 converted_c2, converted_d2,
807 &c, &d, &exact_translation_p);
817 (*simple_cell_conversion_func)(c1, &converted_c1, &converted_d1);
819 (*cell_with_value_of_cell_translation_func)
821 converted_c1, converted_d1,
823 &c, &d, &exact_translation_p);
831 exact_translation_p ?
863 cell pv_remnant_second_cell =
865 bool exact_preceding_test =
true;
873 (*simple_cell_conversion_func)(pv_remnant_second_cell,
874 &pv_remnant_converted_cell,
875 &pv_remnant_converted_desc);
886 &exact_preceding_test))
890 bool exact_translation_p;
892 pips_debug(5,
"good candidate (%sexact)\n",exact_preceding_test?
"":
"non ");
904 (*simple_cell_conversion_func)(new_cell,
906 &new_converted_desc);
908 (*cell_with_value_of_cell_translation_func)
910 new_converted_cell, new_converted_desc,
912 &c, &d, &exact_translation_p);
918 exact_translation_p && exact_preceding_test ?
934 l_remnants = l_remnants_2;
936 if (!
ENDP(l_remnants))
938 pips_debug(5,
"recursing to find aliases to aliased effect...\n");
949 cell_with_address_of_cell_translation_func,
950 cell_with_value_of_cell_translation_func,
951 cells_intersection_p_func,
952 cells_inclusion_p_func,
953 simple_cell_conversion_func ));
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
cell make_cell_reference(reference _field_)
action copy_action(action p)
ACTION.
descriptor make_descriptor(enum descriptor_utype tag, void *val)
void free_effect(effect p)
cell make_cell(enum cell_utype tag, void *val)
approximation make_approximation_exact(void)
approximation make_approximation(enum approximation_utype tag, void *val)
approximation make_approximation_may(void)
effect make_effect(cell a1, action a2, approximation a3, descriptor a4)
descriptor make_descriptor_none(void)
reference copy_reference(reference p)
REFERENCE.
bool entity_flow_or_context_sentitive_heap_location_p(entity e)
bool entity_heap_location_p(entity b)
package abstract location.
static reference ref
Current stmt (an integer)
bool entity_null_locations_p(entity e)
test if an entity is the NULL POINTER
bool entity_abstract_location_p(entity al)
reference make_anywhere_reference(type t)
This function should be located somewhere in effect-util in or near abstract locations.
cell make_anywhere_cell(type t)
void const char const char const int
#define pips_debug_effects(level, message, l_eff)
#define pips_debug_effect(level, message, eff)
for debug
static list generic_transform_sink_cells_from_matching_list(list matching_list, size_t current_max_path_length, bool *exact_p, reference input_ref, descriptor input_desc, void(*cell_reference_with_address_of_cell_reference_translation_func)(reference, descriptor, reference, descriptor, int, reference *, descriptor *, bool *), void(*cell_reference_conversion_func)(reference, reference *, descriptor *))
Build the return list with the points-to sinks to which we add/append the indices of input_ref which ...
#define print_points_to_relations(l)
list generic_reference_to_points_to_matching_list(reference input_ref, descriptor input_desc, size_t *p_current_max_path_length, bool *exact_p, transformer current_precondition, list ptl, void(*cell_reference_conversion_func)(reference, reference *, descriptor *), bool(*cell_reference_preceding_p_func)(reference, descriptor, reference, descriptor, transformer, bool, bool *))
This function has been outlined from generic_eval_cell_with_points_to() to reduce the size of a funct...
static list use_default_sink_cell(reference input_ref, descriptor input_desc __attribute__((__unused__)), void(*cell_reference_with_address_of_cell_reference_translation_func)(reference, descriptor, reference, descriptor, int, reference *, descriptor *, bool *) __attribute__((__unused__)), void(*cell_reference_conversion_func)(reference, reference *, descriptor *) __attribute__((__unused__)))
In case, the points-to information is not complete, use anywhere locations to convert the reference.
list generic_effect_find_aliases_with_simple_pointer_values(effect eff, list l_pv, bool *exact_p, transformer current_precondition, bool(*cell_preceding_p_func)(cell, descriptor, cell, descriptor, transformer, bool, bool *), void(*cell_with_address_of_cell_translation_func)(cell, descriptor, cell, descriptor, int, cell *, descriptor *, bool *), void(*cell_with_value_of_cell_translation_func)(cell, descriptor, cell, descriptor, int, cell *, descriptor *, bool *), bool(*cells_intersection_p_func)(cell, descriptor, cell, descriptor, bool *), bool(*cells_inclusion_p_func)(cell, descriptor, cell, descriptor, bool *), void(*simple_cell_conversion_func)(cell, cell *, descriptor *))
list generic_effect_find_equivalent_simple_pointer_values(effect eff, list l_in, cell_relation *exact_aliased_pv, list *l_in_remnants, bool(*cells_intersection_p_func)(cell, descriptor, cell, descriptor, bool *), bool(*cells_inclusion_p_func)(cell, descriptor, cell, descriptor, bool *), void(*simple_cell_conversion_func)(cell, cell *, descriptor *))
find pointer_values in l_in which give (possible or exact) paths equivalent to eff.
list generic_eval_cell_with_points_to(cell input_cell, descriptor input_desc, list ptl, bool *exact_p, transformer current_precondition, bool(*cell_reference_preceding_p_func)(reference, descriptor, reference, descriptor, transformer, bool, bool *), void(*cell_reference_with_address_of_cell_reference_translation_func)(reference, descriptor, reference, descriptor, int, reference *, descriptor *, bool *), void(*cell_reference_conversion_func)(reference, reference *, descriptor *))
int effects_statement_line_number(void)
To provide information when a but is encountered in the source file or within PIPS.
void effects_to_may_effects(list)
effect make_undefined_pointer_value_effect(action)
bool(* cell_preceding_p_func)(cell, descriptor, cell, descriptor, bool, bool *)
statement effects_private_current_stmt_head(void)
list effect_intermediary_pointer_paths_effect(effect)
effect make_null_pointer_value_effect(action)
list effect_to_list(effect)
#define effect_may_p(eff)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define pips_debug_pv(level, message, pv)
#define make_reference_simple_effect(reference, action, approximation)
#define cell_relation_may_p(cr)
#define cell_relation_second_cell(cr)
#define pips_debug_pvs(level, message, l_pv)
#define cell_relation_exact_p(cr)
#define cell_relation_second_address_of_p(cr)
#define cell_relation_second_value_of_p(cr)
#define cell_relation_first_cell(cr)
#define effect_exact_p(eff)
bool undefined_pointer_value_cell_p(cell)
type points_to_reference_to_concrete_type(reference)
reference cell_any_reference(cell)
API for reference.
bool effect_reference_dereferencing_p(reference, bool *)
points_to points_to_with_stripped_sink(points_to, int(*)(void))
The value of the source can often be expressed with different subscript lists.
bool generic_atomic_points_to_reference_p(reference, bool)
Is it a unique concrete memory location?
entity effect_entity(effect)
cproto-generated files
action make_action_write_memory(void)
To ease the extension of action with action_kind.
list word_points_to(points_to)
reference cell_to_reference(cell)
FI: probably to be moved elsewhere in ri-util.
bool nowhere_cell_p(cell)
Target of an undefined pointer.
bool anywhere_effect_p(effect)
Is it an anywhere effect? ANYMMODULE:ANYWHERE
string effect_reference_to_string(reference)
bool null_pointer_value_cell_p(cell)
#define cell_reference(x)
#define CELL_RELATION(x)
CELL_RELATION.
#define approximation_exact_p(x)
#define approximation_may_p(x)
#define cell_relation_undefined
#define effect_descriptor(x)
#define descriptor_undefined
#define descriptor_undefined_p(x)
#define cell_relation_undefined_p(x)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
void gen_full_free_list(list l)
#define ENDP(l)
Test if a list is empty.
list gen_nreverse(list cp)
reverse a list in place
#define NIL
The empty list (nil in Lisp)
size_t gen_length(const list l)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
void gen_free_list(list l)
free the spine of the list
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define points_to_approximation(x)
#define points_to_sink(x)
#define POINTS_TO(x)
POINTS_TO.
#define points_to_source(x)
string reference_to_string(reference r)
bool same_entity_p(entity e1, entity e2)
predicates on entities
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
#define transformer_undefined
#define reference_undefined
#define reference_variable(x)
#define EXPRESSION(x)
EXPRESSION.
#define reference_indices(x)
#define statement_number(x)
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define semantics_user_warning
static transformer current_precondition
The structure used to build lists in NewGen.
string words_to_string(cons *lw)