PIPS
passes.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "effects-util.h"
#include "misc.h"
#include "properties.h"
#include "effects-generic.h"
#include "pipsdbm.h"
#include "points-to.h"
+ Include dependency graph for passes.c:

Go to the source code of this file.

Macros

#define FRANCOIS   1
 

Functions

void points_to_storage (set pts_to_set, statement s, bool store)
 Store a sorted copy of the points-to pts_to_set associated to a statement s in the points-to hash-table. More...
 
void fi_points_to_storage (pt_map ptm, statement s, bool store)
 
pt_map points_to_to_context_points_to (pt_map in)
 Return the subset of "in" that is related to formal parameters and stubs. More...
 
void init_points_to_context (pt_map init)
 
void reset_points_to_context ()
 
pt_map update_points_to_graph_with_arc (points_to a, pt_map pt)
 Instead of simply adding the new arc, make sure the consistency is not broken. More...
 
void add_arc_to_points_to_context (points_to pt)
 FI: it should rather work the other way round, with add_arc_to_statement_points_to_context() calling add_arc_to_points_to_context(). More...
 
void update_points_to_context_with_arc (points_to pt)
 Same as , but be careful about the arc before adding it to the points-to context. More...
 
pt_map get_points_to_context ()
 
void clean_up_points_to_stubs (entity module)
 
static bool generic_points_to_analysis (char *module_name)
 Pass INTRAPROCEDURAL_POINTS_TO_ANALYSIS. More...
 
bool init_points_to_analysis (char *module_name)
 
bool interprocedural_points_to_analysis_p ()
 
bool fast_interprocedural_points_to_analysis_p ()
 
bool intraprocedural_points_to_analysis (char *module_name)
 
bool interprocedural_points_to_analysis (char *module_name)
 
bool fast_interprocedural_points_to_analysis (char *module_name)
 
bool initial_points_to (char *name)
 Retrieve points-to that are statically initialized, especially in compilation units. More...
 
bool program_points_to (char *name)
 

Variables

static pt_map points_to_context = pt_map_undefined
 
static bool interprocedural_points_to_p = true
 
static bool fast_interprocedural_points_to_p = true
 

Macro Definition Documentation

◆ FRANCOIS

#define FRANCOIS   1

Definition at line 340 of file passes.c.

Function Documentation

◆ add_arc_to_points_to_context()

void add_arc_to_points_to_context ( points_to  pt)

FI: it should rather work the other way round, with add_arc_to_statement_points_to_context() calling add_arc_to_points_to_context().

Parameters
ptt

Definition at line 268 of file passes.c.

269 {
270  pips_assert("points_to_context is defined",
272  //(void) update_points_to_graph_with_arc(pt, points_to_context);
274  pips_assert("in is consistent", consistent_pt_map_p(points_to_context));
275  points_to npt = copy_points_to(pt);
277 }
points_to copy_points_to(points_to p)
POINTS_TO.
#define add_arc_to_pt_map(a, s)
#define pt_map_undefined_p(pt)
#define consistent_pt_map_p(s)
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
static pt_map points_to_context
Definition: passes.c:149
void add_arc_to_statement_points_to_context(points_to)
Definition: statement.c:104

References add_arc_to_pt_map, add_arc_to_statement_points_to_context(), consistent_pt_map_p, copy_points_to(), pips_assert, points_to_context, and pt_map_undefined_p.

Referenced by dereferencing_subscript_to_points_to(), formal_source_to_sinks(), generic_stub_source_to_sinks(), global_source_to_sinks(), and null_to_sinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clean_up_points_to_stubs()

void clean_up_points_to_stubs ( entity  module)

Beware of location entities that might depend on the soon to be deleted stub entities.

Parameters
moduleodule

Definition at line 303 of file passes.c.

304 {
306  list dl = code_declarations(c);
307  list sl = NIL;
308 
309  FOREACH(ENTITY, v, dl) {
311  sl = CONS(ENTITY, v, sl);
312  fprintf(stderr, "Removed stub: \"%s\"\n", entity_name(v));
313  }
314  }
315 
316  /* Beware of location entities that might depend on the soon to be
317  * deleted stub entities.
318  */
319  if(!ENDP(dl) && get_bool_property("SEMANTICS_ANALYZE_CONSTANT_PATH")) {
320  FOREACH(ENTITY, v, dl) {
322  value val = entity_initial(v);
323  reference r = value_reference(val); // guarded by location_entity_p()
324  entity rv = reference_variable(r);
325  if(gen_in_list_p(rv, dl)) {
326  sl = CONS(ENTITY, v, sl);
327  fprintf(stderr, "Removed location: \"%s\"\n", entity_name(v));
328  }
329  }
330  }
331  }
332 
334 
335  GenericCleanEntities(sl, module, false);
336 
337  gen_free_list(sl);
338 }
bool entity_heap_location_p(entity b)
package abstract location.
bool stub_entity_of_module_p(entity s, entity m)
void GenericCleanEntities(list el, entity function, bool fortran_p)
Useful when the user edit a source file and parse it again or when a program transformation is perfor...
Definition: clean.c:63
bool location_entity_of_module_p(entity, entity)
Definition: locations.c:360
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
void gen_list_and_not(list *a, const list b)
Compute A = A inter non B:
Definition: list.c:963
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
static char * module
Definition: pips.c:74
#define value_reference(x)
Definition: ri.h:3085
#define reference_variable(x)
Definition: ri.h:2326
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define code_declarations(x)
Definition: ri.h:784
#define entity_name(x)
Definition: ri.h:2790
#define value_code(x)
Definition: ri.h:3067
#define entity_initial(x)
Definition: ri.h:2796
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References code_declarations, CONS, ENDP, ENTITY, entity_heap_location_p(), entity_initial, entity_name, FOREACH, fprintf(), gen_free_list(), gen_in_list_p(), gen_list_and_not(), GenericCleanEntities(), get_bool_property(), location_entity_of_module_p(), module, NIL, reference_variable, stub_entity_of_module_p(), value_code, and value_reference.

