PIPS
abstract_location.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 "points_to_private.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "text.h"
#include "text-util.h"
#include "misc.h"
#include "properties.h"
+ Include dependency graph for abstract_location.c:

Go to the source code of this file.

Functions

bool entity_heap_location_p (entity b)
 package abstract location. More...
 
entity entity_flow_or_context_sentitive_heap_location (int stmt_number, type t)
 
bool entity_flow_or_context_sentitive_heap_location_p (entity e)
 
type malloc_arg_to_type (expression e)
 generate the type of the allocated area from the malloc argument More...
 
entity malloc_type_to_abstract_location (type t, sensitivity_information *psi)
 generate an abstract heap location entity More...
 
entity malloc_to_abstract_location (expression malloc_exp, sensitivity_information *psi)
 generate an abstract heap location entity More...
 
entity calloc_to_abstract_location (expression n, expression size, sensitivity_information *psi)
 generate an abstract heap location entity More...
 
reference original_malloc_to_abstract_location (expression lhs __attribute__((unused)), type __attribute__((unused)) var_t, type __attribute__((unused)) cast_t, expression sizeof_exp, entity f, statement stmt)
 to handle malloc statemennts: More...
 
sensitivity_information make_sensitivity_information (statement current_stmt, entity current_module, list enclosing_flow)
 

Function Documentation

◆ calloc_to_abstract_location()

entity calloc_to_abstract_location ( expression  n,
expression  size,
sensitivity_information psi 
)

generate an abstract heap location entity

Parameters
nis the first argument expression of the call to calloc
sizeis the second argument expression of the call to calloc
psiis a pointer towards a structure which contains context and/or flow sensitivity information
Returns
an abstract heap location entity
Parameters
sizeize
psisi

Definition at line 414 of file abstract_location.c.

416 {
417  expression malloc_exp = make_op_exp("*",
418  copy_expression(n),
419  copy_expression(size));
420  entity e = malloc_to_abstract_location(malloc_exp, psi);
421  free_expression(malloc_exp);
422  return(e);
423 }
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
void free_expression(expression p)
Definition: ri.c:853
entity malloc_to_abstract_location(expression malloc_exp, sensitivity_information *psi)
generate an abstract heap location entity
expression make_op_exp(char *op_name, expression exp1, expression exp2)
================================================================
Definition: expression.c:2012

References copy_expression(), free_expression(), make_op_exp(), and malloc_to_abstract_location().

+ Here is the call graph for this function:

◆ entity_flow_or_context_sentitive_heap_location()

entity entity_flow_or_context_sentitive_heap_location ( int  stmt_number,
type  t 
)

FI: Beware, the symbol table is updated but this is not reflected in pipsmake.rc

We need to keep track of these pseudo-variables to destroy them before a module is reanalyzed after a code transformation, for instance a constant propagation that changed dependent types into cosntant types.

We might be in trouble, unless a piece of code is reanalyzed. Let's assume the type is unchanged

Parameters
stmt_numbertmt_number

Definition at line 78 of file abstract_location.c.

