PIPS
eval.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "misc.h"
#include "text-util.h"
#include "newgen_set.h"
#include "points_to_private.h"
#include "pointer_values.h"
#include "effects-generic.h"
#include "effects-simple.h"
+ Include dependency graph for eval.c:

Go to the source code of this file.

Functions

bool simple_cell_reference_preceding_p (reference r1, descriptor __attribute__((unused)) d1, reference r2, descriptor __attribute__((unused)) d2, transformer __attribute__((unused)) current_precondition, bool strict_p, bool *exact_p)
 
bool simple_cell_preceding_p (cell c1, descriptor d1, cell c2, descriptor d2, transformer current_precondition, bool strict_p, bool *exact_p)
 
bool path_preceding_p (effect eff1, effect eff2, transformer current_precondition, bool strict_p, bool *exact_p)
 
void simple_reference_to_simple_reference_conversion (reference ref, reference *output_ref, descriptor *output_desc)
 
void simple_cell_to_simple_cell_conversion (cell input_cell, cell *output_cell, descriptor *output_desc)
 
list eval_simple_cell_with_points_to (cell c, descriptor __attribute__((unused)) d, list ptl, bool *exact_p, transformer __attribute__((unused)) t)
 
list simple_effect_to_constant_path_effects_with_pointer_values (effect eff)
 
list effect_to_constant_path_effects_with_points_to (effect eff, statement s, transformer context)
 
list simple_effect_to_constant_path_effects_with_points_to (effect eff)
 
list eval_cell_with_points_to (cell c, list ptl, bool *exact_p)
 for backward compatibility More...
 

Function Documentation

◆ effect_to_constant_path_effects_with_points_to()

list effect_to_constant_path_effects_with_points_to ( effect  eff,
statement  s,
transformer  context 
)

We have not found any equivalent constant path : it may point anywhere

We should maybe contract these effects later. Is it done by the callers ?

make the resulting effects action to the current effect action

This is dead code: no effects, do not modify le

Parameters
effff
contextontext

Definition at line 284 of file eval.c.

285 {
286  list le = NIL;
287  bool exact_p;
289 
290  pips_debug_effect(5, "input effect", eff);
291 
293  if(!points_to_list_bottom(ptl)) {
294  if (effect_reference_dereferencing_p(ref, &exact_p))
295  {
296  pips_debug(8, "dereferencing case \n");
297  bool exact_p = false;
298 #if false
302  else {
304  }
305 #endif
306 
308  points_to_list_list(ptl),
309  &exact_p, context);
310  if (ENDP(l_eval))
311  {
312  pips_debug(8, "no equivalent constant path found -> anywhere effect\n");
313  /* We have not found any equivalent constant path : it may point anywhere */
314  /* We should maybe contract these effects later. Is it done by the callers ? */
315  // le = CONS(EFFECT, make_anywhere_effect(copy_action(effect_action(eff))), le);
316  le = NIL; // A translation failure means an execution
317  // failure, at least according to the standard
318  }
319  else
320  {
321  /* make the resulting effects action to the current effect action */
322  // list l_eval_eff = cells_to_effects_according_to_effect(l_eval, eff, exact_p);
323 
324  if (effect_read_p(eff))
325  effects_to_read_effects(l_eval);
326  if (effect_may_p(eff))
327  effects_to_may_effects(l_eval);
328  le = gen_nconc(l_eval,le);
329  }
330  }
331  else
332  le = CONS(EFFECT, copy_effect(eff), le);
333  }
334  else {
335  /* This is dead code: no effects, do not modify le */
336  ;
337  }
338  return le;
339 
340 }
effect copy_effect(effect p)
EFFECT.
Definition: effects.c:448
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
#define pips_debug_effect(level, message, eff)
for debug
bool effects_private_current_context_empty_p(void)
void effects_to_may_effects(list)
transformer effects_private_current_context_head(void)
void effects_to_read_effects(list)
list eval_simple_cell_with_points_to(cell c, descriptor __attribute__((unused)) d, list ptl, bool *exact_p, transformer __attribute__((unused)) t)
Definition: eval.c:194
#define effect_may_p(eff)
#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))
bool effect_reference_dereferencing_p(reference, bool *)
Definition: type.c:233
points_to_list load_pt_to_list(statement)
#define effect_descriptor(x)
Definition: effects.h:646
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
#define effect_cell(x)
Definition: effects.h:640
#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
#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 pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define points_to_list_list(x)
#define points_to_list_bottom(x)
#define transformer_undefined
Definition: ri.h:2847
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: delay.c:253

