25 #include "pips_config.h"
63 static bool contract_p =
true;
91 debug_on(
"SUMMARY_EFFECTS_DEBUG_LEVEL");
125 effect eff = (*reference_to_effect_func)
128 (eff, formal_t,
'x');
133 (*effect_free_func)(eff);
146 pips_debug(2,
"local regions, before translation to global scope:\n");
147 (*effects_prettyprint_func)(l_loc);
154 pips_debug(8,
"Summary effects from declarations:\n");
155 (*effects_prettyprint_func)(l_dec);
157 pips_debug(8,
"number of declared formal parameters:%d\n", nb_param);
167 l_glob = (*effects_local_to_global_translation_op)(l_loc2);
182 pips_debug(2,
"local regions, after translation to global scope:\n");
183 (*effects_prettyprint_func)(l_loc2);
184 pips_debug(2,
"global regions, after translation to global scope:\n");
185 (*effects_prettyprint_func)(l_glob);
196 (*db_put_summary_rw_effects_func)(
module_name, l_glob);
217 static void rw_effects_of_unstructured(
unstructured unst)
236 transformer t_unst = (*load_transformer_func)(current_stat);
254 le = (*effects_transformer_composition_op)(le, t_unst);
262 (*effects_descriptor_normalize_func)(le);
266 (*effects_prettyprint_func)(le);
319 static void rw_effects_of_while(
whileloop w)
322 list l_prop, l_body, l_cond_first, l_res;
339 trans = (*load_transformer_func)(current_stat);
352 l_body = (*effects_transformer_composition_op)(l_body, trans);
368 (*effects_descriptor_normalize_func)(l_res);
373 static void rw_effects_of_forloop(
forloop w)
426 trans = (*load_transformer_func)(current_stat);
439 l_res = (*effects_transformer_composition_op)(l_body, trans);
455 (*effects_descriptor_normalize_func)(l_res);
460 static void rw_effects_of_loop(
loop l)
463 list l_prop, l_body, l_loop =
NIL;
481 (*effects_prettyprint_func)(l_body);
487 "Fortran 77 standard violation, see Section 11.10.5.\n",
505 loop_trans = (*load_transformer_func)(current_stat);
517 pips_debug(8,
"loop transformer after removing loop index %s : \n",
529 l_body = (*effects_transformer_composition_op)(l_body, loop_trans);
533 pips_debug(4,
"invariant rw effects of loop body:\n");
534 (*effects_prettyprint_func)(l_body);
546 l_loop = (*effects_union_over_range_op)(l_loop, i, r,
551 pips_debug(4,
"rw effects of loop before adding proper effects:\n");
552 (*effects_prettyprint_func)(l_loop);
564 pips_debug(4,
"rw effects of loop after adding proper effects:\n");
565 (*effects_prettyprint_func)(l_loop);
570 (*effects_descriptor_normalize_func)(l_loop);
574 (*effects_prettyprint_func)(l_loop);
580 static void rw_effects_of_call(
call c)
593 pips_debug(2,
"proper effects before summarization: \n");
594 (*effects_prettyprint_func)(le);
605 (*effects_descriptor_normalize_func)(le);
609 (*effects_prettyprint_func)(le);
630 pips_debug(2,
"proper effects before summarization: \n");
631 (*effects_prettyprint_func)(le);
642 (*effects_descriptor_normalize_func)(le);
646 (*effects_prettyprint_func)(le);
658 static void rw_effects_of_expression_instruction(
instruction i)
676 rw_effects_of_call(c);
693 rw_effects_of_call(c);
700 "pointers in data structures are ignored for the time being\n");
701 rw_effects_of_application(a);
714 pips_debug(2,
"Effects for expression instruction in statement%03zd\n",
720 static void rw_effects_of_test(
test t)
723 list le, lt, lf, lc, lr;
783 (*effects_descriptor_normalize_func)(lr);
787 (*effects_prettyprint_func)(lr);
794 static void save_useful_variables_effects(
entity ent,
list l_eff) {
806 (*effects_prettyprint_func)(l_save);
845 static list rw_effects_of_declaration(
list lrw_after_first_decl,
entity decl)
852 pips_debug(8,
"dealing with entity : %s with type %s\n",
878 lrw_after_first_decl = (*effects_union_op)(l_exp_init,
882 save_useful_variables_effects(decl, lrw_after_first_decl);
890 lrw_before_decls = lrw_after_first_decl;
892 return lrw_before_decls;
907 static list rw_effects_of_declarations(
list lrw_after_decls,
list l_decl)
910 list lrw_after_first_decl =
NIL;
917 lrw_after_first_decl = rw_effects_of_declarations(lrw_after_decls,
CDR(l_decl));
919 lrw_after_first_decl = lrw_after_decls;
922 lrw_before_decls = rw_effects_of_declaration(lrw_after_first_decl, decl);
926 lrw_before_decls = lrw_after_decls;
930 list l_tmp = lrw_before_decls;
935 return lrw_before_decls;
982 static list r_rw_effects_of_sequence(
list sl)
985 list remaining_block =
CDR(sl);
1005 pips_debug(5,
"first statement is a declaration statement\n");
1014 if (!
ENDP(remaining_block)) {
1015 rb_lrw = r_rw_effects_of_sequence(remaining_block);
1018 pips_debug(3,
"R/W effects of first statement: \n");
1019 (*effects_prettyprint_func)(s1_lrw);
1020 pips_debug(3,
"R/W effects of remaining sequence: \n");
1021 (*effects_prettyprint_func)(rb_lrw);
1044 pips_debug(3,
"Warning - no effect on remaining block\n");
1048 pips_debug(5,
"R/W effects of remaining sequence "
1049 "after store update: \n");
1050 (*effects_prettyprint_func)(rb_lrw);
1058 rb_lrw = rw_effects_of_declarations(rb_lrw, l_decl);
1062 pips_debug(5,
"R/W effects of remaining sequence "
1063 "after taking declarations into account: \n");
1064 (*effects_prettyprint_func)(rb_lrw);
1076 pips_debug(5,
"R/W effects of remaining sequence "
1078 (*effects_prettyprint_func)(l_rw);
1085 l_rw = rw_effects_of_declarations(
effects_dup(s1_lrw), l_decl);
1111 static void rw_effects_of_sequence(
sequence seq)
1126 list l_tmp = r_rw_effects_of_sequence(
l_inst);
1133 (*effects_prettyprint_func)(le);
1139 (*effects_descriptor_normalize_func)(le);
1142 pips_debug(2,
"R/W effects after normalization: \n");
1143 (*effects_prettyprint_func)(le);
1150 static bool rw_effects_stmt_filter(
statement s)
1161 static void rw_effects_of_statement(
statement s)
1169 static bool r_effects_of_return_exit_abort_statment(
statement s,
list lem) {
1266 (*db_put_rw_effects_func)
1268 (*db_put_invariant_rw_effects_func)
1270 (*db_put_useful_variables_effects_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.
effects make_effects(list a)
effect copy_effect(effect p)
EFFECT.
reference make_reference(entity a1, list a2)
list l_inst
The list "first" is a truncated list from the first to the current statement (not included).
void free_effects_private_current_context_stack(void)
list make_anywhere_read_write_memory_effects(void)
void reset_useful_variables_effects(void)
void set_rw_effects(statement_effects)
void effects_to_may_effects(list)
bool(* empty_context_test)(transformer)
void make_effects_private_current_context_stack(void)
void set_contracted_rw_effects(bool)
rw_effects_engine.c
transformer(* load_context_func)(statement)
void make_effects_private_current_stmt_stack(void)
utils.c
list proper_to_summary_effects(list)
pointer_info_val get_pointer_info_kind(void)
void store_rw_effects_list(statement, list)
void init_useful_variables_effects(void)
list load_proper_rw_effects_list(statement)
entity_effects get_useful_variables_effects(void)
transformer transformer_remove_variable_and_dup(transformer, entity)
void init_rw_effects(void)
statement effects_private_current_stmt_pop(void)
void store_useful_variables_effects(entity, effects)
list proper_effects_combine(list, bool)
void reset_proper_rw_effects(void)
void free_effects_private_current_stmt_stack(void)
list clean_anywhere_effects(list)
list generic_effects_store_update(list, statement, bool)
void rw_effects_of_module_statement(statement)
void set_proper_rw_effects(statement_effects)
bool check_sdfi_effects_p(entity, list)
statement effects_private_current_stmt_head(void)
void update_rw_effects_list(statement, list)
void effects_private_current_stmt_push(statement)
bool summary_rw_effects_engine(const char *)
void update_invariant_rw_effects_list(statement, list)
bool rw_effects_engine(const char *)
list filter_effects_with_declaration(list, entity)
list load_rw_effects_list(statement)
bool get_constant_paths_p(void)
statement_effects get_rw_effects(void)
list generic_proper_effects_of_expression(expression)
void init_invariant_rw_effects(void)
void reset_invariant_rw_effects(void)
void store_invariant_rw_effects_list(statement, list)
transformer effects_private_current_context_pop(void)
void effects_private_current_context_push(transformer)
list effects_dup_without_variables(list, list)
list pointer_effects_to_constant_path_effects(list)
statement_effects(* db_get_proper_rw_effects_func)(const char *)
list generic_effect_generate_all_accessible_paths_effects(effect, type, tag)
void reset_rw_effects(void)
bool effects_same_action_p(effect, effect)
list summary_effects_from_declaration(const char *)
bool(* stmt_strongly_feasible_p_func)(statement)
statement_effects get_invariant_rw_effects(void)
statement_effects(* db_get_rw_effects_func)(const char *)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_read_p(eff)
#define effect_scalar_p(eff) entity_scalar_p(effect_entity(eff))
entity effect_entity(effect)
cproto-generated files
action make_action_write_memory(void)
To ease the extension of action with action_kind.
void set_pt_to_list(statement_points_to)
void reset_pt_to_list(void)
#define effects_undefined
#define action_write_p(x)
#define descriptor_undefined
const char * module_name(const char *s)
Return the module part of an entity name.
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
void gen_full_free_list(list l)
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.
void reset_current_module_entity(void)
Reset the current module entity.
void reset_current_module_statement(void)
Reset the current module statement.
statement set_current_module_statement(statement)
Set the current module statement.
statement get_current_module_statement(void)
Get the current module statement.
entity set_current_module_entity(entity)
static.c
entity get_current_module_entity(void)
Get the entity of the current module.
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
bool gen_false(__attribute__((unused)) gen_chunk *unused)
Return false and ignore the argument.
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
bool loop_parallel_p(loop l)
Test if a loop is parallel.
#define ENDP(l)
Test if a list is empty.
#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
#define CAR(pcons)
Get the value of the first element of a list.
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 CDR(pcons)
Get the list less its first element.
list gen_append(list l1, const list l2)
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
bool statement_call_p(statement)
bool empty_statement_p(statement)
Test if a statement is empty.
bool return_statement_p(statement)
Test if a statement is a C or Fortran "return".
bool exit_statement_p(statement)
bool abort_statement_p(statement)
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define pips_internal_error
void set_pv(statement_cell_relations)
statement_cell_relations db_get_simple_pv(const char *)
I don't know how to deal with these mappings if we have to analyse several modules at the same time w...
string expression_to_string(expression e)
string string_of_type(const type)
void print_statement(statement)
Print a statement on stderr.
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
bool static_area_p(entity aire)
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
bool same_entity_p(entity e1, entity e2)
predicates on entities
bool c_module_p(entity m)
Test if a module "m" is written in C.
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
bool entity_main_module_p(entity e)
const char * label_local_name(entity e)
END_EOLE.
list module_formal_parameters(entity func)
list module_formal_parameters(entity func) input : an entity representing a function.
statement pop_statement_global_stack(void)
type entity_basic_concrete_type(entity)
retrieves or computes and then returns the basic concrete type of an entity
void push_statement_on_statement_global_stack(statement)
void free_statement_global_stack(void)
void make_statement_global_stack(void)
#define forloop_domain
newgen_extensions_domain_defined
#define test_domain
newgen_entity_domain_defined
#define syntax_reference_p(x)
#define expression_domain
newgen_execution_domain_defined
#define unstructured_domain
newgen_type_domain_defined
#define forloop_initialization(x)
#define reference_variable(x)
#define loop_domain
newgen_language_domain_defined
#define control_predecessors(x)
#define forloop_increment(x)
#define statement_ordering(x)
#define type_functional(x)
#define syntax_application(x)
#define entity_storage(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define instruction_domain
newgen_functional_domain_defined
#define call_domain
newgen_callees_domain_defined
#define cast_expression(x)
#define expression_undefined
#define functional_parameters(x)
#define sequence_statements(x)
#define control_successors(x)
#define instruction_expression(x)
#define syntax_application_p(x)
#define expression_undefined_p(x)
#define variable_dimensions(x)
#define whileloop_body(x)
#define whileloop_domain
newgen_variable_domain_defined
#define statement_declarations(x)
#define forloop_condition(x)
#define control_statement(x)
#define statement_number(x)
#define value_expression_p(x)
#define expression_syntax(x)
#define sequence_domain
newgen_reference_domain_defined
#define type_variable_p(x)
#define value_expression(x)
#define instruction_expression_p(x)
#define STATEMENT(x)
STATEMENT.
#define entity_initial(x)
The structure used to build lists in NewGen.