PIPS
sav_alias_classes.c File Reference
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "database.h"
#include "ri-util.h"
#include "effects-util.h"
#include "constants.h"
#include "misc.h"
#include "text.h"
#include "boolean.h"
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
#include "sommet.h"
#include "ray_dte.h"
#include "sg.h"
#include "polyedre.h"
#include "union.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "effects-convex.h"
#include "semantics.h"
#include "transformer.h"
#include "pipsdbm.h"
#include "resources.h"
#include "alias-classes.h"
+ Include dependency graph for sav_alias_classes.c:

Go to the source code of this file.

Functions

static list append_all_not_present (list initial_reg_list, list additional_list)
 The algorithms below depend on the following properties of Alias Lists and Alias Classes: More...
 
static void compare_other_list (region elem, list other_list)
 global variables IN: rest_list, other_lists global variables modified: rest_list, other_lists More...
 
static void compare_rest_other_lists (region elem)
 global variables IN: rest_list, rest_other_lists, other_lists global variables modified: rest_list, other_lists, rest_other_lists ATTENTION: recursive function compares "elem" (the current element from the list currently being made into a class) to each element of each list of "rest_other_lists" (the other lists not yet made into classes) if a match is found, "other_list" (the other list containing the matching element "other_elem") is appended to "rest_list" (the not yet treated elements from the list currently being made into a class) and "other_list" will no longer be a member of "other_lists" if not, "other_list" is appended to "other_lists" More...
 
static void make_class_from_list (list reg_list)
 global variables IN: class, rest_other_lists, other_lists global variables modified: class, other_lists, rest_other_lists, rest_list More...
 
static void make_classes_from_lists ()
 global variables IN: other_lists global variables modified:class, other_lists, rest_other_lists, rest_list ATTENTION: recursive function More...
 
static bool match_this_callee_class_elem (region callee_class_elem, list callee_alias_class)
 global variables IN: l_alias_lists global variables modified: l_alias_lists returns true if l_alias_lists modified, i.e. More...
 
static bool add_callee_class_to_lists (list callee_alias_class)
 global variables IN: l_alias_lists global variables modified: l_alias_lists More...
 
static void save_callee_class (list callee_alias_class)
 global variables IN: other_lists global variables modified: other_lists More...
 
static void add_classes_for_this_callee (string callee_name)
 global variables IN: l_alias_lists, other_lists global variables modified: l_alias_lists, other_lists More...
 
static void add_classes_callees (const char *module_name)
 
bool alias_classes (const string module_name)
 

Variables

static list l_alias_lists
 
static list l_alias_classes
 
static list other_lists
 
static list class
 
static list rest_list
 
static list rest_other_lists
 

Function Documentation

◆ add_callee_class_to_lists()

static bool add_callee_class_to_lists ( list  callee_alias_class)
static

global variables IN: l_alias_lists global variables modified: l_alias_lists

Definition at line 364 of file sav_alias_classes.c.

365 {
366  bool result = false;
367 
368  pips_debug(4,"begin\n");
369 
370  MAP(EFFECT,callee_class_elem,
371  {
372  if ( match_this_callee_class_elem(callee_class_elem,
373  callee_alias_class) )
374  result = true;
375  },
376  callee_alias_class);
377 
378  pips_debug(4,"end\n");
379 
380  return result;
381 }
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
static bool match_this_callee_class_elem(region callee_class_elem, list callee_alias_class)
global variables IN: l_alias_lists global variables modified: l_alias_lists returns true if l_alias_l...

References EFFECT, MAP, match_this_callee_class_elem(), and pips_debug.

Referenced by add_classes_for_this_callee().

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

◆ add_classes_callees()

static void add_classes_callees ( const char *  module_name)
static

Definition at line 432 of file sav_alias_classes.c.

