PIPS
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "points_to_private.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "text.h"
#include "text-util.h"
#include "misc.h"
#include "properties.h"
Go to the source code of this file.
entity calloc_to_abstract_location | ( | expression | n, |
expression | size, | ||
sensitivity_information * | psi | ||
) |
generate an abstract heap location entity
n | is the first argument expression of the call to calloc |
size | is the second argument expression of the call to calloc |
psi | is a pointer towards a structure which contains context and/or flow sensitivity information |
size | ize |
psi | si |
Definition at line 414 of file abstract_location.c.
References copy_expression(), free_expression(), make_op_exp(), and malloc_to_abstract_location().
FI: Beware, the symbol table is updated but this is not reflected in pipsmake.rc
We need to keep track of these pseudo-variables to destroy them before a module is reanalyzed after a code transformation, for instance a constant propagation that changed dependent types into cosntant types.
We might be in trouble, unless a piece of code is reanalyzed. Let's assume the type is unchanged
stmt_number | tmt_number |
Definition at line 78 of file abstract_location.c.
References ABSTRACT_LOCATION, add_C_variable_to_area(), AddEntityToDeclarations(), array_type_p(), asprintf, basic_equal_p(), compute_basic_concrete_type(), copy_type(), DYNAMIC_RAM_OFFSET, entity_initial, entity_kind, entity_storage, entity_type, f(), FindOrCreateEntity(), free(), free_type(), gen_length(), get_current_module_entity(), get_current_module_name(), HEAP_AREA_LOCAL_NAME, int, make_ram(), make_storage_ram(), make_value_unknown(), module_to_heap_area(), NIL, pips_assert, pointer_type_p(), type_equal_p(), type_to_pointed_type(), type_undefined_p, type_variable, variable_basic, and variable_dimensions.
Referenced by malloc_type_to_abstract_location().
Definition at line 147 of file abstract_location.c.
References ANYWHERE_LOCATION, entity_local_name(), HEAP_AREA_LOCAL_NAME, and pips_debug.
Referenced by convex_cells_inclusion_p(), convex_cells_intersection_p(), free_to_post_pv(), generic_transform_sink_cells_from_matching_list(), references_may_conflict_p(), simple_cells_inclusion_p(), and simple_cells_intersection_p().
package abstract location.
Amira Mensi 2010
File: abstract_location.c
This file contains various useful functions to modelize a heap. check if an entity b may represent a bucket or a set of buckets in the heap.
Definition at line 64 of file abstract_location.c.
References entity_all_heap_locations_p(), entity_all_module_heap_locations_p(), entity_local_name(), HEAP_AREA_LOCAL_NAME, and heap_area_p().
Referenced by analyzable_scalar_entity_p(), cell_out_of_scope_p(), cells_to_read_or_write_effects(), clean_up_points_to_stubs(), generic_atomic_points_to_reference_p(), generic_eval_cell_with_points_to(), generic_remove_unreachable_vertices_in_points_to_graph(), module_to_value_mappings(), points_to_reference_to_typed_index(), and semantics_usable_points_to_reference_p().
sensitivity_information make_sensitivity_information | ( | statement | current_stmt, |
entity | current_module, | ||
list | enclosing_flow | ||
) |
current_stmt | urrent_stmt |
current_module | urrent_module |
enclosing_flow | nclosing_flow |
Definition at line 522 of file abstract_location.c.
References sensitivity_information::current_module, current_module, current_stmt, sensitivity_information::current_stmt, and sensitivity_information::enclosing_flow.
Referenced by flow_sensitive_malloc_to_points_to_sinks(), heap_intrinsic_to_post_pv(), and original_malloc_to_abstract_location().
type malloc_arg_to_type | ( | expression | e | ) |
generate the type of the allocated area from the malloc argument
e | is the malloc argument expression |
Store dependent types are not generated. It means that whenever the size of the allocated space is store dependent, the returned type is an array of unbounded_dimension.
which one is the sizeof operator ? try the second one first
sizeofexpression is an expression
Definition at line 187 of file abstract_location.c.
References call_arguments, call_function, CAR, cast_expression, CDR, CONS, copy_basic(), copy_expression(), DEFAULT_CHARACTER_TYPE_SIZE, DIMENSION, entity_local_name(), EXPRESSION, expression_constant_p(), expression_syntax, expression_to_string(), expression_to_type(), expression_undefined, expression_undefined_p, free_expression(), free_type(), gen_full_copy_list(), int_to_expression(), make_basic_int(), make_dimension(), make_op_exp(), make_type_variable(), make_unbounded_expression(), make_variable(), MULTIPLY_OPERATOR_NAME, NIL, pips_assert, pips_debug, same_string_p, sizeofexpression_expression, sizeofexpression_type, sizeofexpression_type_p, sizeofexpression_undefined, sizeofexpression_undefined_p, string_of_type(), syntax_call, syntax_call_p, syntax_cast, syntax_cast_p, syntax_sizeofexpression, syntax_sizeofexpression_p, type_undefined, type_variable, type_variable_p, unbounded_expression_p(), variable_basic, variable_dimensions, variable_undefined, and variable_undefined_p.
Referenced by malloc_to_abstract_location().
entity malloc_to_abstract_location | ( | expression | malloc_exp, |
sensitivity_information * | psi | ||
) |
generate an abstract heap location entity
malloc_exp | is the argument expression of the call to malloc |
psi | is a pointer towards a structure which contains context and/or flow sensitivity information |
free_type(ct)
malloc_exp | alloc_exp |
psi | si |
Definition at line 389 of file abstract_location.c.
References entity_name, entity_type, entity_undefined, expression_to_string(), free_type(), malloc_arg_to_type(), malloc_type_to_abstract_location(), pips_debug, and string_of_type().
Referenced by calloc_to_abstract_location(), flow_sensitive_malloc_to_points_to_sinks(), heap_intrinsic_to_post_pv(), and original_malloc_to_abstract_location().
entity malloc_type_to_abstract_location | ( | type | t, |
sensitivity_information * | psi | ||
) |
generate an abstract heap location entity
t | is type of the allocated space |
psi | is a pointer towards a structure which contains context and/or flow sensitivity information |
in case we want an anywhere abstract heap location : the property ABSTRACT_HEAP_LOCATIONS is set to "unique" and a unique abstract location is used for all heap buckets.
in case the property ABSTRACT_HEAP_LOCATIONS is set to "insensitive": an abstract location is used for each function.
in case the property ABSTRACT_HEAP_LOCATIONS is set to "flow-sensitive" or "context-sensitive".
No difference here between the two values. The diffferent behavior will show when points-to and effects are translated at call sites
At this level, we want to use the statement number or the statement ordering. The statement ordering is safer because two statements or more can be put on the same line. The statement number is more user-friendly.
There is no need to distinguish between types since the statement ordering is at least as effective.
psi | si |
Definition at line 324 of file abstract_location.c.
References copy_type(), sensitivity_information::current_module, sensitivity_information::current_stmt, entity_all_heap_locations(), entity_all_heap_locations_typed(), entity_all_module_heap_locations(), entity_all_module_heap_locations_typed(), entity_flow_or_context_sentitive_heap_location(), entity_name, entity_type, entity_undefined, get_bool_property(), get_string_property(), pips_debug, pips_user_error, statement_number, and string_of_type().
Referenced by malloc_to_abstract_location().
reference original_malloc_to_abstract_location | ( | expression lhs | __attribute__(unused), |
type __attribute__((unused)) | var_t, | ||
type __attribute__((unused)) | cast_t, | ||
expression | sizeof_exp, | ||
entity | f, | ||
statement | stmt | ||
) |
to handle malloc statemennts:
p = (cast t) malloc(sizeof(expression))
This function return a reference according to the value of the property ABSTRACT_HEAP_LOCATIONS. the list of callers will be added to ensure the context sensitive property. We should keep in mind that context and sensitive properties are orthogonal and we should modify them in pipsmake.
ABSTRACT_HEAP_LOCATIONS is set to "unique" and a unique abstract
location is used for all heap buckets. *\/
if(strcmp(opt, "unique")==0){
if(type_sensitive_p) {
e = entity_all_heap_locations_typed(var_t);
r = make_reference(e , NIL);
}
else {
e = entity_all_heap_locations();
r = make_reference(e , NIL);
}
}
/* in case the property ABSTRACT_HEAP_LOCATIONS is set to
"insensitive": an abstract location is used for each function. *\/
else if(strcmp(opt, "insensitive")==0){
if(type_sensitive_p) {
e = entity_all_module_heap_locations_typed(get_current_module_entity(),
var_t);
r = make_reference(e , NIL);
}
else {
e = entity_all_module_heap_locations(f);
r = make_reference(e , NIL);
}
}
/* in case the property ABSTRACT_HEAP_LOCATIONS is set to
"flow-sensitive" or "context-sensitive".
No difference here between the two values. The diffferent
behavior will show when points-to and effects are translated at
call sites
At this level, we want to use the statement number or the
statement ordering. The statement ordering is safer because two
statements or more can be put on the same line. The statement
number is more user-friendly.
There is no need to distinguish between types since the statement
ordering is at least as effective.
*\/
else if(strcmp(opt, "flow-sensitive")==0
|| strcmp(opt, "context-sensitive")==0 ){
e = entity_flow_or_context_sentitive_heap_location(stmt_number, var_t);
r = make_reference(e , NIL);
}
else {
pips_user_error("Unrecognized value for property ABSTRACT_HEAP_LOCATION:"
" \"s"", opt);
}
pips_debug(8, "Reference to ");
Definition at line 436 of file abstract_location.c.
References CONS, entity_array_p(), entity_undefined, EXPRESSION, f(), int_to_expression(), make_reference(), make_sensitivity_information(), malloc_to_abstract_location(), NIL, and reference_undefined.