Referenced by generic_points_to_analysis().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fast_interprocedural_points_to_analysis()

bool fast_interprocedural_points_to_analysis ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 574 of file passes.c.

575 {
579 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
static bool fast_interprocedural_points_to_p
Definition: passes.c:549
static bool generic_points_to_analysis(char *module_name)
Pass INTRAPROCEDURAL_POINTS_TO_ANALYSIS.
Definition: passes.c:345
static bool interprocedural_points_to_p
Definition: passes.c:548

References fast_interprocedural_points_to_p, generic_points_to_analysis(), interprocedural_points_to_p, and module_name().

+ Here is the call graph for this function:

◆ fast_interprocedural_points_to_analysis_p()

bool fast_interprocedural_points_to_analysis_p ( void  )

Definition at line 555 of file passes.c.

556 {
558 }

References fast_interprocedural_points_to_p.

Referenced by user_call_to_points_to(), and user_call_to_points_to_sinks().

+ Here is the caller graph for this function:

◆ fi_points_to_storage()

void fi_points_to_storage ( pt_map  ptm,
statement  s,
bool  store 
)
Parameters
ptmtm
storetore

Definition at line 97 of file passes.c.

97  {
98  list pt_list = NIL, tmp_l;
100  set pts_to_set = points_to_graph_set(ptm);
101  bool bottom_p = points_to_graph_bottom(ptm);
102 
103  if ( !set_empty_p(pts_to_set) && store == true ) {
104 
105  pt_list = set_to_sorted_list(pts_to_set,
106  (int(*)(const void*, const void*))
108  tmp_l = gen_full_copy_list(pt_list);
109  new_pt_list = make_points_to_list(bottom_p, tmp_l);
110  points_to_list_consistent_p(new_pt_list);
111  store_or_update_pt_to_list(s, new_pt_list);
112  }
113  else if(set_empty_p(pts_to_set)){
114  tmp_l = gen_full_copy_list(pt_list);
115  new_pt_list = make_points_to_list(bottom_p, tmp_l);
116  store_or_update_pt_to_list(s, new_pt_list);
117  }
118  gen_free_list(pt_list);
119 }
points_to_list make_points_to_list(bool a1, list a2)
bool points_to_list_consistent_p(points_to_list p)
void store_or_update_pt_to_list(statement, points_to_list)
int points_to_compare_cells(const void *, const void *)
Comparison of two points-to arcs based on their source and sink nodes.
Definition: prettyprint.c:295
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
bool set_empty_p(const set)
tell whether set s is empty.
Definition: set.c:367
list set_to_sorted_list(const set, gen_cmp_func_t)
Definition: set.c:447
#define points_to_list_undefined
#define points_to_graph_bottom(x)
#define points_to_graph_set(x)
FI: I do not understand why the type is duplicated at the set level.
Definition: set.c:59

References gen_free_list(), gen_full_copy_list(), make_points_to_list(), NIL, points_to_compare_cells(), points_to_graph_bottom, points_to_graph_set, points_to_list_consistent_p(), points_to_list_undefined, set_empty_p(), set_to_sorted_list(), and store_or_update_pt_to_list().

Referenced by statement_to_points_to().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generic_points_to_analysis()

static bool generic_points_to_analysis ( char *  module_name)
static

Pass INTRAPROCEDURAL_POINTS_TO_ANALYSIS.

In case we need effects to generate all necessary points-to information

Clean-up formal context stubs and heap model variables

Stack for on-demand update of in points-to information

Necessary to compute memory effects

Memory effects may be computed to avoid issues with side effects Three possible options: 1) a new expression_to_points_to() that does not take side effects into account, 2) an extension of condition_to_points_to() to take care of dereferencing as in expression_to_points_to(), or use memory effects to deal with side effect free expressions only.