References CONS, copy_effect(), EFFECT, effect_any_reference, effect_cell, effect_descriptor, effect_may_p, effect_read_p, effect_reference_dereferencing_p(), effects_private_current_context_empty_p(), effects_private_current_context_head(), effects_to_may_effects(), effects_to_read_effects(), ENDP, eval_simple_cell_with_points_to(), gen_nconc(), load_pt_to_list(), NIL, pips_debug, pips_debug_effect, points_to_list_bottom, points_to_list_list, ref, and transformer_undefined.

Referenced by add_values_for_simple_effects_of_statement(), c_user_call_to_transformer(), and simple_effect_to_constant_path_effects_with_points_to().

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

◆ eval_cell_with_points_to()

list eval_cell_with_points_to ( cell  c,
list  ptl,
bool exact_p 
)

for backward compatibility

Parameters
ptltl
exact_pxact_p

Definition at line 352 of file eval.c.

353 {
355  list l = NIL;
356 
357  FOREACH(EFFECT,eff, l_eff)
358  {
359  l = CONS(CELL, effect_cell(eff), l);
361  }
362  gen_full_free_list(l_eff);
363  return l;
364 }
#define cell_undefined
Definition: effects.h:430
#define CELL(x)
CELL.
Definition: effects.h:424
#define descriptor_undefined
Definition: effects.h:559
void gen_full_free_list(list l)
Definition: genClib.c:1023
#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

References CELL, cell_undefined, CONS, descriptor_undefined, EFFECT, effect_cell, eval_simple_cell_with_points_to(), FOREACH, gen_full_free_list(), NIL, and transformer_undefined.

+ Here is the call graph for this function:

◆ eval_simple_cell_with_points_to()

list eval_simple_cell_with_points_to ( cell  c,
descriptor __attribute__((unused))  d,
list  ptl,
bool exact_p,
transformer __attribute__((unused))  t 
)

Definition at line 194 of file eval.c.

197 {
203 }
list generic_eval_cell_with_points_to(cell input_cell, descriptor input_desc, list ptl, bool *exact_p, transformer current_precondition, bool(*cell_reference_preceding_p_func)(reference, descriptor, reference, descriptor, transformer, bool, bool *), void(*cell_reference_with_address_of_cell_reference_translation_func)(reference, descriptor, reference, descriptor, int, reference *, descriptor *, bool *), void(*cell_reference_conversion_func)(reference, reference *, descriptor *))
Definition: eval.c:361
void simple_reference_to_simple_reference_conversion(reference ref, reference *output_ref, descriptor *output_desc)
Definition: eval.c:146
bool simple_cell_reference_preceding_p(reference r1, descriptor __attribute__((unused)) d1, reference r2, descriptor __attribute__((unused)) d2, transformer __attribute__((unused)) current_precondition, bool strict_p, bool *exact_p)
Definition: eval.c:60
void simple_cell_reference_with_address_of_cell_reference_translation(reference, descriptor, reference, descriptor, int, reference *, descriptor *, bool *)

References descriptor_undefined, generic_eval_cell_with_points_to(), simple_cell_reference_preceding_p(), simple_cell_reference_with_address_of_cell_reference_translation(), simple_reference_to_simple_reference_conversion(), and transformer_undefined.

Referenced by effect_to_constant_path_effects_with_points_to(), and eval_cell_with_points_to().

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

◆ path_preceding_p()

bool path_preceding_p ( effect  eff1,
effect  eff2,
transformer  current_precondition,
bool  strict_p,
bool exact_p 
)
Parameters
eff1ff1
eff2ff2
current_preconditionurrent_precondition
strict_ptrict_p
exact_pxact_p

Definition at line 132 of file eval.c.

136 {
137  reference r1 = effect_any_reference(eff1);
138  descriptor d1 = effect_descriptor(eff1);
139  reference r2 = effect_any_reference(eff2);
140  descriptor d2 = effect_descriptor(eff2);
141 
143  strict_p, exact_p);
144 }
static transformer current_precondition

References current_precondition, effect_any_reference, effect_descriptor, and simple_cell_reference_preceding_p().

Referenced by c_convex_effects_on_actual_parameter_forward_translation().

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

◆ simple_cell_preceding_p()