433 {
434  callees all_callees;
435 
436  pips_debug(4,"begin\n");
437 
438  all_callees = (callees) db_get_memory_resource(DBR_CALLEES,
439  module_name,
440  true);
441 
442  MAP(STRING, callee_name,
443  {
444  add_classes_for_this_callee(callee_name);
445  },
446  callees_callees(all_callees));
447 
448  pips_debug(4,"end\n");
449 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define STRING(x)
Definition: genC.h:87
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
struct _newgen_struct_callees_ * callees
Definition: ri.h:55
#define callees_callees(x)
Definition: ri.h:675
static void add_classes_for_this_callee(string callee_name)
global variables IN: l_alias_lists, other_lists global variables modified: l_alias_lists,...

References add_classes_for_this_callee(), callees_callees, db_get_memory_resource(), MAP, module_name(), pips_debug, and STRING.

Referenced by alias_classes().

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

◆ add_classes_for_this_callee()

static void add_classes_for_this_callee ( string  callee_name)
static

global variables IN: l_alias_lists, other_lists global variables modified: l_alias_lists, other_lists

Definition at line 404 of file sav_alias_classes.c.

405 {
406  list callee_alias_classes;
407 
408  pips_debug(4,"begin for callee %s\n",callee_name);
409 
410  callee_alias_classes = effects_to_list((effects)
411  db_get_memory_resource(DBR_ALIAS_CLASSES,
412  callee_name,
413  true));
414  MAP(LIST,callee_alias_class,
415  {
416  ifdebug(9)
417  {
418  pips_debug(9,"add class:\n");
419  print_inout_regions(callee_alias_class);
420  }
421 
422  if (!add_callee_class_to_lists(callee_alias_class))
423  save_callee_class(callee_alias_class);
424  },
425  callee_alias_classes);
426 
427  pips_debug(4,"end\n");
428 }
void print_inout_regions(list)
list effects_to_list(effects)
Definition: effects.c:209
#define LIST(x)
Definition: genC.h:93
static void save_callee_class(list callee_alias_class)
global variables IN: other_lists global variables modified: other_lists
static bool add_callee_class_to_lists(list callee_alias_class)
global variables IN: l_alias_lists global variables modified: l_alias_lists
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References add_callee_class_to_lists(), db_get_memory_resource(), effects_to_list(), ifdebug, LIST, MAP, pips_debug, print_inout_regions(), and save_callee_class().

Referenced by add_classes_callees().

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

◆ alias_classes()

bool alias_classes ( const string  module_name)

ATTENTION: we have to do ALL this just to call print_inout_regions for debug !!

and this to call print_region set_action_interpretation(ACTION_IN,ACTION_OUT);

that's it, but we musn't forget to reset everything below

reset_action_interpretation();

Definition at line 452 of file sav_alias_classes.c.

453 {
455  entity module;
456 
457  debug_on("ALIAS_CLASSES_DEBUG_LEVEL");
458  pips_debug(4,"begin for module %s\n",module_name);
459  ifdebug(9)
460  {
461  /* ATTENTION: we have to do ALL this
462  * just to call print_inout_regions for debug !!
463  */
468  db_get_memory_resource(DBR_CODE,
469  module_name,
470  true) );
473  DBR_CUMULATED_EFFECTS,
474  module_name,
475  true));
478  DBR_PROPER_EFFECTS,
479  module_name,
480  true));
482  /* and this to call print_region
483  set_action_interpretation(ACTION_IN,ACTION_OUT); */
484  /* that's it, but we musn't forget to reset everything below */
485  }
486 
487  l_alias_lists = NIL;
489  other_lists = NIL;
490 
491 /*
492  alias_lists =
493  effects_to_list((effects)
494  db_get_memory_resource(DBR_ALIAS_LISTS,
495  module_name,
496  true));
497 */
498 
499  alias_lists =
501  db_get_memory_resource(DBR_ALIAS_LISTS,
502  module_name,
503  true));
504 
505  MAP(LIST,alias_list,
506  {
507  l_alias_lists =
508  gen_nconc(CONS(LIST,regions_dup(alias_list),NIL),
509  l_alias_lists);
510  },
511  alias_lists);
512 
513  ifdebug(9)
514  {
515  pips_debug(9,"alias lists:\n");
516  MAP(LIST,alias_list,
517  {
518  print_inout_regions(alias_list);
519  pips_debug(9,"---\n");
520  },
521  l_alias_lists);
522  }
523 
525 
526  ifdebug(9)
527  {
528  pips_debug(9,"alias lists:\n");
529  MAP(LIST,alias_list,
530  {
531  print_inout_regions(alias_list);
532  pips_debug(9,"---\n");
533  },
534  l_alias_lists);
535  pips_debug(9,"callee classes:\n");
536  MAP(LIST,alias_class,
537  {
538  print_inout_regions(alias_class);
539  pips_debug(9,"---\n");
540  },
541  other_lists);
542  }
543 
545 
547 
548  DB_PUT_MEMORY_RESOURCE(DBR_ALIAS_CLASSES,
551 
552  ifdebug(9)
553  {
554 /* reset_action_interpretation(); */
560  }
561  pips_debug(4,"end\n");
562  debug_off();
563 
564  return true;
565 }
effects_classes make_effects_classes(list a)
Definition: effects.c:526
bool alias_lists(const string)
alias_lists.c
Definition: alias_lists.c:328
list regions_dup(list)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
#define effects_classes_classes(x)
Definition: effects.h:678
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
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
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
#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 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 debug_off()
Definition: misc-local.h:160
static char * module
Definition: pips.c:74
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
static void make_classes_from_lists()
global variables IN: other_lists global variables modified:class, other_lists, rest_other_lists,...
static void add_classes_callees(const char *module_name)
static list other_lists
static list l_alias_lists
static list l_alias_classes
char * strdup()
void module_to_value_mappings(entity m)
void module_to_value_mappings(entity m): build hash tables between variables and values (old,...
Definition: mappings.c:624
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212

References add_classes_callees(), alias_lists(), CONS, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, effects_classes_classes, free_value_mappings(), gen_nconc(), get_current_module_entity(), ifdebug, l_alias_classes, l_alias_lists, LIST, local_name_to_top_level_entity(), make_classes_from_lists(), make_effects_classes(), MAP, module, module_name(), module_to_value_mappings(), NIL, other_lists, pips_debug, print_inout_regions(), regions_dup(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_proper_rw_effects(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_proper_rw_effects(), and strdup().

+ Here is the call graph for this function:

◆ append_all_not_present()

static list append_all_not_present ( list  initial_reg_list,
list  additional_list 
)
static

The algorithms below depend on the following properties of Alias Lists and Alias Classes:

  • an Alias List contains no repeated elements
  • two Alias Lists of the same module never have the same head (distinct heads)
  • an element from one Alias List of a particular module can also be present in another Alias List of the same module (not disjoint sets)
  • no element from one Alias Class of a particular module is also present in another Alias Class of the same module (disjoint sets) global variables IN: l_alias_lists gloabl variables modified: l_alias_lists add a copy of each element in additional_list not already present in initial_reg_list to the end of initial_reg_list

Definition at line 89 of file sav_alias_classes.c.

90 {
91  list new_reg_list;
92 
93  pips_debug(4,"begin\n");
94 
95  MAP(EFFECT,additional_reg,
96  {
97  new_reg_list = append_reg_if_not_present(initial_reg_list,
98  region_dup(additional_reg));
99  },
100  additional_list);
101 
102  pips_debug(4,"end\n");
103 
104  return new_reg_list;
105 }
effect region_dup(effect)
list append_reg_if_not_present(list reg_list, region reg)
adds reg as final element on the end of reg_list unless reg is already present in reg_list

References append_reg_if_not_present(), EFFECT, MAP, pips_debug, and region_dup().

Referenced by compare_other_list(), and match_this_callee_class_elem().

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

◆ compare_other_list()

static void compare_other_list ( region  elem,
list  other_list 
)
static

global variables IN: rest_list, other_lists global variables modified: rest_list, other_lists

Definition at line 112 of file sav_alias_classes.c.

113 {
114  bool result = false;
115  region other_elem;
116  list rest_other_list;
117 
118  ifdebug(4)
119  {
120  pips_debug(4,"begin for elem:\n");
122  print_region(elem);
124  pips_debug(4,"and list:\n");
125  print_inout_regions(other_list);
126  }
127 
128  if (other_list != NIL)
129  {
130  rest_other_list = other_list;
131  do {
132  other_elem = EFFECT(CAR(rest_other_list));
133  rest_other_list = CDR(rest_other_list);
134 
135  ifdebug(9)
136  {
137  pips_debug(9,"compare elem:\n");
139  print_region(other_elem);
141  }
142 
143  if ( effect_exact_p(other_elem) )
144  {
145  pips_debug(9,"exact\n");
146 
147  if ( same_reg_ignore_action(elem,other_elem) )
148  {
149  pips_debug(9,"same\n");
150 
152  result = true;
153  }
154  }
155  } while (result == false && rest_other_list != NIL);
156  if (result == false)
157  other_lists = gen_nconc(other_lists,CONS(LIST,other_list,NIL));
158  }
159  pips_debug(4,"end\n");
160 }
#define region
simulation of the type region
#define ACTION_IN
#define ACTION_OUT
void reset_action_interpretation(void)
void set_action_interpretation(string, string)
prettyprint.c
#define effect_exact_p(eff)
#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
#define print_region(x)
Definition: print.c:343
static list append_all_not_present(list initial_reg_list, list additional_list)
The algorithms below depend on the following properties of Alias Lists and Alias Classes:
static list rest_list
bool same_reg_ignore_action(region reg1, region reg2)
put reg in list of one element for call to alias_pairs

References ACTION_IN, ACTION_OUT, append_all_not_present(), CAR, CDR, CONS, EFFECT, effect_exact_p, gen_nconc(), ifdebug, LIST, NIL, other_lists, pips_debug, print_inout_regions(), print_region, region, reset_action_interpretation(), rest_list, same_reg_ignore_action(), and set_action_interpretation().

Referenced by compare_rest_other_lists().

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

◆ compare_rest_other_lists()

static void compare_rest_other_lists ( region  elem)
static

global variables IN: rest_list, rest_other_lists, other_lists global variables modified: rest_list, other_lists, rest_other_lists ATTENTION: recursive function compares "elem" (the current element from the list currently being made into a class) to each element of each list of "rest_other_lists" (the other lists not yet made into classes) if a match is found, "other_list" (the other list containing the matching element "other_elem") is appended to "rest_list" (the not yet treated elements from the list currently being made into a class) and "other_list" will no longer be a member of "other_lists" if not, "other_list" is appended to "other_lists"

Definition at line 178 of file sav_alias_classes.c.

179 {
180  list other_list;
181 
182  if (rest_other_lists != NIL)
183  {
184  ifdebug(4)
185  {
186  pips_debug(4,"begin for:\n");
188  print_region(elem);
190  }
191 
192  other_list = LIST(CAR(rest_other_lists));
194  compare_other_list(elem, other_list);
195 
196  if(rest_other_lists != NIL)
198 
199  pips_debug(4,"end\n");
200  }
201 }
static void compare_rest_other_lists(region elem)
global variables IN: rest_list, rest_other_lists, other_lists global variables modified: rest_list,...
static list rest_other_lists
static void compare_other_list(region elem, list other_list)
global variables IN: rest_list, other_lists global variables modified: rest_list, other_lists

References ACTION_IN, ACTION_OUT, CAR, CDR, compare_other_list(), ifdebug, LIST, NIL, pips_debug, print_region, reset_action_interpretation(), rest_other_lists, and set_action_interpretation().

Referenced by make_class_from_list().

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

◆ make_class_from_list()

static void make_class_from_list ( list  reg_list)
static

global variables IN: class, rest_other_lists, other_lists global variables modified: class, other_lists, rest_other_lists, rest_list

Definition at line 208 of file sav_alias_classes.c.

209 {
210  region elem;
211 
212  ifdebug(4)
213  {
214  pips_debug(4,"begin for:\n");
215  print_inout_regions(reg_list);
216  }
217 
218  if (reg_list != NIL)
219  {
220  rest_list = reg_list;
221  do {
222  elem = EFFECT(CAR(rest_list));
224 
225  ifdebug(9)
226  {
227  pips_debug(9,"elem:\n");
229  print_region(elem);
231  }
232 
233  if ( effect_exact_p(elem) )
234  {
235  pips_debug(9,"exact\n");
236 
238  other_lists = NIL;
240  }
241  class = gen_nconc(class,CONS(EFFECT,elem,NIL));
242  } while(rest_list != NIL);
243  }
244 
245  pips_debug(4,"end\n");
246 }
static list class

References ACTION_IN, ACTION_OUT, CAR, CDR, class, compare_rest_other_lists(), CONS, EFFECT, effect_exact_p, gen_nconc(), ifdebug, NIL, other_lists, pips_debug, print_inout_regions(), print_region, region, reset_action_interpretation(), rest_list, rest_other_lists, and set_action_interpretation().

Referenced by make_classes_from_lists().

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

◆ make_classes_from_lists()

static void make_classes_from_lists ( )
static

global variables IN: other_lists global variables modified:class, other_lists, rest_other_lists, rest_list ATTENTION: recursive function

rest_other_lists = CDR(other_lists);

other_lists = NIL;

Definition at line 254 of file sav_alias_classes.c.

255 {
256  list next_list;
257 
258  if (other_lists != NIL)
259  {
260  pips_debug(4,"begin\n");
261 
262  next_list = LIST(CAR(other_lists));
263 /* rest_other_lists = CDR(other_lists); */
264 /* other_lists = NIL; */
266  class = NIL;
267 
268  make_class_from_list(next_list);
270 
271  ifdebug(9)
272  {
273  pips_debug(9,"class:\n");
274  print_inout_regions(class);
275  pips_debug(9,"other_lists:\n");
276  MAP(LIST,alias_list,
277  {
278  print_inout_regions(alias_list);
279  pips_debug(9,"---\n");
280  },
281  other_lists);
282  }
283 
285 
286  pips_debug(4,"end\n");
287  }
288 }
static void make_class_from_list(list reg_list)
global variables IN: class, rest_other_lists, other_lists global variables modified: class,...

References CAR, CDR, CONS, gen_nconc(), ifdebug, l_alias_classes, LIST, make_class_from_list(), MAP, NIL, other_lists, pips_debug, and print_inout_regions().

Referenced by alias_classes().

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

◆ match_this_callee_class_elem()

static bool match_this_callee_class_elem ( region  callee_class_elem,
list  callee_alias_class 
)
static

global variables IN: l_alias_lists global variables modified: l_alias_lists returns true if l_alias_lists modified, i.e.

if callee_class_elem is present in one or more of the callers alias lists, in which case, the whole callee_alias_class is added to each of these caller alias lists

Definition at line 301 of file sav_alias_classes.c.

302 {
303  bool result = false;
304  list rest_alias_lists, alias_list;
305  region formal_reg_caller_list;
306 
307  ifdebug(4)
308  {
309  pips_debug(4,"begin for elem:\n");
311  print_region(callee_class_elem);
313  }
314 
315  rest_alias_lists = l_alias_lists;
316  if (l_alias_lists != NIL)
317  do{
318  alias_list = LIST( CAR(rest_alias_lists) );
319  formal_reg_caller_list = EFFECT( CAR(alias_list) );
320 
321  ifdebug(9)
322  {
323  pips_debug(9,"compare with:\n");
325  print_region(formal_reg_caller_list);
327  }
328 
329  if ( same_reg_ignore_action(formal_reg_caller_list,
330  callee_class_elem) )
331  {
332  pips_debug(9,"match\n");
333  ifdebug(9)
334  {
335  pips_debug(9,"old alias list:\n");
336  print_inout_regions(alias_list);
337  }
338 
339  result = true;
340  alias_list =
341  append_all_not_present(alias_list,
342  callee_alias_class);
343 
344  ifdebug(9)
345  {
346  pips_debug(9,"new alias list:\n");
347  print_inout_regions(alias_list);
348  }
349 
350  }
351  rest_alias_lists = CDR(rest_alias_lists);
352  }while (rest_alias_lists != NIL && result == false);
353 
354  pips_debug(4,"end\n");
355 
356  return result;
357 }

References ACTION_IN, ACTION_OUT, append_all_not_present(), CAR, CDR, EFFECT, ifdebug, l_alias_lists, LIST, NIL, pips_debug, print_inout_regions(), print_region, region, reset_action_interpretation(), same_reg_ignore_action(), and set_action_interpretation().

Referenced by add_callee_class_to_lists().

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

◆ save_callee_class()

static void save_callee_class ( list  callee_alias_class)
static

global variables IN: other_lists global variables modified: other_lists

Definition at line 388 of file sav_alias_classes.c.

389 {
390  pips_debug(4,"begin\n");
391 
392  other_lists =
394  CONS(LIST,regions_dup(callee_alias_class),NIL));
395 
396  pips_debug(4,"end\n");
397 }

References CONS, gen_nconc(), LIST, NIL, other_lists, pips_debug, and regions_dup().

Referenced by add_classes_for_this_callee().

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

Variable Documentation

◆ class

list class
static

Definition at line 68 of file sav_alias_classes.c.

Referenced by make_class_from_list().

◆ l_alias_classes

list l_alias_classes
static

Definition at line 67 of file sav_alias_classes.c.

Referenced by alias_classes(), and make_classes_from_lists().

◆ l_alias_lists

list l_alias_lists
static

Definition at line 67 of file sav_alias_classes.c.

Referenced by alias_classes(), and match_this_callee_class_elem().

◆ other_lists

◆ rest_list

list rest_list
static

Definition at line 68 of file sav_alias_classes.c.

Referenced by compare_other_list(), and make_class_from_list().

◆ rest_other_lists

list rest_other_lists
static

Definition at line 68 of file sav_alias_classes.c.

Referenced by compare_rest_other_lists(), and make_class_from_list().