79 {
80  entity e;
81  string s;
82  asprintf(&s, HEAP_AREA_LOCAL_NAME "_l_%d", stmt_number);
83 
85  free(s);
89  //ram r = make_ram(f, a, UNKNOWN_RAM_OFFSET, NIL);
91 
92  /* FI: Beware, the symbol table is updated but this is not
93  reflected in pipsmake.rc */
95  entity_type(e) = copy_type(ct);
99  (void) add_C_variable_to_area(a, e);
100  /* We need to keep track of these pseudo-variables to destroy them
101  before a module is reanalyzed after a code transformation, for
102  instance a constant propagation that changed dependent types
103  into cosntant types. */
105  }
106  else {
107  /* We might be in trouble, unless a piece of code is
108  reanalyzed. Let's assume the type is unchanged */
110  type et = entity_type(e);
111  // FI: too strong if 1-D arrays and pointers can be assimilated
112  //pips_assert("The type is unchanged",
113  // type_equal_p(ct, et));
114  if(!type_equal_p(ct,et)) {
115  // FI: this might be improvable with array_pointer_type_equal_p
116  if(pointer_type_p(ct) && array_type_p(et)) {
117  type pt = type_to_pointed_type(ct);
119  variable etv = type_variable(et);
120  basic eb = variable_basic(etv);
121  int d = (int) gen_length(variable_dimensions(etv));
122  if(d==1 && basic_equal_p(pb, eb))
123  ;
124  else
125  pips_assert("The type is unchanged or compatible", false);
126  }
127  else if(pointer_type_p(et) && array_type_p(ct)) {
128  type pt = type_to_pointed_type(et);
130  variable etv = type_variable(ct);
131  basic eb = variable_basic(etv);
132  int d = (int) gen_length(variable_dimensions(etv));
133  if(d==1 && basic_equal_p(pb, eb))
134  ;
135  else
136  pips_assert("The type is unchanged or compatible", false);
137  }
138  else
139  pips_assert("The type is unchanged or compatible", false);
140  }
141  free_type(ct);
142  }
143  return e;
144 
145 }
value make_value_unknown(void)
Definition: ri.c:2847
type copy_type(type p)
TYPE.
Definition: ri.c:2655
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
void free_type(type p)
Definition: ri.c:2658
storage make_storage_ram(ram _field_)
Definition: ri.c:2279
void const char const char const int
void free(void *)
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
#define asprintf
Definition: misc-local.h:225
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define HEAP_AREA_LOCAL_NAME
Definition: naming-local.h:71
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
#define DYNAMIC_RAM_OFFSET
FI: I would have assumed that it is used for the stack area, but I must be wrong.....
@ ABSTRACT_LOCATION
entity module_to_heap_area(entity f)
Returns the heap area "a" associated to module "f".
Definition: area.c:129
entity FindOrCreateEntity(const char *package, const char *local_name)
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a functi...
Definition: entity.c:1586
bool array_type_p(type)
Definition: type.c:2942
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
int add_C_variable_to_area(entity, entity)
Definition: variable.c:1381
bool type_equal_p(type, type)
Definition: type.c:547
bool basic_equal_p(basic, basic)
Definition: type.c:927
type type_to_pointed_type(type)
returns t if t is not a pointer type, and the pointed type if t is a pointer type.
Definition: type.c:5265
bool pointer_type_p(type)
Check for scalar pointers.
Definition: type.c:2993
type compute_basic_concrete_type(type)
computes a new type which is the basic concrete type of the input type (this new type is not stored i...
Definition: type.c:3556
#define type_variable(x)
Definition: ri.h:2949
#define entity_storage(x)
Definition: ri.h:2794
#define type_undefined_p(x)
Definition: ri.h:2884
#define variable_dimensions(x)
Definition: ri.h:3122
#define entity_kind(x)
Definition: ri.h:2798
#define entity_type(x)
Definition: ri.h:2792
#define variable_basic(x)
Definition: ri.h:3120
#define entity_initial(x)
Definition: ri.h:2796

References ABSTRACT_LOCATION, add_C_variable_to_area(), AddEntityToDeclarations(), array_type_p(), asprintf, basic_equal_p(), compute_basic_concrete_type(), copy_type(), DYNAMIC_RAM_OFFSET, entity_initial, entity_kind, entity_storage, entity_type, f(), FindOrCreateEntity(), free(), free_type(), gen_length(), get_current_module_entity(), get_current_module_name(), HEAP_AREA_LOCAL_NAME, int, make_ram(), make_storage_ram(), make_value_unknown(), module_to_heap_area(), NIL, pips_assert, pointer_type_p(), type_equal_p(), type_to_pointed_type(), type_undefined_p, type_variable, variable_basic, and variable_dimensions.

Referenced by malloc_type_to_abstract_location().

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

◆ entity_flow_or_context_sentitive_heap_location_p()

bool entity_flow_or_context_sentitive_heap_location_p ( entity  e)

Definition at line 147 of file abstract_location.c.

148 {
149  bool result = false;
150  const char* ln = entity_local_name(e);
151  string found = strstr(ln, ANYWHERE_LOCATION);
152 
153  pips_debug(9, "input entity: %s\n", ln);
154  pips_debug(9, "found (1) = : %s\n", found);
155 
156  if (found == NULL)
157  {
158  found = strstr(ln, HEAP_AREA_LOCAL_NAME);
159  pips_debug(9, "found (2) = : %s\n", found);
160  if (found!=NULL)
161  {
162  size_t found_n = strspn(found, HEAP_AREA_LOCAL_NAME);
163  ln = &found[found_n];
164  pips_debug(9, "ln : %s\n", ln);
165  found = strstr(ln, "_l_");
166  pips_debug(9, "found (3) = : %s\n", found);
167  result = (found != NULL);
168  }
169  else
170  result = false;
171  }
172  else
173  result = false;
174  pips_debug(9, "result = %d\n", (int) result);
175  return result;
176 }
#define ANYWHERE_LOCATION
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453

References ANYWHERE_LOCATION, entity_local_name(), HEAP_AREA_LOCAL_NAME, and pips_debug.

Referenced by convex_cells_inclusion_p(), convex_cells_intersection_p(), free_to_post_pv(), generic_transform_sink_cells_from_matching_list(), references_may_conflict_p(), simple_cells_inclusion_p(), and simple_cells_intersection_p().

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

◆ entity_heap_location_p()

bool entity_heap_location_p ( entity  b)

package abstract location.

abstract_location.c

Amira Mensi 2010

File: abstract_location.c

This file contains various useful functions to modelize a heap. check if an entity b may represent a bucket or a set of buckets in the heap.

Definition at line 64 of file abstract_location.c.

65 {
66  bool bucket_p = entity_all_heap_locations_p(b) ||
68 
69  if(!heap_area_p(b) && !bucket_p) {
70  const char* ln = entity_local_name(b);
71  const char* found = strstr(ln, HEAP_AREA_LOCAL_NAME);
72  bucket_p = found != NULL;
73  }
74 
75  return bucket_p;
76 }
bool entity_all_module_heap_locations_p(entity e)
test if an entity is the a heap area
bool entity_all_heap_locations_p(entity e)
test if an entity is the set of all heap locations
bool heap_area_p(entity aire)
Definition: area.c:86

References entity_all_heap_locations_p(), entity_all_module_heap_locations_p(), entity_local_name(), HEAP_AREA_LOCAL_NAME, and heap_area_p().

Referenced by analyzable_scalar_entity_p(), cell_out_of_scope_p(), cells_to_read_or_write_effects(), clean_up_points_to_stubs(), generic_atomic_points_to_reference_p(), generic_eval_cell_with_points_to(), generic_remove_unreachable_vertices_in_points_to_graph(), module_to_value_mappings(), points_to_reference_to_typed_index(), and semantics_usable_points_to_reference_p().

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

◆ make_sensitivity_information()

sensitivity_information make_sensitivity_information ( statement  current_stmt,
entity  current_module,
list  enclosing_flow 
)
Parameters
current_stmturrent_stmt
current_moduleurrent_module
enclosing_flownclosing_flow

Definition at line 522 of file abstract_location.c.

525 {
529  si.enclosing_flow = enclosing_flow;
530  return si;
531 }
static string current_module
Definition: message.c:63
static statement current_stmt

References sensitivity_information::current_module, current_module, current_stmt, sensitivity_information::current_stmt, and sensitivity_information::enclosing_flow.

Referenced by flow_sensitive_malloc_to_points_to_sinks(), heap_intrinsic_to_post_pv(), and original_malloc_to_abstract_location().

+ Here is the caller graph for this function:

◆ malloc_arg_to_type()

type malloc_arg_to_type ( expression  e)

generate the type of the allocated area from the malloc argument

Parameters
eis the malloc argument expression
Returns
a new type (no sharing)

Store dependent types are not generated. It means that whenever the size of the allocated space is store dependent, the returned type is an array of unbounded_dimension.

which one is the sizeof operator ? try the second one first

sizeofexpression is an expression

Definition at line 187 of file abstract_location.c.

188 {
189  type t = type_undefined;
190  syntax s = expression_syntax(e);
193  bool scalar_p = false;;
194 
195  pips_debug(5, "begin for expression:%s\n", expression_to_string(e));
196 
198  {
199  scalar_p = true; // Not necessarily! An array type may be argument
200  sizeof_exp = syntax_sizeofexpression(s);
201  }
202  else if(syntax_cast_p(s)) {
203  cast c = syntax_cast(s);
204  expression ce = cast_expression(c);
205  t = malloc_arg_to_type(ce);
206  return t; // FI: I hate doing this...
207  }
208  else if (syntax_call_p(s))
209  {
210  call c = syntax_call(s);
211  entity func = call_function(c);
212  list func_args = call_arguments(c);
213 
215  {
216  pips_debug(5, "multiply operator found\n");
217  expression arg1 = EXPRESSION(CAR(func_args));
218  expression arg2 = EXPRESSION(CAR(CDR(func_args)));
219 
220  /* which one is the sizeof operator ? try the second one first */
222  {
223  pips_debug(5," second arg is a sizeof expression\n");
224  sizeof_exp = syntax_sizeofexpression(expression_syntax(arg2));
225  n = make_op_exp("-", copy_expression(arg1), int_to_expression(1));
226  }
228  {
229  pips_debug(5," first arg is a sizeof expression\n");
230  sizeof_exp = syntax_sizeofexpression(expression_syntax(arg1));
231  n = make_op_exp("-", copy_expression(arg2), int_to_expression(1));
232  }
233  else
234  {
236  }
237  }
238  else
239  {
241  }
242  }
243  else
245 
247  && !expression_constant_p(n))
248  {
249  // FI: I do not see why we cannot generate dependent types...
250  // We would have to be careful to evaluate the expression in
251  // case its variables are modified. Just as the parser should do.
252  pips_debug(5, "non constant number of elements "
253  "-> generating unbounded dimension\n");
254  free_expression(n);
256  }
257 
258  if (sizeofexpression_undefined_p(sizeof_exp))
259  {
262  CONS(DIMENSION,
264  NIL),
265  NIL));
266  }
267  else if (sizeofexpression_type_p(sizeof_exp))
268  {
269  type t_sizeof_exp = sizeofexpression_type(sizeof_exp);
270  variable t_var_sizeof_exp = type_variable_p(t_sizeof_exp) ?
271  type_variable(t_sizeof_exp) : variable_undefined;
272  pips_assert("type must be variable",
273  !variable_undefined_p(t_var_sizeof_exp));
274 
275  if (scalar_p)
277  (make_variable(copy_basic(variable_basic(t_var_sizeof_exp)),
279  (t_var_sizeof_exp)),
280  NIL));
281  else
283  (make_variable(copy_basic(variable_basic(t_var_sizeof_exp)),
284  CONS(DIMENSION,
287  (t_var_sizeof_exp))),
288  NIL));
289  }
290  else /* sizeofexpression is an expression */
291  {
292  type t_sizeof_exp =
294  variable t_var_sizeof_exp = type_variable_p(t_sizeof_exp) ?
295  type_variable(t_sizeof_exp) : variable_undefined;
296 
297  if (scalar_p)
299  (make_variable(copy_basic(variable_basic( t_var_sizeof_exp)),
301  (t_var_sizeof_exp)),
302  NIL));
303  else
305  (make_variable(copy_basic(variable_basic(t_var_sizeof_exp)),
306  CONS(DIMENSION,
309  (t_var_sizeof_exp))),
310  NIL));
311  free_type(t_sizeof_exp);
312  }
313  pips_debug(5, "end with type %s\n", string_of_type(t));
314  return t;
315 }
type make_type_variable(variable _field_)
Definition: ri.c:2715
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
type malloc_arg_to_type(expression e)
generate the type of the allocated area from the malloc argument
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
bool expression_constant_p(expression)
HPFC module by Fabien COELHO.
Definition: expression.c:2453
#define same_string_p(s1, s2)
string expression_to_string(expression e)
Definition: expression.c:77
string string_of_type(const type)
Definition: type.c:56
#define DEFAULT_CHARACTER_TYPE_SIZE
Default type sizes.
#define MULTIPLY_OPERATOR_NAME
expression make_unbounded_expression()
Definition: expression.c:4339
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
bool unbounded_expression_p(expression e)
Definition: expression.c:4329
type expression_to_type(expression)
For an array declared as int a[10][20], the type returned for a[i] is int [20].
Definition: type.c:2486
#define call_function(x)
Definition: ri.h:709
#define sizeofexpression_type(x)
Definition: ri.h:2406
#define syntax_call_p(x)
Definition: ri.h:2734
#define sizeofexpression_expression(x)
Definition: ri.h:2409
#define syntax_cast(x)
Definition: ri.h:2739
#define syntax_sizeofexpression_p(x)
Definition: ri.h:2740
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define cast_expression(x)
Definition: ri.h:747
#define expression_undefined
Definition: ri.h:1223
#define variable_undefined
Definition: ri.h:3095
#define sizeofexpression_undefined_p(x)
Definition: ri.h:2371
#define syntax_sizeofexpression(x)
Definition: ri.h:2742
#define variable_undefined_p(x)
Definition: ri.h:3096
#define sizeofexpression_type_p(x)
Definition: ri.h:2404
#define syntax_call(x)
Definition: ri.h:2736
#define expression_undefined_p(x)
Definition: ri.h:1224
#define type_undefined
Definition: ri.h:2883
#define sizeofexpression_undefined
Definition: ri.h:2370
#define call_arguments(x)
Definition: ri.h:711
#define syntax_cast_p(x)
Definition: ri.h:2737
#define expression_syntax(x)
Definition: ri.h:1247
#define type_variable_p(x)
Definition: ri.h:2947
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References call_arguments, call_function, CAR, cast_expression, CDR, CONS, copy_basic(), copy_expression(), DEFAULT_CHARACTER_TYPE_SIZE, DIMENSION, entity_local_name(), EXPRESSION, expression_constant_p(), expression_syntax, expression_to_string(), expression_to_type(), expression_undefined, expression_undefined_p, free_expression(), free_type(), gen_full_copy_list(), int_to_expression(), make_basic_int(), make_dimension(), make_op_exp(), make_type_variable(), make_unbounded_expression(), make_variable(), MULTIPLY_OPERATOR_NAME, NIL, pips_assert, pips_debug, same_string_p, sizeofexpression_expression, sizeofexpression_type, sizeofexpression_type_p, sizeofexpression_undefined, sizeofexpression_undefined_p, string_of_type(), syntax_call, syntax_call_p, syntax_cast, syntax_cast_p, syntax_sizeofexpression, syntax_sizeofexpression_p, type_undefined, type_variable, type_variable_p, unbounded_expression_p(), variable_basic, variable_dimensions, variable_undefined, and variable_undefined_p.

