PIPS
|
#include <stdio.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "workspace-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "constants.h"
#include "misc.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "effects-simple.h"
#include "effects-generic.h"
#include "transformer.h"
#include "semantics.h"
#include "preprocessor.h"
#include "properties.h"
Go to the source code of this file.
Functions | |
static void | reset_equivalence_equalities () |
transformer | tf_equivalence_equalities_add (transformer tf) |
mappings.c More... | |
static void | add_equivalence_equality (entity e, entity eq) |
void | add_equivalenced_values (entity e, entity eq, bool readonly) |
static void | add_interprocedural_value_entities (entity e) |
???? More... | |
static void | add_interprocedural_new_value_entity (entity e) |
static void | add_intraprocedural_value_entities_unconditionally (entity e) |
void | add_intraprocedural_value_entities (entity e) |
Use to be static, but may be called from ri_to_transformer. More... | |
void | add_or_kill_equivalenced_variables (entity e, bool readonly) |
Look for variables equivalenced with e. More... | |
static void | allocate_module_value_mappings (entity m) |
void | add_implicit_interprocedural_write_effects (entity al, list el) |
It is assumed that al is an abstract location that is written and which may conflict with effects in effect list el. More... | |
static bool | entity_for_value_mapping_p (entity e) |
static void | add_intraprocedural_field_entities (reference r, list fl) |
static void | add_interprocedural_field_entities (reference r, list fl) |
static void | add_inter_or_intraprocedural_field_entities (reference r, list fl, bool intra_p) |
Check which fields combined with r would lead to analyzed values and recurse for fields which are struct themselves. More... | |
static void | add_reference_values (reference r, bool write_p, bool global_p) |
static void | create_values_for_simple_effect (effect e, entity m) |
If effect e meets all conditions to represent a location whose value could and should be analyzed, create the related values. More... | |
static bool | add_values_for_simple_effects_of_statement (statement s) |
Declare value entities necessary to analyze locations defined by proper effects. More... | |
static void | values_for_current_module_intraprocedural_simple_effects (void) |
void | module_to_value_mappings (entity m) |
void module_to_value_mappings(entity m): build hash tables between variables and values (old, new and intermediate), and between values and names for module m, as well as equivalence equalities More... | |
bool | value_mappings_compatible_vector_p (Pvecteur iv) |
transform a vector based on variable entities into a vector based on new value entities when possible; does nothing most of the time; does a little in the presence of equivalenced variables More... | |
list | variables_to_values (list list_mod) |
list | variable_to_values (entity e) |
list | dynamic_variables_to_values (list list_mod) |
Build the list of values to be projected when the declaration list list_mod is no longer valid because a block is closed/left. More... | |
list | variables_to_old_values (list list_mod) |
void | variables_to_new_values (Pvecteur v) |
replace variables by new values which is necessary for equivalenced variables More... | |
void | upwards_vect_rename (Pvecteur v, transformer post) |
Renaming of variables in v according to transformations occuring later. More... | |
Variables | |
static Pcontrainte | equivalence_equalities = CONTRAINTE_UNDEFINED |
Variable value mappings package. More... | |
assumes e and eq are different
Strange: there is no macro to chain a contrainte on a list of contrainte
Definition at line 93 of file mappings.c.
References contrainte_make(), eq, equivalence_equalities, Scontrainte::succ, vect_add_elem(), and vect_new().
Referenced by add_equivalenced_values().
e and eq are assumed to be different scalar variables of the same analyzed type
eq will be seen as e, as far as values are concerned, but for printing
new equalities e::new == eq::new and e::old == eq::old have to be added to the preconditions just before they are stored; since eq should never be written no eq::old should appear; thus the first equation is enough
By definition, all variables are conflicting with themselves but this is assumed filtered out above.
add the equivalence equations
eq | q |
readonly | eadonly |
Definition at line 107 of file mappings.c.
References add_equivalence_equality(), add_synonym_values(), eq, and pips_assert.
Referenced by add_or_kill_equivalenced_variables().
It is assumed that al is an abstract location that is written and which may conflict with effects in effect list el.
If there is a conflict, than the variable associated to this effect is written.
It should be generalized to non-interprocedural cases.
al | l |
el | l |
Definition at line 382 of file mappings.c.
References add_interprocedural_value_entities(), analyzable_scalar_entity_p(), dummy_parameter_entity_p(), EFFECT, effect_any_reference, entities_may_conflict_p(), entity_abstract_location_p(), entity_type, FOREACH, get_bool_property(), overloaded_type_p(), pips_internal_error, reference_variable, type_area_p, type_equal_p(), type_unknown_p, and ultimate_type().
Referenced by module_to_value_mappings().
|
static |
Check which fields combined with r would lead to analyzed values and recurse for fields which are struct themselves.
A similar function would be useful to handle struct assignments in semantics or points-to or effect analysis.
Definition at line 435 of file mappings.c.
References add_interprocedural_field_entities(), add_interprocedural_value_entities(), add_intraprocedural_field_entities(), add_intraprocedural_value_entities(), analyzed_type_p(), copy_reference(), ENTITY, entity_basic_concrete_type(), entity_has_values_p(), f(), FOREACH, free_reference(), make_location_entity(), simple_reference_add_field_dimension(), struct_type_p(), and struct_type_to_fields().
Referenced by add_interprocedural_field_entities(), and add_intraprocedural_field_entities().
Definition at line 466 of file mappings.c.
References add_inter_or_intraprocedural_field_entities().
Referenced by add_inter_or_intraprocedural_field_entities(), and module_to_value_mappings().
|
static |
CA: information on aliasing variables erased
Definition at line 152 of file mappings.c.
References add_new_alias_value(), add_new_value(), add_or_kill_equivalenced_variables(), entity_has_values_p(), entity_name, entity_undefined, pips_debug, and value_alias().
Referenced by add_reference_values(), and module_to_value_mappings().
|
static |
????
void add_interprocedural_value_entities
Definition at line 133 of file mappings.c.
References add_intermediate_alias_value(), add_intermediate_value(), add_new_alias_value(), add_new_value(), add_old_alias_value(), add_old_value(), add_or_kill_equivalenced_variables(), entity_has_values_p(), entity_name, entity_undefined, pips_debug, and value_alias().
Referenced by add_implicit_interprocedural_write_effects(), add_inter_or_intraprocedural_field_entities(), add_reference_values(), and module_to_value_mappings().
Definition at line 461 of file mappings.c.
References add_inter_or_intraprocedural_field_entities().
Referenced by add_inter_or_intraprocedural_field_entities(), and module_to_value_mappings().
void add_intraprocedural_value_entities | ( | entity | e | ) |
Use to be static, but may be called from ri_to_transformer.
void add_intraprocedural_value_entities(entity e)
Definition at line 181 of file mappings.c.
References add_intraprocedural_value_entities_unconditionally(), entity_basic_concrete_type(), entity_has_values_p(), entity_name, pips_debug, and type_variable_p.
Referenced by add_inter_or_intraprocedural_field_entities(), add_reference_values(), and module_to_value_mappings().
|
static |
Definition at line 169 of file mappings.c.
References add_local_intermediate_value(), add_local_old_value(), add_new_value(), add_or_kill_equivalenced_variables(), entity_name, and pips_debug.
Referenced by add_intraprocedural_value_entities(), and module_to_value_mappings().
Look for variables equivalenced with e.
e already has values associated although it may not be a canonical representative of its equivalence class...
Forget dynamic aliasing between formal parameters.
Handle intraprocedural aliasing only.
Do not handle interprocedural aliasing: this does not seem to be the right place because too many synonyms, not visible from the current procedure, are introduced (global_shared = area_layout(type_area(t));
potential canonical representative for all variables equivalenced with e
Is e intraprocedurally equivalenced/aliased with an array or a non-analyzable variable which would make e and all its aliased variables unanalyzable?
Since the equivalence is reflexive, no need to process e==eq again.
Since the equivalence is symetrical, eq may have been processed already.
this approximate test by Pierre Jouvelot should be replaced by an exact test but it does not really matter; an exact test could only be useful in presence of arrays; and in presence of arrays we do nothing here
if it's not, go ahead: it exists at least one eq such that e and eq are different, are scalars and have the same analyzable type. All eq conflicting with e meets these conditions.
Declare values for the canonical representative re
Give values to re which should have none and remove values of e. Assume that e and re are local variables.
If it is intra-procedurally equivalenced, set the synonyms as read-only variables
if eq is an integer scalar variable it does not only have a destructive effect
Variable e is equivalenced with an array or a non-integer variable and cannot be analyzed; it must be removed from the hash tables.
semantics analysis should be performed on this kind of variable but it has probably been eliminated earlier; no equivalence possible anyway!
to be dealt with later if we assume non-standard dynamic aliasing between formal parameters
readonly | eadonly |
Definition at line 204 of file mappings.c.
References add_equivalenced_values(), add_intermediate_value(), add_new_value(), add_old_value(), analyzable_scalar_entity_p(), CAR, ENDP, entities_may_conflict_p(), ENTITY, entity_has_values_p(), entity_local_name(), entity_name, entity_storage, entity_type, eq, list_undefined, pips_assert, pips_debug, pips_internal_error, pips_user_warning, POP, ram_section, ram_shared, remove_entity_values(), storage_formal_p, storage_ram, storage_ram_p, storage_return_p, storage_tag, storage_to_string(), type_area_p, type_equal_p(), and type_to_string().
Referenced by add_interprocedural_new_value_entity(), add_interprocedural_value_entities(), and add_intraprocedural_value_entities_unconditionally().
Definition at line 470 of file mappings.c.
References add_interprocedural_new_value_entity(), add_interprocedural_value_entities(), add_intraprocedural_value_entities(), and make_location_entity().
Referenced by create_values_for_simple_effect().
Declare value entities necessary to analyze locations defined by proper effects.
Definition at line 528 of file mappings.c.
References copy_effect(), create_values_for_simple_effect(), EFFECT, effect_dup_func, effect_to_constant_path_effects_with_no_pointer_information(), effect_to_constant_path_effects_with_points_to(), effect_write_p, effects_effects, FOREACH, gen_full_free_list(), get_bool_property(), get_current_module_entity(), list_undefined, load_proper_rw_effects(), pt_to_list_undefined_p(), reference_to_effect_func, reference_to_reference_effect(), store_effect_p(), store_independent_effect_p(), and transformer_undefined.
Referenced by values_for_current_module_intraprocedural_simple_effects().
|
static |
this routine tries to estimate the sizes of the hash tables, although the hashtable package has enlarging capability; its usefulness is limited... but keep at least hash table allocations!
FI: not a good estimate for C codes with local delcarations
count interprocedural effects on scalar integer variables before allocating hash tables; too many entries might be expected because the same variable could appear many times, at least twice, once in a read effect and once in a write effect; entries for arrays equivalenced with scalar variables are ignored; some slack is added before allocating the hash tables; module_inter_effects are (should be) included into module_intra_effects
add 50 % slack for underestimation (some more slack will be added by the hash package
the hash package does not like very small sizes
overapproximate intermediate value number
allocate hash tables
Definition at line 325 of file mappings.c.
References action_write_p, allocate_value_mappings(), EFFECT, effect_action, effect_any_reference, FOREACH, integer_scalar_entity_p(), load_module_intraprocedural_effects(), MAX, pips_debug, and reference_variable.
Referenced by module_to_value_mappings().
If effect e meets all conditions to represent a location whose value could and should be analyzed, create the related values.
Definition at line 490 of file mappings.c.
References action_write_p, add_reference_values(), analyzed_type_p(), effect_action, effect_any_reference, effects_package_entity_p(), entity_abstract_location_p(), entity_storage, entity_variable_p, formal_context_variable_p(), generic_atomic_points_to_reference_p(), global_variable_p(), place_holder_variable_p(), points_to_reference_to_concrete_type(), reference_variable, storage_formal_p, storage_ram_p, store_effect_p(), and variable_is_a_module_formal_parameter_p().
Referenced by add_values_for_simple_effects_of_statement().
Build the list of values to be projected when the declaration list list_mod is no longer valid because a block is closed/left.
Values for static variables are preserved. Values for heap variables also, in case their values are computed in the future...
This may not be the best algorithm when locations are used because the list of locations may be much longer, especially for arrays, than the list of values appearing in the transformer.
list_mod | ist_mod |
Definition at line 1007 of file mappings.c.
References CONS, ENTITY, entity_has_values_p(), entity_to_new_value(), entity_to_old_value(), FOREACH, NIL, variable_dynamic_p(), and variable_stack_p().
Referenced by statement_to_transformer(), and statement_to_transformer_list().
Definition at line 418 of file mappings.c.
References entity_field_p(), entity_not_constant_or_intrinsic_p(), and typedef_entity_p().
Referenced by module_to_value_mappings().
void module_to_value_mappings | ( | entity | m | ) |
void module_to_value_mappings(entity m): build hash tables between variables and values (old, new and intermediate), and between values and names for module m, as well as equivalence equalities
NW: before calling "module_to_value_mappings" to set up the hash table to translate value into value names for module with name (string) module_name do:
set_current_module_entity( local_name_to_top_level_entity(module_name) );
(the following call is only necessary if a variable of type entity such as "module" is not already set) module = get_current_module_entity();
set_current_module_statement( (statement) db_get_memory_resource(DBR_CODE, module_name, true) ); set_cumulated_rw_effects((statement_effects) db_get_memory_resource(DBR_CUMULATED_EFFECTS, module_name, true));
(that's it, but we musn't forget to reset everything after the call to "module_to_value_mappings", as below)
reset_current_module_statement(); reset_cumulated_rw_effects(); reset_current_module_entity(); free_value_mappings();
reset local intermediate value counter for make_local_intermediate_value_entity and make_local_old_value_entity
module_inter_effects = code_effects(value_code(entity_initial(m)));
look for interprocedural write effects on scalar analyzable variables and generate proper entries into hash tables
In C, write effects on scalar formal parameter are masked by the value passing mode but the copy may nevertheless be written inside the function.
To keep the summary transformer consistent although the return value has no old value
look for interprocedural read effects on scalar analyzable variables and generate proper entries into hash tables
static variables have an old value too
look for intraprocedural write effects on scalar analyzable variables and generate proper entries into hash tables
look for intraprocedural read effects on scalar analyzable variables and generate proper entry into value name hash table if it has not been entered before; interprocedural read effects are implicitly dealed with since they are included; most entities are likely to have been encountered before; however in parameters and uninitialized variables have to be dealt with
FI: although it may only be read within this procedure, e might be written in another one thru a COMMON; this write is not visible from OUT, but only from a caller of out; because we have only a local intraprocedural or a global interprocedural view of aliasing, we have to create useless values:-(
add_new_value(e);
Note: this makes the control structure of this procedure obsolete!
This call is useless because it only is effective if entity_has_values_p() is true: add_intraprocedural_value_entities(e);
A stronger call to the same subroutine is included in the previous call: add_or_kill_equivalenced_variables(e, true);
scan declarations to make sure that private variables are taken into account; assume a read and write effects on these variables, although they may not even be used.
Only intraprocedural variables can be privatized (1 Aug. 92)
This should be useless if return variables are taken into account by effect analysis. No problem with Fortran because the return variable really is assigned a value. Not obvious in C because the assignment is implicit in the return statement. In C the return variable is more like a value: it cannot be re-assigned.
FI: Only return variables are forgotten by effects
FI: no, this is wrong in C; local variables are dropped from effect when their declaration statements are processed. They cannot be found in the effects of the module statement.
We need references to all fields, direct or indirect when a field is itself a struct
scan other referenced variables to make sure everyone has an entry in the symbol table
We need references to all fields, direct or indirect when a field is itself a struct
Beware of struct return values which may generate additional locations and location values
To be sure to retrieve all relevant locations, including array elements
for debug, print hash tables
Definition at line 624 of file mappings.c.
References action_read_p, action_write_p, add_implicit_interprocedural_write_effects(), add_interprocedural_field_entities(), add_interprocedural_new_value_entity(), add_interprocedural_value_entities(), add_intraprocedural_field_entities(), add_intraprocedural_value_entities(), add_intraprocedural_value_entities_unconditionally(), allocate_module_value_mappings(), analyzable_scalar_entity_p(), analyzed_reference_p(), analyzed_type_p(), aproximate_number_of_analyzed_variables(), c_module_p(), callees_callees, cell_any_reference(), compute_basic_concrete_type(), constant_path_analyzed_p(), current_module_declarations(), db_get_memory_resource(), EFFECT, effect_action, effect_any_reference, effect_cell, effects_package_entity_p(), ENTITY, entity_abstract_location_p(), entity_anywhere_locations_p(), entity_basic_concrete_type(), entity_for_value_mapping_p(), entity_formal_p(), entity_has_values_p(), entity_heap_location_p(), entity_local_name(), entity_module_p(), entity_static_variable_p(), entity_storage, entity_typed_anywhere_locations_p(), entity_variable_p, error_reset_value_mappings(), f(), FOREACH, free_reference(), free_type(), function_to_return_value(), functional_result, gen_true(), get_current_module_statement(), get_referenced_entities_filtered(), ifdebug, load_module_intraprocedural_effects(), load_summary_effects(), location_entity_p(), make_location_entity(), make_reference(), module_local_name(), module_name(), module_name_to_entity(), NIL, number_of_analyzed_values(), pips_assert, pips_debug, place_holder_variable_p(), points_to_reference_to_concrete_type(), print_value_mappings(), reference_variable, reset_equivalence_equalities(), reset_hooks_register(), reset_temporary_value_counter(), reset_value_counters(), set_analyzed_types(), SET_FOREACH, set_free(), storage_ram_p, storage_return_p, store_effect_p(), STRING, struct_type_p(), struct_type_to_fields(), test_mapping_entry_consistency(), type_functional, and values_for_current_module_intraprocedural_simple_effects().
Referenced by add_alias_pairs_for_this_caller(), alias_classes(), alias_lists(), alias_pairs(), aliases_text(), any_complexities(), array_expansion(), bdsc_code_instrumentation(), call_site_to_module_precondition_text(), comp_regions(), continuation_conditions(), dsc_code_parallelization(), generic_module_name_to_transformers(), generic_print_xml_application(), get_any_comp_regions_text(), get_continuation_condition_text(), get_semantic_text(), hbdsc_parallelization(), init_convex_in_out_regions(), init_convex_rw_regions(), init_convex_summary_in_out_regions(), init_convex_summary_rw_regions(), initial_precondition(), isolate_statement(), kernel_data_mapping(), kernel_load_store_engine(), module_name_to_preconditions(), module_name_to_total_preconditions(), out_regions_from_caller_to_callee(), partial_eval(), phrase_comEngine_distributor(), phrase_distributor(), phrase_distributor_control_code(), pragma_outliner(), print_initial_precondition(), print_program_precondition(), program_precondition(), safescale_distributor(), safescale_module_analysis(), sequence_dependence_graph(), solve_hardware_constraints(), spire_distributed_unstructured_to_structured(), summary_precondition(), summary_total_postcondition(), and update_precondition_with_call_site_preconditions().
|
static |
Definition at line 76 of file mappings.c.
References CONTRAINTE_UNDEFINED, contraintes_free(), and equivalence_equalities.
Referenced by module_to_value_mappings().
transformer tf_equivalence_equalities_add | ( | transformer | tf | ) |
mappings.c
I need here a contraintes_dup() that is not yet available in Linear and I cannot change Linear just before the DRET meeting; I've got to modify transformer_equalities_add() and to give it a behavior different from transformer_equality_add()
tf | f |
Definition at line 83 of file mappings.c.
References equivalence_equalities, and transformer_equalities_add().
Referenced by statement_to_postcondition(), and statement_to_total_precondition().
void upwards_vect_rename | ( | Pvecteur | v, |
transformer | post | ||
) |
Renaming of variables in v according to transformations occuring later.
If a variable is modified by post, its old value must be used in v
FI: it would probably ne more efficient to scan va and vb than the argument list...
post | ost |
Definition at line 1062 of file mappings.c.
References ENTITY, FOREACH, new_value_to_old_value(), transformer_arguments, and vect_variable_rename().
Referenced by add_declaration_list_information(), add_reference_information(), and transformer_add_integer_relation_information().
transform a vector based on variable entities into a vector based on new value entities when possible; does nothing most of the time; does a little in the presence of equivalenced variables
Ugly because it has a hidden side effect on v to handle Fortran equivalences and because its implementation is dependent on type Pvecteur.
Assume that the value mappings are available (as implied by the function's name!), which may not be true when dealing with call sites.
The variable may denote a constant with compatible type
or a temporary variable
Or a variable value
Or a phi variable, when transformers are computed by the region analysis
Or the vector cannot be used in the semantics analysis
iv | v |
Definition at line 924 of file mappings.c.
References analyzed_constant_p(), entity_constant_p, entity_has_values_p(), entity_to_new_value(), entity_undefined, local_temporary_value_entity_p(), Svecteur::succ, TCST, variable_phi_p, VECTEUR_NUL_P, and vecteur_var.
Referenced by add_affine_bound_conditions(), add_declaration_list_information(), add_loop_index_exit_value(), add_loop_skip_condition(), add_reference_information(), affine_to_transformer(), integer_divide_to_transformer(), integer_right_shift_to_transformer(), simple_affine_to_transformer(), transformer_add_integer_relation_information(), and transformer_add_loop_index_incrementation().
|
static |
Definition at line 578 of file mappings.c.
References add_values_for_simple_effects_of_statement(), gen_null(), gen_recurse, get_bool_property(), get_current_module_statement(), pips_user_warning, and statement_domain.
Referenced by module_to_value_mappings().
Definition at line 982 of file mappings.c.
References CONS, ENTITY, entity_has_values_p(), entity_to_new_value(), entity_to_old_value(), and NIL.
Referenced by statement_to_postcondition().
void variables_to_new_values | ( | Pvecteur | v | ) |
replace variables by new values which is necessary for equivalenced variables
Definition at line 1038 of file mappings.c.
References entity_to_new_value(), TCST, vect_variable_rename(), VECTEUR_NUL_P, vecteur_succ, VECTEUR_UNDEFINED, and vecteur_var.
Referenced by transformer_add_integer_relation_information().
list_mod | ist_mod |
Definition at line 1024 of file mappings.c.
References CONS, ENTITY, entity_to_old_value(), MAP, and NIL.
Referenced by recompute_loop_transformer().
list_mod | ist_mod |
Definition at line 966 of file mappings.c.
References CONS, ENTITY, entity_has_values_p(), entity_to_new_value(), entity_to_old_value(), FOREACH, and NIL.
Referenced by recompute_loop_transformer(), and statement_to_postcondition().
|
static |
Variable value mappings package.
Establish mappings between analyzed scalar variable entities and variable value entities for a given module (see transformer/value.c).
Handle static aliasing in Fortran, i.e. equivalences too.
Cannot handle more than one module at a time: no recursivity on modules or chaos will occur.
See package value.c for more information on functions more or less independent of the internal representation.
Francois Irigoin, 20 April 1990 To convert non constant effects into constant effects FORTRAN 77 EQUIVALENCE
Definition at line 74 of file mappings.c.
Referenced by add_equivalence_equality(), reset_equivalence_equalities(), and tf_equivalence_equalities_add().