bool simple_cell_preceding_p ( cell  c1,
descriptor  d1,
cell  c2,
descriptor  d2,
transformer  current_precondition,
bool  strict_p,
bool exact_p 
)
Parameters
c11
d11
c22
d22
current_preconditionurrent_precondition
strict_ptrict_p
exact_pxact_p

Definition at line 119 of file eval.c.

124 {
125  reference r1 = cell_any_reference(c1);
126  reference r2 = cell_any_reference(c2);
127 
129  strict_p, exact_p);
130 }
reference cell_any_reference(cell)
API for reference.
Definition: effects.c:77

References cell_any_reference(), current_precondition, and simple_cell_reference_preceding_p().

Referenced by effect_find_aliased_paths_with_pointer_values(), and make_simple_pv_context().

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

◆ simple_cell_reference_preceding_p()

bool simple_cell_reference_preceding_p ( reference  r1,
descriptor __attribute__((unused))  d1,
reference  r2,
descriptor __attribute__((unused))  d2,
transformer __attribute__((unused))  current_precondition,
bool  strict_p,
bool exact_p 
)

same entity and the path length of r1 is shorter than the path length of r2. we now have to check that each common index matches

Definition at line 60 of file eval.c.

65 {
66  bool res = true;
67  entity e1 = reference_variable(r1);
68  list ind1 = reference_indices(r1);
69  size_t r1_path_length = gen_length(ind1);
70  entity e2 = reference_variable(r2);
71  list ind2 = reference_indices(r2);
72  size_t r2_path_length = gen_length(ind2);
73 
74  pips_debug(8, "input references r1 : %s, r2: %s \n",
77 
78  *exact_p = true;
79  if (same_entity_p(e1, e2)
80  && ((r1_path_length < r2_path_length)
81  || (!strict_p && r1_path_length == r2_path_length)))
82  {
83  /* same entity and the path length of r1 is shorter than the path length of r2.
84  we now have to check that each common index matches
85  */
86  pips_debug(8,"same entities, and r1 path is shorter than r2 path\n");
87  while (res && !ENDP(ind1))
88  {
89  expression exp1 = EXPRESSION(CAR(ind1));
90  expression exp2 = EXPRESSION(CAR(ind2));
91 
93  {
94  res = true;
95  *exact_p = false;
96  }
97  else if(!expression_equal_p(exp1, exp2))
98  {
99  res = false;
100  *exact_p = true;
101  }
102 
103  POP(ind1);
104  POP(ind2);
105  }
106  }
107  else
108  {
109  res = false;
110  *exact_p = true;
111  }
112 
113  pips_debug(8, "end : r1 is %s a predecessor of r2 (%s exact)\n",
114  res ? "":"not", *exact_p ? "":"not");
115  return res;
116 }
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
size_t gen_length(const list l)
Definition: list.c:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
string reference_to_string(reference r)
Definition: expression.c:87
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
bool expression_equal_p(expression e1, expression e2)
Syntactic equality e1==e2.
Definition: expression.c:1347
bool unbounded_expression_p(expression e)
Definition: expression.c:4329
#define reference_variable(x)
Definition: ri.h:2326
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define reference_indices(x)
Definition: ri.h:2328

References CAR, ENDP, EXPRESSION, expression_equal_p(), gen_length(), pips_debug, POP, reference_indices, reference_to_string(), reference_variable, same_entity_p(), and unbounded_expression_p().

Referenced by eval_simple_cell_with_points_to(), path_preceding_p(), and simple_cell_preceding_p().

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

◆ simple_cell_to_simple_cell_conversion()

void simple_cell_to_simple_cell_conversion ( cell  input_cell,
cell output_cell,
descriptor output_desc 
)
Parameters
input_cellnput_cell
output_cellutput_cell
output_descutput_desc

Definition at line 154 of file eval.c.

157 {
158  *output_cell = input_cell;
159  *output_desc = make_descriptor(is_descriptor_none,UU);
160 }
descriptor make_descriptor(enum descriptor_utype tag, void *val)
Definition: effects.c:433
@ is_descriptor_none
Definition: effects.h:576
#define UU
Definition: newgen_types.h:98

References is_descriptor_none, make_descriptor(), and UU.

Referenced by effect_find_aliased_paths_with_pointer_values(), and effect_find_equivalent_pointer_values().

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

◆ simple_effect_to_constant_path_effects_with_pointer_values()

list simple_effect_to_constant_path_effects_with_pointer_values ( effect  eff)

it should be a union here. However, we expect the caller to perform the contraction afterwards.

Parameters
effff

Definition at line 206 of file eval.c.

207 {
208  list le = NIL;
209  bool exact_p;
211 
212  if (effect_reference_dereferencing_p(ref, &exact_p))
213  {
214  pips_debug(8, "dereferencing case \n");
215  bool exact_p = false;
218  list l_aliased = effect_find_aliased_paths_with_pointer_values(eff, l_pv, &ctxt);
219  pips_debug_effects(8, "aliased effects\n", l_aliased);
220  reset_pv_context(&ctxt);
221 
222  FOREACH(EFFECT, eff_alias, l_aliased)
223  {
224  entity ent_alias = effect_entity(eff_alias);
225  if (undefined_pointer_value_entity_p(ent_alias)
226  || null_pointer_value_entity_p(ent_alias))
227  {
228  // currently interpret them as anywhere effects since these values
229  // are not yet well integrated in abstract locations lattice
230  // and in effects computations
231  // to be FIXED later.
232  le = CONS(EFFECT, make_anywhere_effect(copy_action(effect_action(eff_alias))), le);
233  free_effect(eff_alias);
234  }
235  else if (entity_abstract_location_p(effect_entity(eff_alias))
236  || !effect_reference_dereferencing_p(effect_any_reference(eff_alias), &exact_p)) {
237  le = CONS(EFFECT, eff_alias, le);
238  /* it should be a union here.
239  * However, we expect the caller
240  * to perform the contraction afterwards. */
241  }
242  else
243  free_effect(eff_alias);
244  }
245  gen_free_list(l_aliased);
246  }
247  else {
248  // functions that can be pointed by effect_dup_func:
249  // simple_effect_dup
250  // region_dup
251  // copy_effect
252  le = CONS(EFFECT, (*effect_dup_func)(eff), le);
253  }
254 
255  return le;
256 }
action copy_action(action p)
ACTION.
Definition: effects.c:77
void free_effect(effect p)
Definition: effects.c:451
bool entity_abstract_location_p(entity al)
#define pips_debug_effects(level, message, l_eff)
effect make_anywhere_effect(action)
statement effects_private_current_stmt_head(void)
effect(* effect_dup_func)(effect eff)
entity effect_entity(effect)
cproto-generated files
Definition: effects.c:52
bool undefined_pointer_value_entity_p(entity)
bool null_pointer_value_entity_p(entity)
#define cell_relations_list(x)
Definition: effects.h:549
#define effect_action(x)
Definition: effects.h:642
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
pv_context make_simple_pv_context(void)
cell_relations load_pv(statement)
list effect_find_aliased_paths_with_pointer_values(effect, list, pv_context *)
find all paths equivalent to eff cell in l_pv by performing a transitive closure
void reset_pv_context(pv_context *)
pv_context is a structure holding the methods to use during pointer values analyses

References cell_relations_list, CONS, copy_action(), EFFECT, effect_action, effect_any_reference, effect_dup_func, effect_entity(), effect_find_aliased_paths_with_pointer_values(), effect_reference_dereferencing_p(), effects_private_current_stmt_head(), entity_abstract_location_p(), FOREACH, free_effect(), gen_free_list(), load_pv(), make_anywhere_effect(), make_simple_pv_context(), NIL, null_pointer_value_entity_p(), pips_debug, pips_debug_effects, ref, reset_pv_context(), and undefined_pointer_value_entity_p().

+ Here is the call graph for this function:

◆ simple_effect_to_constant_path_effects_with_points_to()

list simple_effect_to_constant_path_effects_with_points_to ( effect  eff)
Parameters
effff

Definition at line 343 of file eval.c.

344 {
348 }
list effect_to_constant_path_effects_with_points_to(effect eff, statement s, transformer context)
Definition: eval.c:284

References effect_to_constant_path_effects_with_points_to(), effects_private_current_context_head(), and effects_private_current_stmt_head().

+ Here is the call graph for this function:

◆ simple_reference_to_simple_reference_conversion()

void simple_reference_to_simple_reference_conversion ( reference  ref,
reference output_ref,
descriptor output_desc 
)
Parameters
refef
output_refutput_ref
output_descutput_desc

Definition at line 146 of file eval.c.

149 {
150  *output_ref = ref;
151  *output_desc = make_descriptor(is_descriptor_none,UU);
152 }

References is_descriptor_none, make_descriptor(), ref, and UU.

Referenced by eval_simple_cell_with_points_to().

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