Referenced by malloc_to_abstract_location().

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

◆ malloc_to_abstract_location()

entity malloc_to_abstract_location ( expression  malloc_exp,
sensitivity_information psi 
)

generate an abstract heap location entity

Parameters
malloc_expis the argument expression of the call to malloc
psiis a pointer towards a structure which contains context and/or flow sensitivity information
Returns
an abstract heap location entity

free_type(ct)

Parameters
malloc_expalloc_exp
psisi

Definition at line 389 of file abstract_location.c.

391 {
393 
394  pips_debug(8, "begin for expression %s\n", expression_to_string(malloc_exp));
395  type t = malloc_arg_to_type(malloc_exp);
396  //type ct = copy_type(compute_basic_concrete_type(t));
397  //e = malloc_type_to_abstract_location(ct, psi);
399  free_type(t)/*, free_type(ct)*/;
400  pips_debug(8, "returning entity %s of type %s\n", entity_name(e),
402 
403  return e;
404 }
entity malloc_type_to_abstract_location(type t, sensitivity_information *psi)
generate an abstract heap location entity
#define entity_undefined
Definition: ri.h:2761
#define entity_name(x)
Definition: ri.h:2790

References entity_name, entity_type, entity_undefined, expression_to_string(), free_type(), malloc_arg_to_type(), malloc_type_to_abstract_location(), pips_debug, and string_of_type().

Referenced by calloc_to_abstract_location(), flow_sensitive_malloc_to_points_to_sinks(), heap_intrinsic_to_post_pv(), and original_malloc_to_abstract_location().

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

◆ malloc_type_to_abstract_location()

entity malloc_type_to_abstract_location ( type  t,
sensitivity_information psi 
)

generate an abstract heap location entity

Parameters
tis type of the allocated space
psiis a pointer towards a structure which contains context and/or flow sensitivity information
Returns
an abstract heap location entity

in case we want an anywhere abstract heap location : the property ABSTRACT_HEAP_LOCATIONS is set to "unique" and a unique abstract location is used for all heap buckets.

in case the property ABSTRACT_HEAP_LOCATIONS is set to "insensitive": an abstract location is used for each function.

in case the property ABSTRACT_HEAP_LOCATIONS is set to "flow-sensitive" or "context-sensitive".

No difference here between the two values. The diffferent behavior will show when points-to and effects are translated at call sites

At this level, we want to use the statement number or the statement ordering. The statement ordering is safer because two statements or more can be put on the same line. The statement number is more user-friendly.

There is no need to distinguish between types since the statement ordering is at least as effective.

Parameters
psisi

Definition at line 324 of file abstract_location.c.

325 {
327  const char* opt = get_string_property("ABSTRACT_HEAP_LOCATIONS");
328  bool type_sensitive_p = !get_bool_property("ALIASING_ACROSS_TYPES");
329 
330  pips_debug(8, "begin for type %s\n",
331  string_of_type(t));
332  /* in case we want an anywhere abstract heap location : the property
333  ABSTRACT_HEAP_LOCATIONS is set to "unique" and a unique abstract
334  location is used for all heap buckets. */
335  if(strcmp(opt, "unique")==0){
336  if(type_sensitive_p)
338  else
340  }
341 
342  /* in case the property ABSTRACT_HEAP_LOCATIONS is set to
343  "insensitive": an abstract location is used for each function. */
344  else if(strcmp(opt, "insensitive")==0){
345  if(type_sensitive_p)
347  copy_type(t));
348  else
350  }
351 
352  /* in case the property ABSTRACT_HEAP_LOCATIONS is set to
353  "flow-sensitive" or "context-sensitive".
354 
355  No difference here between the two values. The diffferent
356  behavior will show when points-to and effects are translated at
357  call sites
358 
359  At this level, we want to use the statement number or the
360  statement ordering. The statement ordering is safer because two
361  statements or more can be put on the same line. The statement
362  number is more user-friendly.
363 
364  There is no need to distinguish between types since the statement
365  ordering is at least as effective.
366  */
367  else if(strcmp(opt, "flow-sensitive")==0
368  || strcmp(opt, "context-sensitive")==0 )
371  copy_type(t));
372  else
373  pips_user_error("Unrecognized value for property ABSTRACT_HEAP_LOCATION:"
374  " \"%s\"", opt);
375 
376  pips_debug(8, "returning entity %s of type %s\n", entity_name(e),
378 
379  return e;
380 }
entity entity_flow_or_context_sentitive_heap_location(int stmt_number, type t)
entity entity_all_module_heap_locations(entity m)
return m:*HEAP**ANYWHERE
entity entity_all_module_heap_locations_typed(entity m, type t)
entity entity_all_heap_locations()
return ANY_MODULE:HEAP
entity entity_all_heap_locations_typed(type t)
char * get_string_property(const char *)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define pips_user_error
Definition: misc-local.h:147
#define statement_number(x)
Definition: ri.h:2452