Store the points-to relations

Remove dangling stubs... before the formal parameters are projected as the projection will create lots of dangling stubs. In fact, they are not dangling from a formal context view point.

Filter OUT points-to by deleting local variables, including the formal paprameters

FI: you would have to be much more specific about was is kept or not when the main function is exited... I am not sure it is a good idea. Potentially useful information about argv is lost. As well as useless information about memory leaks occuring at the end of the execution. Motsly an issue for validation.

Save IN points-to relations

Save OUT points-to relations

Definition at line 345 of file passes.c.

345  {
346  entity module;
347  statement module_stat;
348  pt_map pt_in = new_pt_map();
349  pt_map pts_to_out = new_pt_map();
350 
351  init_pt_to_list();
356  module_name, true));
357  module_stat = get_current_module_statement();
359 
360  debug_on("POINTS_TO_DEBUG_LEVEL");
361 
362  pips_debug(1, "considering module %s\n", module_name);
363 
364  /* In case we need effects to generate all necessary points-to information */
365  // These initializations are not sufficient. We also need at least a
366  // stack of statements
367  //set_constant_paths_p(true);
368  //set_pointer_info_kind(with_points_to);
369  //set_methods_for_proper_simple_effects();
370 
371  /* Clean-up formal context stubs and heap model variables */
373 
374  /* Stack for on-demand update of in points-to information */
376 
377  /*
378  Get the init_points_to_list resource.
379  This list contains formal paramters and their stub sinks
380  */
381  // #if !FRANCOIS: to simplify interface with effects_with_points_to
382  // FI: I would like not to use DBR_INIT_POINTS_TO_LIST because it
383  // generates useless information. However I need something as long
384  // as the empty points-to set is the attribute of dead code...
385  // Also, the init analysis uses the same modules but with another
386  // interface, which muddles the generation of stub cells with stars
387  // or zeros
388 #if 0
389  list pts_to_list = NIL;
390  points_to_list init_pts_to_list =
391  (points_to_list) db_get_memory_resource(DBR_INIT_POINTS_TO_LIST,
392  module_name, true);
393  /* Transform the list of init_pts_to_list in set of points-to.*/
394  pts_to_list = gen_full_copy_list(points_to_list_list(init_pts_to_list));
395  pt_in = graph_assign_list(pt_in, pts_to_list);
396  init_points_to_context(pt_in);
397  // FI: this should be useless as stubs are built on demand
398  // pt_in = set_assign_list(pt_in, NIL);
399  gen_free_list(pts_to_list);
400 #else
401  points_to_graph_set(pt_in) =
403  init_points_to_context(pt_in);
404 #endif
405 
406  /* Necessary to compute memory effects
407  *
408  * Memory effects may be computed to avoid issues with side effects
409  * Three possible options: 1) a new expression_to_points_to() that
410  * does not take side effects into account, 2) an extension of
411  * condition_to_points_to() to take care of dereferencing as in
412  * expression_to_points_to(), or use memory effects to deal with
413  * side effect free expressions only.
414  */
415  // set_methods_for_simple_effects();
416 
417  pts_to_out = statement_to_points_to(module_stat, pt_in);
418  /* Store the points-to relations */
420 
421  /* Remove dangling stubs... before the formal parameters are
422  projected as the projection will create lots of dangling
423  stubs. In fact, they are not dangling from a formal context view
424  point. */
425  // pts_to_out = remove_unreachable_vertices_in_points_to_graph(pts_to_out);
426  /* Filter OUT points-to by deleting local variables, including the
427  formal paprameters */
429  /* FI: you would have to be much more specific about was is kept
430  or not when the main function is exited... I am not sure it is
431  a good idea. Potentially useful information about argv is
432  lost. As well as useless information about memory leaks
433  occuring at the end of the execution. Motsly an issue for
434  validation. */
435  clear_pt_map(pts_to_out);
436  }
437  else
438  points_to_graph_set(pts_to_out) =
440 
441  /* Save IN points-to relations */
442 #if !FRANCOIS
443  list l_in = set_to_list(pt_in);
444  points_to_list in_list = make_points_to_list(true, l_in); // SG: baaaaaaad copy, let us hope AM will fix her code :p
445 #else
446  // pt_map context = points_to_to_context_points_to(pts_to_out);
448  // FI: not useful here, should be performed earlier I guess
449  // context = normalize_points_to_graph(context);
451  points_to_list in_list = make_points_to_list(false, l_in); // SG: baaaaaaad copy, let us hope AM will fix her code :p
452  // FI: I suppose context should be emptied because of the sharing
453  // with l_in and then freed
454 #endif
455  DB_PUT_MEMORY_RESOURCE(DBR_POINTS_TO_IN, module_name, in_list);
456 
457  /* Save OUT points-to relations */
458  list l_out =
460  bool out_bottom_p = points_to_graph_bottom(pts_to_out);
461  points_to_list out_list = make_points_to_list(out_bottom_p, l_out); // SG: baaaaaaad copy, let us hope AM will fix her code :p
462 
463  DB_PUT_MEMORY_RESOURCE(DBR_POINTS_TO_OUT, module_name, out_list);
464 
468  // FI: the depth of the free depends on pt_map
469  // free_pt_map(pts_to_out);
470  // free_pt_map(pt_in);
475  //generic_effects_reset_all_methods();
476  debug_off();
477  bool good_result_p = true;
478 
479  return (good_result_p);
480 }
#define clear_pt_map(pt)
#define new_pt_map()
void make_effects_private_current_context_stack(void)
void reset_effects_private_current_context_stack(void)
void init_pt_to_list(void)
void reset_pt_to_list(void)
statement_points_to get_pt_to_list(void)
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
set set_assign_list(set, const list)
assigns a list contents to a set all duplicated elements are lost
Definition: set.c:474
list set_to_list(const set)
create a list from a set the set is not freed
Definition: set.c:436
void init_points_to_context(pt_map init)
Definition: passes.c:151
void clean_up_points_to_stubs(entity module)
Definition: passes.c:303
pt_map get_points_to_context()
Definition: passes.c:298
void reset_points_to_context()
Definition: passes.c:158
void reset_statement_points_to_context(void)
Definition: statement.c:139
pt_map graph_assign_list(pt_map, list)
FI: I add functions dealing with points_to_graph variable, i.e.
void init_statement_points_to_context(void)
Definition: statement.c:90
pt_map statement_to_points_to(statement, pt_map)
See points_to_statement()
Definition: statement.c:154
set points_to_function_projection(set)
"pts" is the points-to relation existing at the return point of a function.
#define points_to_list_list(x)
struct _newgen_struct_points_to_list_ * points_to_list
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
bool entity_main_module_p(entity e)
Definition: entity.c:700
void free_statement_global_stack(void)
Definition: static.c:358
void make_statement_global_stack(void)
Definition: static.c:318
Definition: delay.c:253

