PIPS
points_to.c File Reference
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "linear.h"
#include "misc.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "effects-util.h"
#include "resources.h"
#include "pipsdbm.h"
#include "transformer.h"
#include "semantics.h"
#include "effects-generic.h"
#include "effects-convex.h"
#include "pips-libs.h"
+ Include dependency graph for points_to.c:

Go to the source code of this file.

Functions

set safe_user_call_to_points_to_interprocedural_binding_set (entity callee __attribue__((unused)), list real_args __attribue__((unused)))
 Interface with points-to library. More...
 
static list backward_translation_of_points_to_formal_context_effect (_UNUSED_ entity callee, _UNUSED_ list real_args, _UNUSED_ effect eff _UNUSED_ set binding)
 
list effects_lhs_expression_to_sources (expression e)
 Returns a list of cells corresponding to the possibles values, i.e. More...
 
list effects_lhs_expression_to_sinks (expression e)
 Returns a list of cells corresponding to the value,i.e. More...
 
list cells_to_read_or_write_effects (list cl, bool write_p)
 
list cells_to_write_effects (list cl)
 
list cells_to_read_effects (list cl)
 

Function Documentation

◆ backward_translation_of_points_to_formal_context_effect()

static list backward_translation_of_points_to_formal_context_effect ( _UNUSED_ entity  callee,
_UNUSED_ list  real_args,
_UNUSED_ effect eff _UNUSED_ set  binding 
)
static

Definition at line 331 of file points_to.c.

333 {
334  pips_internal_error("points-to library not available");
335  return NIL;
336 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define pips_internal_error
Definition: misc-local.h:149

References NIL, and pips_internal_error.

◆ cells_to_read_effects()

list cells_to_read_effects ( list  cl)
Parameters
cll

Definition at line 467 of file points_to.c.

468 {
469  return cells_to_read_or_write_effects(cl, false);
470 }
list cells_to_read_or_write_effects(list cl, bool write_p)
Definition: points_to.c:377

References cells_to_read_or_write_effects().

+ Here is the call graph for this function:

◆ cells_to_read_or_write_effects()

list cells_to_read_or_write_effects ( list  cl,
bool  write_p 
)
Parameters
cll
write_prite_p

Definition at line 377 of file points_to.c.

378 {
379  // (*reference_to_effect_func)
380  list wel = NIL;
381  size_t n = gen_length(cl);
382  size_t u = 0; // number of useless cells
383  FOREACH(CELL, c, cl) {
385  if(nowhere_cell_p(c)) {
386  if(n==1 || n==1+u) {
387  // Would it be better to move on with a simple warning?
388  pips_user_error("Dereferencing of an undefined pointer.\n");
389  }
390  else {
391  ; // ignore
392  }
393  u++;
394  }
395  else if(null_cell_p(c)) {
396  if(n==1 || n==1+u)
397  pips_user_error("Dereferencing of a null pointer.\n");
398  else {
399  ; // ignore
400  }
401  u++;
402  }
403  else {
405  //descriptor d = make_descriptor_none();
406  if(cell_abstract_location_p(c)) {
407  // This may always capture heap locations, although they may
408  // sometimes be concrete
409  // approximation ap = make_approximation_may();
411  e = (*reference_to_effect_func)(r, a, false); // , ap, d);
412  }
413  else {
415  e = (*reference_to_effect_func)(r, a, false); // , ap, d);
416  if(n==1 || n==1+u) {
417  // approximation ap = make_approximation_exact();
418  // e = make_effect(c, a, ap, d);
419  ;
420  }
421  else {
422  // FI: it could be exact with n>1 if alternatives are null
423  // and undefined
424  //approximation ap = make_approximation_may();
425  // e = make_effect(c, a, ap, d);
426  ;
427  }
428  }
429  // Adjust type, which implies a may approximation
431  int msn = type_depth(t);
432  if(msn>0) {
439  }
440  entity re = reference_variable(r);
442  // FI: we hope that heap entities are not included here
443  pips_assert("Not a heap abstraction", !entity_heap_location_p(re));
446  reference_variable(r) = nre;
448  reference_indices(r) = NIL;
449  }
450  }
451  }
452  if(!effect_undefined_p(e))
453  wel = gen_nconc(wel, CONS(EFFECT, e, wel));
454  }
455 
458 
459  return wel;
460 }
approximation make_approximation_may(void)
Definition: effects.c:179
void free_approximation(approximation p)
Definition: effects.c:135
bool entity_heap_location_p(entity b)
package abstract location.
entity entity_typed_anywhere_locations(type t)
bool entity_typed_anywhere_locations_p(entity e)
Test if an entity is the bottom of the lattice.
void add_precondition_information_to_effects(list)
void effects_to_proper_approximation(list)
type points_to_reference_to_concrete_type(reference)
Definition: type.c:685
reference cell_any_reference(cell)
API for reference.
Definition: effects.c:77
action make_action_write_memory(void)
To ease the extension of action with action_kind.
Definition: effects.c:1011
type points_to_cell_to_concrete_type(cell)
Definition: type.c:676
bool nowhere_cell_p(cell)
Target of an undefined pointer.
Definition: effects.c:455
action make_action_read_memory(void)
Definition: effects.c:1017
bool cell_abstract_location_p(cell)
Definition: effects.c:273
bool null_cell_p(cell)
Definition: effects.c:466
#define effect_undefined_p(x)
Definition: effects.h:615
#define approximation_exact_p(x)
Definition: effects.h:369
#define effect_undefined
Definition: effects.h:614
#define CELL(x)
CELL.
Definition: effects.h:424
#define effect_approximation(x)
Definition: effects.h:644
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
void gen_full_free_list(list l)
Definition: genClib.c:1023
size_t gen_length(const list l)
Definition: list.c:150
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#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
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_user_error
Definition: misc-local.h:147
list make_unbounded_subscripts(int d)
FI: this piece of code must have been duplicated somewhere else in an effect library.
Definition: expression.c:4346
size_t type_depth(type)
Number of steps to access the lowest leave of type t without dereferencing.
Definition: type.c:4880
#define reference_variable(x)
Definition: ri.h:2326
#define reference_indices(x)
Definition: ri.h:2328
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References add_precondition_information_to_effects(), approximation_exact_p, CELL, cell_abstract_location_p(), cell_any_reference(), CONS, EFFECT, effect_approximation, effect_undefined, effect_undefined_p, effects_to_proper_approximation(), entity_heap_location_p(), entity_typed_anywhere_locations(), entity_typed_anywhere_locations_p(), FOREACH, free_approximation(), gen_full_free_list(), gen_length(), gen_nconc(), make_action_read_memory(), make_action_write_memory(), make_approximation_may(), make_unbounded_subscripts(), NIL, nowhere_cell_p(), null_cell_p(), pips_assert, pips_user_error, points_to_cell_to_concrete_type(), points_to_reference_to_concrete_type(), reference_indices, reference_variable, and type_depth().

Referenced by cells_to_read_effects(), and cells_to_write_effects().

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

◆ cells_to_write_effects()

list cells_to_write_effects ( list  cl)
Parameters
cll

Definition at line 462 of file points_to.c.

463 {
464  return cells_to_read_or_write_effects(cl, true);
465 }

References cells_to_read_or_write_effects().

+ Here is the call graph for this function:

◆ effects_lhs_expression_to_sinks()

list effects_lhs_expression_to_sinks ( expression  e)

Returns a list of cells corresponding to the value,i.e.

abstract or concrete locations, denoted by lhs expression e.

If "p" is a pointer, expression "p" has "p" as a source, and the sources of "*p" as sinks.

This should work whether the points-to library is available or not, but it is not yet the case

The prefix effects_ is used to have a local copy in the effects-generic library.

We expect here a test about points-to availability and a work around if the points-to library is not linked.

Definition at line 369 of file points_to.c.

370 {
371  /* We expect here a test about points-to availability and a work
372  * around if the points-to library is not linked.
373  */
375 }
list effects_expression_to_points_to_sinks(expression)

References effects_expression_to_points_to_sinks().

+ Here is the call graph for this function:

◆ effects_lhs_expression_to_sources()

list effects_lhs_expression_to_sources ( expression  e)

Returns a list of cells corresponding to the possibles values, i.e.

abstract or concrete locations, denoted by lhs expression e.

This should work whether the points-to library is available or not, but it is not yet the case.

The prefix effects_ is used to have a local copy in the effects-generic library.

We expect here a test about points-to availability and a work around if the points-to library is not linked.

Definition at line 349 of file points_to.c.

350 {
351  /* We expect here a test about points-to availability and a work
352  * around if the points-to library is not linked.
353  */
355 }
list effects_expression_to_points_to_sources(expression)
points_to.c

References effects_expression_to_points_to_sources().

+ Here is the call graph for this function:

◆ safe_user_call_to_points_to_interprocedural_binding_set()

set safe_user_call_to_points_to_interprocedural_binding_set ( entity callee   __attribue__(unused),
list real_args   __attribue__(unused) 
)

Interface with points-to library.

Definition at line 324 of file points_to.c.

326 {
327  set binding = set_undefined;
328  return binding;
329 }
#define set_undefined
Definition: newgen_set.h:48
FI: I do not understand why the type is duplicated at the set level.
Definition: set.c:59

References set_undefined.