References copy_type(), sensitivity_information::current_module, sensitivity_information::current_stmt, entity_all_heap_locations(), entity_all_heap_locations_typed(), entity_all_module_heap_locations(), entity_all_module_heap_locations_typed(), entity_flow_or_context_sentitive_heap_location(), entity_name, entity_type, entity_undefined, get_bool_property(), get_string_property(), pips_debug, pips_user_error, statement_number, and string_of_type().

Referenced by malloc_to_abstract_location().

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

◆ original_malloc_to_abstract_location()

reference original_malloc_to_abstract_location ( expression lhs   __attribute__(unused),
type __attribute__((unused))  var_t,
type __attribute__((unused))  cast_t,
expression  sizeof_exp,
entity  f,
statement  stmt 
)

to handle malloc statemennts:

p = (cast t) malloc(sizeof(expression))

This function return a reference according to the value of the property ABSTRACT_HEAP_LOCATIONS. the list of callers will be added to ensure the context sensitive property. We should keep in mind that context and sensitive properties are orthogonal and we should modify them in pipsmake.

ABSTRACT_HEAP_LOCATIONS is set to "unique" and a unique abstract

location is used for all heap buckets. *\/

if(strcmp(opt, "unique")==0){

if(type_sensitive_p) {

e = entity_all_heap_locations_typed(var_t);

r = make_reference(e , NIL);

}

else {

e = entity_all_heap_locations();

r = make_reference(e , NIL);

}

}