References clean_up_points_to_stubs(), clear_pt_map, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, entity_main_module_p(), free_statement_global_stack(), gen_free_list(), gen_full_copy_list(), get_current_module_statement(), get_points_to_context(), get_pt_to_list(), graph_assign_list(), init_points_to_context(), init_pt_to_list(), init_statement_points_to_context(), make_effects_private_current_context_stack(), make_points_to_list(), make_statement_global_stack(), module, module_name(), module_name_to_entity(), new_pt_map, NIL, pips_debug, points_to_function_projection(), points_to_graph_bottom, points_to_graph_set, points_to_list_list, reset_current_module_entity(), reset_current_module_statement(), reset_effects_private_current_context_stack(), reset_points_to_context(), reset_pt_to_list(), reset_statement_points_to_context(), set_assign_list(), set_current_module_entity(), set_current_module_statement(), set_to_list(), and statement_to_points_to().

Referenced by fast_interprocedural_points_to_analysis(), interprocedural_points_to_analysis(), and intraprocedural_points_to_analysis().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_points_to_context()

pt_map get_points_to_context ( void  )

Definition at line 298 of file passes.c.

299 {
300  return points_to_context;
301 }

References points_to_context.

Referenced by generic_points_to_analysis().

+ Here is the caller graph for this function:

◆ init_points_to_analysis()

bool init_points_to_analysis ( char *  module_name)

Properties

Parameters
module_nameodule_name

Definition at line 483 of file passes.c.

484 {
485  entity module;
486  type t;
487  list pt_list = NIL, dl = NIL;
488  set pts_to_set = set_generic_make(set_private,
490  set formal_set = set_generic_make(set_private,
494 
495  t = entity_type(module);
496 
497  debug_on("POINTS_TO_DEBUG_LEVEL");
498 
499  pips_debug(1, "considering module \"%s\"\n", module_name);
500 
501  /* Properties */
502  if(get_bool_property("ALIASING_ACROSS_FORMAL_PARAMETERS"))
503  pips_user_warning("Property ALIASING_ACROSS_FORMAL_PARAMETERS"
504  " is ignored\n");
505  if(get_bool_property("ALIASING_ACROSS_TYPES"))
506  pips_user_warning("Property ALIASING_ACROSS_TYPES"
507  " is ignored\n");
508  if(get_bool_property("ALIASING_INSIDE_DATA_STRUCTURE"))
509  pips_user_warning("Property ALIASING_INSIDE_DATA_STRUCTURE"
510  " is ignored\n");
511 
512  if(type_functional_p(t)){
514 
515  FOREACH(ENTITY, fp, dl) {
516  if(formal_parameter_p(fp)) {
517  reference r = make_reference(fp, NIL);
518  cell c = make_cell_reference(r);
519  formal_set = formal_points_to_parameter(c);
520  pts_to_set = set_union(pts_to_set, pts_to_set,
521  formal_set);
522  }
523  }
524 
525  }
526  else
527  pips_user_error("The module %s is not a function.\n", module_name);
528 
529  pt_list = set_to_sorted_list(pts_to_set,
530  (int(*)
531  (const void*,const void*))
533  points_to_list init_pts_to_list = make_points_to_list(false, pt_list);
534  points_to_list_consistent_p(init_pts_to_list);
536  (DBR_INIT_POINTS_TO_LIST, module_name, init_pts_to_list);
538  set_clear(pts_to_set);
539  set_clear(pts_to_set);
540  set_free(pts_to_set);
541  set_free(formal_set);
542  debug_off();
543 
544  bool good_result_p = true;
545  return (good_result_p);
546 }
cell make_cell_reference(reference _field_)
Definition: effects.c:293
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define pips_user_warning
Definition: misc-local.h:146
#define pips_user_error
Definition: misc-local.h:147
set set_generic_make(set_type, hash_equals_t, hash_rank_t)
what about this replacement? #define SET_MAP(the_item, the_code, the_set) \ { SET_FOREACH(void *,...
Definition: set.c:83
void set_free(set)
Definition: set.c:332
set set_clear(set)
Assign the empty set to s s := {}.
Definition: set.c:326
set set_union(set, const set, const set)
Definition: set.c:211
@ set_private
Definition: newgen_set.h:45
set formal_points_to_parameter(cell)
We want a recursive descent on the type of the formal parameter, once we found a pointer type we begu...
_uint points_to_rank(const void *, size_t)
create a key which is a concatenation of the source's name, the sink's name and the approximation of ...
int points_to_equal_p(const void *, const void *)
returns true if two points-to arcs "vpt1" and "vpt2" are equal.
Definition: points_to_set.c:98
bool formal_parameter_p(entity)
Definition: variable.c:1489
#define type_functional_p(x)
Definition: ri.h:2950
#define entity_type(x)
Definition: ri.h:2792

References code_declarations, DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, ENTITY, entity_initial, entity_type, FOREACH, formal_parameter_p(), formal_points_to_parameter(), get_bool_property(), get_current_module_entity(), make_cell_reference(), make_points_to_list(), make_reference(), module, module_name(), module_name_to_entity(), NIL, pips_debug, pips_user_error, pips_user_warning, points_to_compare_cells(), points_to_equal_p(), points_to_list_consistent_p(), points_to_rank(), reset_current_module_entity(), set_clear(), set_current_module_entity(), set_free(), set_generic_make(), set_private, set_to_sorted_list(), set_union(), type_functional_p, and value_code.

+ Here is the call graph for this function:

◆ init_points_to_context()

void init_points_to_context ( pt_map  init)
Parameters
initnit

Definition at line 151 of file passes.c.

152 {
153  pips_assert("points_to_context is undefined",
156 }
pt_map full_copy_pt_map(pt_map)
Definition: statement.c:67
static int init
Maximal value set for Fortran 77.
Definition: entity.c:320

References full_copy_pt_map(), init, pips_assert, points_to_context, and pt_map_undefined_p.

Referenced by generic_points_to_analysis().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initial_points_to()

bool initial_points_to ( char *  name)

Retrieve points-to that are statically initialized, especially in compilation units.

At least, useful for debugging

Could we retrieve initializations of static variables?

Parameters
nameame

Definition at line 582 of file passes.c.

583 {
586 
587  debug_on("POINTS_TO_DEBUG_LEVEL");
588 
589  /* At least, useful for debugging */
591  //set_current_module_statement( (statement)
592  // db_get_memory_resource(DBR_CODE, name, true));
593 
594  if(compilation_unit_p(name)) {
595  points_to_list ptl_out =
596  (points_to_list) db_get_memory_resource(DBR_POINTS_TO_OUT, name, true);
597  ptl_init = copy_points_to_list(ptl_out);
598  }
599  else {
600  /* Could we retrieve initializations of static variables? */
601  ptl_init = make_points_to_list(true, NIL);
602  }
603 
604  DB_PUT_MEMORY_RESOURCE(DBR_INITIAL_POINTS_TO, strdup(name), (char*) ptl_init);
605 
607  //reset_current_module_statement();
608 
609  debug_off();
610  return true;
611 }
points_to_list copy_points_to_list(points_to_list p)
POINTS_TO_LIST.
bool compilation_unit_p(const char *module_name)
The names of PIPS entities carry information about their nature.
Definition: entity_names.c:56
char * strdup()

References compilation_unit_p(), copy_points_to_list(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, make_points_to_list(), module, module_name_to_entity(), NIL, points_to_list_undefined, reset_current_module_entity(), set_current_module_entity(), and strdup().

+ Here is the call graph for this function:

◆ interprocedural_points_to_analysis()

bool interprocedural_points_to_analysis ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 567 of file passes.c.

References fast_interprocedural_points_to_p, generic_points_to_analysis(), interprocedural_points_to_p, and module_name().

+ Here is the call graph for this function:

◆ interprocedural_points_to_analysis_p()

bool interprocedural_points_to_analysis_p ( void  )

Definition at line 550 of file passes.c.

551 {
553 }

References interprocedural_points_to_p.

Referenced by user_call_to_points_to(), and user_call_to_points_to_sinks().

+ Here is the caller graph for this function:

◆ intraprocedural_points_to_analysis()

bool intraprocedural_points_to_analysis ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 560 of file passes.c.

561 {
565 }

References fast_interprocedural_points_to_p, generic_points_to_analysis(), interprocedural_points_to_p, and module_name().

+ Here is the call graph for this function:

◆ points_to_storage()

void points_to_storage ( set  pts_to_set,
statement  s,
bool  store 
)

Store a sorted copy of the points-to pts_to_set associated to a statement s in the points-to hash-table.

passes.c

In case s is a loop, do, while or for, the parameter "store" is set to false to prevent key redefinitions in the underlying points-to hash-table. This entry condition is not checked.

In case s is a sequence, the sorted copy pts_to_set is associated to each substatement and shared by s and all its substatement.

Note: the function is called with store==true from points_to_whileloop(). And the hash-table can be updated (hash_update()).

Parameters
pts_to_setts_to_set
storetore

Definition at line 67 of file passes.c.

67  {
68  list pt_list = NIL, tmp_l;
70 
71  if ( !set_empty_p(pts_to_set) && store == true ) {
72 
73  pt_list = set_to_sorted_list(pts_to_set,
74  (int(*)(const void*, const void*))
76  tmp_l = gen_full_copy_list(pt_list);
77  new_pt_list = make_points_to_list(true, tmp_l);
78  points_to_list_consistent_p(new_pt_list);
79  store_or_update_pt_to_list(s, new_pt_list);
80 
82  if(instruction_sequence_p(i)) {
85  store_or_update_pt_to_list(stm, new_pt_list);
86  }
87  }
88  }
89  else if(set_empty_p(pts_to_set)){
90  tmp_l = gen_full_copy_list(pt_list);
91  new_pt_list = make_points_to_list(true, tmp_l);
92  store_or_update_pt_to_list(s, new_pt_list);
93  }
94  gen_free_list(pt_list);
95 }
#define instruction_sequence_p(x)
Definition: ri.h:1512
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_sequence(x)
Definition: ri.h:1514
#define statement_instruction(x)
Definition: ri.h:2458

References FOREACH, gen_free_list(), gen_full_copy_list(), instruction_sequence, instruction_sequence_p, make_points_to_list(), NIL, points_to_compare_cells(), points_to_list_consistent_p(), points_to_list_undefined, sequence_statements, set_empty_p(), set_to_sorted_list(), statement_instruction, and store_or_update_pt_to_list().

+ Here is the call graph for this function:

◆ points_to_to_context_points_to()

pt_map points_to_to_context_points_to ( pt_map  in)

Return the subset of "in" that is related to formal parameters and stubs.

More care should be taken about formal parameter modifications. Dummy initial variables should be allocated to preserve the values of formal parameters on entry.

Parameters
inn

Definition at line 127 of file passes.c.

128 {
129  pt_map out = new_pt_map();
130  set in_s = points_to_graph_set(in);
131  set out_s = points_to_graph_set(out);
132 
133  SET_FOREACH(points_to, pt, in_s) {
134  cell source = points_to_source(pt);
136  || stub_points_to_cell_p(source)) {
137  cell sink = points_to_sink(pt);
138  if(stub_points_to_cell_p(sink)) {
139  points_to npt = copy_points_to(pt);
140  add_arc_to_simple_pt_map(npt, out_s);
141  }
142  }
143  }
144 
145  return out;
146 }
#define add_arc_to_simple_pt_map(a, s)
static FILE * out
Definition: alias_check.c:128
bool formal_parameter_points_to_cell_p(cell)
Definition: points_to.c:99
bool stub_points_to_cell_p(cell)
Definition: points_to.c:108
#define SET_FOREACH(type_name, the_item, the_set)
enumerate set elements in their internal order.
Definition: newgen_set.h:78
#define points_to_sink(x)
#define points_to_source(x)

References add_arc_to_simple_pt_map, copy_points_to(), formal_parameter_points_to_cell_p(), new_pt_map, out, points_to_graph_set, points_to_sink, points_to_source, SET_FOREACH, and stub_points_to_cell_p().

+ Here is the call graph for this function:

◆ program_points_to()

bool program_points_to ( char *  name)
Parameters
nameame

Definition at line 613 of file passes.c.

614 {
615  //transformer t = transformer_identity();
617  int i, nmodules;
618  gen_array_t modules;
619  // list e_inter = NIL;
620  list pptl = NIL; // Program points-to list
621 
622  pips_assert("main was found", the_main!=entity_undefined);
623 
624  debug_on("POINTS_TO_DEBUG_LEVEL");
625  pips_debug(1, "considering program \"%s\" with main \"%s\"\n", name,
626  module_local_name(the_main));
627 
628  set_current_module_entity(the_main);
630  db_get_memory_resource(DBR_CODE,
631  module_local_name(the_main),
632  true));
633  modules = db_get_module_list();
634  nmodules = gen_array_nitems(modules);
635  pips_assert("some modules in the program", nmodules>0);
636 
637  for(i=0; i<nmodules; i++) {
638  string mname = gen_array_item(modules, i);
639  pips_debug(1, "considering module %s\n", mname);
640 
641  // Module initial points-to list
642  points_to_list mptl =
644  db_get_memory_resource(DBR_INITIAL_POINTS_TO, mname, true));
645  if(!points_to_list_bottom(mptl)) {
646  // FI: a bit simplistic if C standard allows double definitions...
647  pptl = gen_nconc(pptl, points_to_list_list(mptl));
648  }
649  }
650 
651  points_to_list program_ptl = make_points_to_list(false, pptl);
652  DB_PUT_MEMORY_RESOURCE(DBR_PROGRAM_POINTS_TO, "", (void *) program_ptl);
653 
656 
657  gen_array_full_free(modules);
658 
659  debug_off();
660  return true;
661 }
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
void gen_array_full_free(gen_array_t a)
Definition: array.c:77
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
gen_array_t db_get_module_list(void)
Get an array of all the modules (functions, procedures and compilation units) of a workspace.
Definition: database.c:1266
string get_main_entity_name(void)
Return the local name of the main module if it is available, or the local name of any module by defau...
Definition: util.c:63
#define points_to_list_bottom(x)
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
#define entity_undefined
Definition: ri.h:2761

References copy_points_to_list(), db_get_memory_resource(), db_get_module_list(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, entity_undefined, gen_array_full_free(), gen_array_item(), gen_array_nitems(), gen_nconc(), get_main_entity_name(), make_points_to_list(), module_local_name(), module_name_to_entity(), NIL, pips_assert, pips_debug, points_to_list_bottom, points_to_list_list, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), and set_current_module_statement().

+ Here is the call graph for this function:

◆ reset_points_to_context()

void reset_points_to_context ( void  )

Definition at line 158 of file passes.c.

159 {
160  pips_assert("points_to_context is defined",
162  // Deep when pt_map is a Newgen object
163  // free_pt_map(points_to_context); // Shallow if pt_map==set
165 }
#define pt_map_undefined

References pips_assert, points_to_context, pt_map_undefined, and pt_map_undefined_p.

Referenced by generic_points_to_analysis().

+ Here is the caller graph for this function:

◆ update_points_to_context_with_arc()

void update_points_to_context_with_arc ( points_to  pt)

Same as , but be careful about the arc before adding it to the points-to context.

This function is used to update the contexts when dealing with global variables at a call site.

Parameters
ptt

Definition at line 285 of file passes.c.

286 {
287  pips_assert("points_to_context is defined",
289  // Copy "pt" before it may be freed by update_points_to_graph_with_arc()
290  points_to npt = copy_points_to(pt);
292  //add_arc_to_pt_map(pt, points_to_context);
293  pips_assert("in is consistent", consistent_pt_map_p(points_to_context));
294  //add_arc_to_statement_points_to_context(npt);
296 }
pt_map update_points_to_graph_with_arc(points_to a, pt_map pt)
Instead of simply adding the new arc, make sure the consistency is not broken.
Definition: passes.c:183
void update_statement_points_to_context_with_arc(points_to)
Definition: statement.c:112

References consistent_pt_map_p, copy_points_to(), pips_assert, points_to_context, pt_map_undefined_p, update_points_to_graph_with_arc(), and update_statement_points_to_context_with_arc().

Referenced by filter_formal_context_according_to_actual_context(), new_filter_formal_context_according_to_actual_context(), and new_recursive_filter_formal_context_according_to_actual_context_for_pointer_pair().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_points_to_graph_with_arc()

pt_map update_points_to_graph_with_arc ( points_to  a,
pt_map  pt 
)

Instead of simply adding the new arc, make sure the consistency is not broken.

If "a" is an exact arc starting from source "s_a" and pointing to destination "d_a" and if "pt" contains may arcs or an exact arc s->d, these arcs must be removed. Vice-versa, if "a=(s_a,d_a)" is a may arc and if "pt" contain an exact arc (s,d)...

FI: I am cheating and doing exactly what I need to deal with global variables at call sites...

FI: issue with the commented out free() below: the caller doesn't know that the object may be freed and may reuse it later, for instance to make a copy of it...

Argument a is either included in pt or freed. it cannot be used after the call.

Arc a is already in relation pt

ap_b must be exact

Same source, different destinations

We are in trouble if both arcs carry approximation exact...

Arc b is less precise and mut be removed to avoid a conflict

Two may arcs: they are compatible but this may be invalidated later by another arc in pt, for isntance making a redundant.

The sources are different

Parameters
ptt

Definition at line 183 of file passes.c.

184 {
185  // Default functionality
186  // add_arc_to_pt_map(a, pt);
187 
188  cell s_a = points_to_source(a);
190  list dl = NIL; // delete list
191  list nl = NIL; // new list
192  bool found_p = false;
193  bool freed_p = false; // nl could be cleaned up instead at each free
194  set pt_s = points_to_graph_set(pt);
195 
196  SET_FOREACH(points_to, b, pt_s) {
197  cell s_b = points_to_source(b);
198  if(points_to_cell_equal_p(s_a, s_b)) {
199  cell d_a = points_to_sink(a);
200  cell d_b = points_to_sink(b);
202  found_p = true;
203  if(points_to_cell_equal_p(d_a, d_b)) {
204  if(approximation_tag(ap_a)==approximation_tag(ap_b)) {
205  /* Arc a is already in relation pt*/
206  //free_points_to(a);
207  freed_p = true;
208  }
209  else if(approximation_may_p(ap_a)) {
210  /* ap_b must be exact */
211  //free_points_to(a); // a is of no use because the context is stricter
212  freed_p = true;
213  }
214  }
215  else { /* Same source, different destinations */
216  /* We are in trouble if both arcs carry approximation exact... */
217  if(approximation_exact_p(ap_a)) {
218  if(approximation_exact_p(ap_b)) {
219  pips_internal_error("Conflicting arcs.\n"); // we are in trouble
220  }
221  else {
222  /* Arc b is less precise and mut be removed to avoid a conflict */
223  dl = CONS(POINTS_TO, b, dl);
224  }
225  }
226  else {
227  if(approximation_exact_p(ap_b)) {
228  // pips_internal_error("Conflicting arcs.\n"); // we are in trouble
229  // But the may arc is included in the exact arc already in pt
230  //free_points_to(a);
231  freed_p = true;
232  }
233  else {
234  /* Two may arcs: they are compatible but this may be
235  invalidated later by another arc in pt, for isntance
236  making a redundant. */
237  nl = CONS(POINTS_TO, a, nl);
238  }
239  }
240  }
241  }
242  else {
243  /* The sources are different */
244  ; // ignore this arc from pt
245  }
246  }
247 
248  if(found_p) {
249  FOREACH(POINTS_TO, d, dl)
250  remove_arc_from_pt_map(d, pt);
251 
252  // 0 or 1 element, which must be "a", which may have been freed
253  // after insertion in nl
254  FOREACH(POINTS_TO, n, nl)
255  if(!freed_p)
256  add_arc_to_pt_map(n, pt);
257  }
258  else
259  add_arc_to_pt_map(a, pt);
260 
261  return pt;
262 }
#define remove_arc_from_pt_map(a, s)
bool points_to_cell_equal_p(cell, cell)
Definition: points_to.c:916
#define approximation_tag(x)
Definition: effects.h:362
#define approximation_exact_p(x)
Definition: effects.h:369
#define approximation_may_p(x)
Definition: effects.h:363
#define pips_internal_error
Definition: misc-local.h:149
#define points_to_approximation(x)
#define POINTS_TO(x)
POINTS_TO.

References add_arc_to_pt_map, approximation_exact_p, approximation_may_p, approximation_tag, CONS, FOREACH, NIL, pips_internal_error, POINTS_TO, points_to_approximation, points_to_cell_equal_p(), points_to_graph_set, points_to_sink, points_to_source, remove_arc_from_pt_map, and SET_FOREACH.

Referenced by update_points_to_context_with_arc(), and update_statement_points_to_context_with_arc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ fast_interprocedural_points_to_p

◆ interprocedural_points_to_p

◆ points_to_context