/* in case the property ABSTRACT_HEAP_LOCATIONS is set to

"insensitive": an abstract location is used for each function. *\/

else if(strcmp(opt, "insensitive")==0){

if(type_sensitive_p) {

e = entity_all_module_heap_locations_typed(get_current_module_entity(),

var_t);

r = make_reference(e , NIL);

}

else {

e = entity_all_module_heap_locations(f);

r = make_reference(e , NIL);

}

}

/* in case the property ABSTRACT_HEAP_LOCATIONS is set to

"flow-sensitive" or "context-sensitive".

No difference here between the two values. The diffferent

behavior will show when points-to and effects are translated at

call sites

At this level, we want to use the statement number or the

statement ordering. The statement ordering is safer because two

statements or more can be put on the same line. The statement

number is more user-friendly.

There is no need to distinguish between types since the statement

ordering is at least as effective.

*\/

else if(strcmp(opt, "flow-sensitive")==0

|| strcmp(opt, "context-sensitive")==0 ){

e = entity_flow_or_context_sentitive_heap_location(stmt_number, var_t);

r = make_reference(e , NIL);

}

else {

pips_user_error("Unrecognized value for property ABSTRACT_HEAP_LOCATION:"

" \"s"", opt);

}

pips_debug(8, "Reference to ");

Definition at line 436 of file abstract_location.c.

442 {
447  f,
448  NIL);
449  //string opt = get_string_property("ABSTRACT_HEAP_LOCATIONS");
450  //bool type_sensitive_p = !get_bool_property("ALIASING_ACROSS_TYPES");
451 
452  e = malloc_to_abstract_location(sizeof_exp, &si);
453  if(!entity_array_p(e))
454  r = make_reference(e , NIL);
455  else
457  /* /\* in case we want an anywhere abstract heap location : the property */
458 /* ABSTRACT_HEAP_LOCATIONS is set to "unique" and a unique abstract */
459 /* location is used for all heap buckets. *\/ */
460 /* if(strcmp(opt, "unique")==0){ */
461 /* if(type_sensitive_p) { */
462 /* e = entity_all_heap_locations_typed(var_t); */
463 /* r = make_reference(e , NIL); */
464 /* } */
465 /* else { */
466 /* e = entity_all_heap_locations(); */
467 /* r = make_reference(e , NIL); */
468 /* } */
469 /* } */
470 
471 /* /\* in case the property ABSTRACT_HEAP_LOCATIONS is set to */
472 /* "insensitive": an abstract location is used for each function. *\/ */
473 /* else if(strcmp(opt, "insensitive")==0){ */
474 /* if(type_sensitive_p) { */
475 /* e = entity_all_module_heap_locations_typed(get_current_module_entity(), */
476 /* var_t); */
477 /* r = make_reference(e , NIL); */
478 /* } */
479 /* else { */
480 /* e = entity_all_module_heap_locations(f); */
481 /* r = make_reference(e , NIL); */
482 /* } */
483 /* } */
484 
485 /* /\* in case the property ABSTRACT_HEAP_LOCATIONS is set to */
486 /* "flow-sensitive" or "context-sensitive". */
487 
488 /* No difference here between the two values. The diffferent */
489 /* behavior will show when points-to and effects are translated at */
490 /* call sites */
491 
492 /* At this level, we want to use the statement number or the */
493 /* statement ordering. The statement ordering is safer because two */
494 /* statements or more can be put on the same line. The statement */
495 /* number is more user-friendly. */
496 
497 /* There is no need to distinguish between types since the statement */
498 /* ordering is at least as effective. */
499 /* *\/ */
500 /* else if(strcmp(opt, "flow-sensitive")==0 */
501 /* || strcmp(opt, "context-sensitive")==0 ){ */
502 /* e = entity_flow_or_context_sentitive_heap_location(stmt_number, var_t); */
503 /* r = make_reference(e , NIL); */
504 /* } */
505 /* else { */
506 /* pips_user_error("Unrecognized value for property ABSTRACT_HEAP_LOCATION:" */
507 /* " \"%s\"", opt); */
508 /* } */
509 
510 /* pips_debug(8, "Reference to "); */
511 
512  return r;
513 }
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
sensitivity_information make_sensitivity_information(statement current_stmt, entity current_module, list enclosing_flow)
bool entity_array_p(entity e)
Is e a variable with an array type?
Definition: entity.c:754
#define reference_undefined
Definition: ri.h:2302
Definition: statement.c:54

References CONS, entity_array_p(), entity_undefined, EXPRESSION, f(), int_to_expression(), make_reference(), make_sensitivity_information(), malloc_to_abstract_location(), NIL, and reference_undefined.

+ Here is the call graph for this function: