PIPS
anywhere_abstract_locations.c
Go to the documentation of this file.
1 #ifdef HAVE_CONFIG_H
2  #include "pips_config.h"
3 #endif
4 #include <stdio.h>
5 #include <string.h>
6 #include <stdlib.h>
7 
8 #include "genC.h"
9 #include "linear.h"
10 #include "ri.h"
11 #include "effects.h"
12 #include "ri-util.h"
13 #include "effects-util.h"
14 #include "misc.h"
15 #include "properties.h"
16 
17 /*
18 The ANYWHERE lattice is shown in the figure:
19 
20  *ANY_MODULE*:*ANYWHERE*
21  |
22  --------------------------------------------------
23  | |
24  module:*ANYWHERE* module2:*ANYWHERE*
25  / | \
26  / | \
27  / | \
28  module:*HEAP* module:*STACK* module:*STATIC*...
29  \ | /
30  \ | /
31  \ | /
32  \ | /
33  --- --------------------------------------------------
34  |
35  *ANY_MODULE*:*NOWHERE*
36 
37 It is used to modelize the anywhere abstract locations, but some
38 elements are missing such as *ANYWHERE*:*HEAP*, *ANYWHERE*:*STACK*,
39 etc.
40 
41 All the generating functions for this lattice return an
42 entity, but the API can be easily translated at the reference or the
43 effect level.
44 
45 To merge abstract locations linked to two different modules, the
46 module ANY_MODULE_NAME (*ANYWHERE*) is used. For instance, FOO:*HEAP*
47 and BAR:*HEAP* are included into *ANYWHERE*:*HEAP*, their smallest
48 upper bound.
49 
50 To merge different areas for the same module, such as FOO:*HEAP* and
51 FOO:*STACK*, the abstract location *ANYWHERE* is used.
52 
53 If the modules are different and the areas are different, then the
54 resulting abstract location is *ANYWHERE*:*ANYWHERE*.
55 
56 */
57 ␌
58 // FI: redundance between all_locations and anywhere
59 
60 /*return *ANY_MODULE*:*ANYWHERE* (the top of the lattice)
61  *
62  * FI->aM: it was first decided to make this entity an area, but areas
63  * cannot be typed. So the internal representation must be changed to
64  * carry a type usable according to ALIAS_ACROSS_TYPES. The top of the
65  * location lattice should use overloaded as type, that is the top of
66  * the type lattice.
67  */
69 {
70  entity anywhere = entity_undefined;
71  static const char any_name[] =
73  anywhere = gen_find_tabulated(any_name, entity_domain);
74  if(entity_undefined_p(anywhere)) {
75  area a = make_area(0,NIL); /* Size and layout are unknown */
76  type t = make_type_area(a);
77  anywhere = make_entity(strdup(any_name),
78  t,
82  }
83 
84  return anywhere;
85 }
86 
88 {
89  return entity_all_locations();
90 }
91 
92 /* test if an entity is the top of the lattice
93  *
94  * This test does not take typed anywhere into account. This is
95  * consistent with the function name, but may be not with its uses.
96  *
97  * It is not consistent with hiding the impact of
98  * ALIASING_ACROSS_TYPES from callers.
99  */
101 {
102 
103  bool anywhere_p;
105  anywhere_p = anywhere_p
107 
108  return anywhere_p;
109 }
110 
112 {
114 }
115 
117 {
119  if(get_bool_property("ALIASING_ACROSS_TYPES"))
120  a = entity_all_locations();
121  else
123  return a;
124 }
125 
126 /* test if an entity is the bottom of the lattice*/
128 {
129  return same_entity_p(e, entity_all_locations());
130 }
131 
132 /* test if a cell is the bottom of the lattice*/
134 {
136  bool anywhere_p = reference_typed_anywhere_locations_p(r);
137  return anywhere_p;
138 }
139 
140 /* test if a reference is the bottom of the lattice*/
142 {
143  entity e = reference_variable(r);
144  bool anywhere_p = entity_typed_anywhere_locations_p(e);
145  return anywhere_p;
146 }
147 
148 
149 /* Test if an entity is the bottom of the lattice. Not really since it
150  * is typed...
151  *
152  * The typed anywhere locations have names like ANYWHERE_LOCATION_bxxx
153  *
154  * Beware, because the string ANYWHERE_LOCATION is also used for the
155  * heap, *HEAP**ANYWHERE*.
156  *
157  * Also, this does not check for the module: is it ANYMODULE or a
158  * specific module?
159  */
161 {
162  bool typed_anywhere_p = false;
163  string ln = (string) entity_local_name(e);
164  string p = strstr(ln, ANYWHERE_LOCATION);
165  if(p==ln) {
166  // if the two strings are equal, we have the non-typed anywhere location
167  typed_anywhere_p = strcmp(ln, ANYWHERE_LOCATION);
168  }
169  return typed_anywhere_p;
170 }
171 ␌
172 /* return *ANY_MODULE*:*NOWHERE* */
173 
175 {
176  static entity nowhere = entity_undefined;
177  static const char any_name [] = ANY_MODULE_NAME MODULE_SEP_STRING NOWHERE_LOCATION ;
178  nowhere = gen_find_tabulated(any_name, entity_domain);
179  if(entity_undefined_p(nowhere)) {
180  area a = make_area(0,NIL); /* Size and layout are unknown */
181  type t = make_type_area(a);
182  nowhere = make_entity(strdup(any_name),
185  register_static_entity(&nowhere);
186  }
187 
188  return nowhere;
189 }
190 
192 {
194 }
195 
196 /* test if an entity is the bottom of the lattice
197  *
198  * Should we care for the typed nowhere too?
199 */
201 {
203 }
204 
205 /* test if an entity is the bottom of the lattice*/
207 {
208  string ln = (string) entity_local_name(e);
209  string p = strstr(ln, NOWHERE_LOCATION);
210  return p!=NULL;
211 }
212 ␌
213 
214 /* return TOP-LEVEL:*NULL_POINTER*
215  * The NULL pointer should be a global variable, unique for all modules
216  * FI: why isn't it called entity_null_location()?
217  *
218  * Since NULL is a constant, it should be declared as a function. But
219  * then it cold not be used in a reference for the points-to
220  * analysis. Too bad for the semantics analysis of pointers were a
221  * constant 0-ary function would make more sense.
222  */
224 {
225  static entity null_pointer = entity_undefined;
226  if(entity_undefined_p(null_pointer)) {
227  if(true) {
229  area a = make_area(0,NIL); /* Size and layout are unknown */
230  type t = make_type_area(a);
231  null_pointer = make_entity(strdup(null_name),
233  // FI: I do not see why NULL should be an abstract location; it
234  // does not represent a set of locations, but a unique one
235  // entity_kind(null_pointer) = ABSTRACT_LOCATION;
236  entity_kind(null_pointer) = DEFAULT_ENTITY_KIND;
237  }
238  else {
243  entity_type(null_pointer) = ft;
244  entity_storage(null_pointer) = make_storage_rom();
246  }
247  register_static_entity(&null_pointer);
248  }
249 
250  return null_pointer;
251 }
252 
253 /* test if an entity is the NULL POINTER*/
255 {
257 }
258 ␌
259 /* return m:*ANYWHERE*
260  Set of all memory locations related to one module.
261 
262  FI: This may prove useless unless the compilation unit is taken into
263  account.
264  */
266 {
267  entity anywhere = entity_undefined;
268  const char* mn = entity_local_name(m);
269 
270  anywhere = FindEntity(mn,ANYWHERE_LOCATION);
271  if(entity_undefined_p(anywhere)) {
272  area a = make_area(0,NIL); /* Size and layout are unknown */
273  type t = make_type_area(a);
274  /* FI: any_name? */
275  anywhere = CreateEntity(mn,ANYWHERE_LOCATION);
276  entity_type(anywhere)=t;
277  entity_storage(anywhere)=make_storage_rom();
279  entity_kind(anywhere)=ABSTRACT_LOCATION;
280  }
281 
282  return anywhere;
283 }
284 
285 /* test if an entity is the set of locations defined in a module */
287 {
288 
289  bool all_module_p;
291 
292  return all_module_p;
293 }
294 ␌
295 /* return m:xxx*ANYWHERE*
296  * Generic set of functions for all kinds of areas
297 */
298 
300 {
301  entity dynamic = entity_undefined;
302  string any_name;
303  asprintf(&any_name, "%s" ANYWHERE_LOCATION, xxx);
304 
305  //dynamic = gen_find_tabulated(any_name, entity_domain);
306  dynamic = FindOrCreateEntity(entity_local_name(m), any_name);
307  if(storage_undefined_p(entity_storage(dynamic))) {
308  area a = make_area(0,NIL); /* Size and layout are unknown */
309  type t = make_type_area(a);
310  /*FI: more work to be done here... */
311  entity_type(dynamic) = t;
312  entity_storage(dynamic) = make_storage_rom();
313  entity_initial(dynamic) = make_value_unknown();
315  }
316  free(any_name);
317 
318  return dynamic;
319 }
320 
321 entity entity_all_module_xxx_locations_typed(const char* mn, const char* xxx, type t)
322 {
324  int count = 0;
325  bool found_p = false; // a break could be used instead
326 
327  pips_assert("Type t is defined", !type_undefined_p(t));
328 
329  for(count = 0; !found_p; count++) {
330 
331  type ot = type_undefined;
332  char * local_name;
333 
334  asprintf(&local_name, "%s_b%d", xxx,count);
336  free(local_name);
337  ot = entity_type(e);
338  if(type_undefined_p(ot)) {
339  /* A new entity has been created */
340  //area a = make_area(0,NIL); /* Size and layout are unknown */
341  //type t = make_type_area(a);
342  /*FI: more work to be done here... */
343  entity_type(e) = copy_type(t); /* no aliasing */
346  found_p = true;
347 
348  }
349  else if(type_equal_p(t, ot))
350  found_p = true;
351  }
352 
353  // FI: the debug message should be improved with full information
354  // about the type... See get_symbol_table() and isolate the code
355  // used to prettyprint the type. Too bad it uses the buffer type...
356  pips_debug(8, "New abstract location entity \"%s\" found or created"
357  " with type \"%s\"\n", entity_name(e), type_to_string(t));
358 
359  return e;
360 }
361 
362 
363 /* test if an entity is the set of all memory locations in the xxx
364  area of a module. The module is not checked, so it can be the set
365  of all modules... */
367 {
368  bool dynamic_p;
369  string s = concatenate(xxx, ANYWHERE_LOCATION, NULL);
370 
371  pips_assert("e is defined", !entity_undefined_p(e));
372 
373  dynamic_p = same_string_p(entity_local_name(e), s);
374 
375  return dynamic_p;
376 }
377 
378 /* return *ANY_MODULE*:xxx */
380 {
381  entity dynamic = entity_undefined;
382  dynamic = FindOrCreateEntity(ANY_MODULE_NAME,xxx);
383 
384  if(type_undefined_p(entity_type(dynamic))) {
385  //area a = make_area(0,NIL); /* Size and layout are unknown */
386  //type t = make_type_area(a);
387  /*FI: more work to be done here... */
388  /* FI: I'd like to make the type variable, overloaded,... */
389  // entity_type(dynamic) = make_type_unknown();
391  variable v = make_variable(b, NIL, NIL);
392  entity_type(dynamic) = make_type_variable(v);
393  entity_storage(dynamic) = make_storage_rom();
394  entity_initial(dynamic) = make_value_unknown();
400  }
401 
402  return dynamic;
403 }
404 
405 /* FI->AM: the predicate entity_all_xxx_locations_typed_p() is missing... */
407 {
409  int count = 0;
410  bool found_p = false; // a break could be used instead
411 
412  pips_assert("Type t is defined", !type_undefined_p(t));
413  pips_assert("Type t is not functional", !type_functional_p(t));
414 
415  for(count = 0; !found_p; count++) {
416  string name = string_undefined;
417  type ot = type_undefined;
418 
419  asprintf(&name, "%s_b%d", xxx, count);
421  free(name);
422  ot = entity_type(e);
423  if(type_undefined_p(ot)) {
424  /* A new entity has been created */
425  //area a = make_area(0,NIL); /* Size and layout are unknown */
426  //type t = make_type_area(a);
427  /*FI: more work to be done here... */
428  entity_type(e) = copy_type(t);
432  found_p = true;
433  }
434  else if(type_equal_p(t, ot)) // FI: do we want to relax this test?
435  found_p = true;
436  }
437 
438  // FI: the debug message should be improved with full information
439  // about the type... See get_symbol_table() and isolate the code
440  // used to prettyprint the type. Too bad it uses the buffer type...
441  ifdebug(8) {
442  pips_debug(8, "New abstract location entity \"%s\" found or created"
443  " with type ", entity_name(e));
444  print_type(t);
445  fprintf(stderr, "\n");
446  }
447 
448  return e;
449 }
450 
451 /* test if an entity is the set of all memory locations in the xxx
452  * area of any module.
453  *
454  * FI->AM: how come w generate *HEAP* and we check *HEAP**ANYWHERE*?
455  */
457 {
458  bool dynamic_p;
459  string s = concatenate(xxx, ANYWHERE_LOCATION, NULL);
460 
461  dynamic_p = same_string_p(entity_local_name(e), s);
462  dynamic_p = dynamic_p
464 
465  return dynamic_p;
466 }
467 
468 ␌
469 
470 /* return m:*HEAP**ANYWHERE */
472 {
474 }
475 
477 {
480 }
481 
482 /* test if an entity is the a heap area*/
484 {
486 }
487 
488 /* return ANY_MODULE:*HEAP*
489  *
490  * FI->AM: I move it to ANY_MODULE:*HEAP**ANYWHERE*
491  *
492  * Not compatible with entity_all_locations_p()...
493  */
495 {
497 }
498 
499 /* test if an entity is the set of all heap locations
500  *
501  * We look for "*ANY_MODULE*:*HEAP**ANYWHERE*"... unless it is "foo:*HEAP**ANYWHERE*"
502  *
503  * FI->AM: this is not compatible with the entity name *ANY-MODULE*:*HEAP*
504  */
506 {
508 }
509 
511 {
513 }
514 
515 // FI->AM: missing predicate...
516 //bool entity_all_heap_locations_typed_p(entity e)
517 //{
518 // return entity_all_xxx_locations_typed_p(e, HEAP_AREA_LOCAL_NAME);
519 //}
520 
521 ␌
522 /* return m:*STACK**ANYWHERE */
524 {
526 }
527 
528 /* test if an entity is the a stack area*/
530 {
532 }
533 
534 /* return ANY_MODULE:*STACK* */
536 {
538 }
539 
540 /* test if an entity is the set of all stack locations */
542 {
544 }
545 
546 ␌
547 /* return m:*DYNAMIC**ANYWHERE */
549 {
551 }
552 
553 /* test if an entity is the a static area*/
555 {
557 }
558 
559 /* return ANY_MODULE:*STATIC* */
561 {
563 }
564 
565 /* test if an entity is the set of all static locations*/
567 {
569 }
570 
571 ␌
572 /* return m:*DYNAMIC**ANYWHERE */
574 {
576 }
577 
578 /* test if an entity is the a dynamic area*/
580 {
582 }
583 
584 /* return ANY_MODULE:*DYNAMIC* */
586 {
588 }
589 
590 /* test if an entity is the set of all dynamic locations */
592 {
594 }
595 
596 /* test if an entity is a stub sink for a formal parameter
597  e.g. f->_f_1, EXACT
598 */
600 {
601  bool stub_sink_p = false;
602  bool dummy_target_p = false;
603  const char * en = entity_local_name(e);
604  storage s = entity_storage(e);
605  if(storage_ram_p(s)) {
606  // dummy_target_p = pointer_dummy_targets_area_p(ram_section(storage_ram(s)));
607  dummy_target_p = formal_area_p(ram_section(storage_ram(s)));
608  }
609  char first = en[0];
610  //char penultimate = en[strlen(en) - 2];
611  int l = strlen(en);
612  if(dummy_target_p && first == '_') {
613  int i = 1;
614  while('0' <=en[l-i] && en[l-i]<='9') {
615  i++;
616  }
617  if(i>=2 && en[l-i]=='_')
618  stub_sink_p = true;
619  }
620 
621  return stub_sink_p;
622 }
623 
625 {
626  bool stub_p = entity_stub_sink_p(s);
627  if(stub_p) {
628  /* There are several ways to decide if entity "s" is local to "m":
629  its module name, its belonging to the declarations of m, its
630  storage,... Let's avoir string comparisons and list scans... */
631  storage ss = entity_storage(s);
632  if(storage_ram_p(ss)) {
633  ram rss = storage_ram(ss);
634  entity f = ram_function(rss);
635  stub_p = m==f;
636  }
637  }
638  return stub_p;
639 }
640 ␌
642 {
643 #ifndef NDEBUG
644  const char * en = entity_name(al);
645  const char * module_sep = strchr(en,MODULE_SEP_CHAR);
646  bool abstract_locations_p = ( 0 == strncmp(en,ANY_MODULE_NAME,module_sep++ - en) // << FI: this may change in the future and may not be a strong enough condition
647  || 0 == strncmp(module_sep, ANYWHERE_LOCATION, sizeof(ANYWHERE_LOCATION)-1)
648  || 0 == strncmp(module_sep, STATIC_AREA_LOCAL_NAME, sizeof(STATIC_AREA_LOCAL_NAME)-1)
649  || 0 == strncmp(module_sep, DYNAMIC_AREA_LOCAL_NAME, sizeof(DYNAMIC_AREA_LOCAL_NAME)-1)
650  || 0 == strncmp(module_sep, STACK_AREA_LOCAL_NAME, sizeof(STACK_AREA_LOCAL_NAME)-1)
651  || 0 == strncmp(module_sep, HEAP_AREA_LOCAL_NAME, sizeof(HEAP_AREA_LOCAL_NAME)-1)
652  || 0 == strncmp(module_sep, FORMAL_AREA_LOCAL_NAME, sizeof(HEAP_AREA_LOCAL_NAME)-1)
653  // || 0 == strncmp(module_sep, NULL_POINTER_NAME, sizeof(NULL_POINTER_NAME)-1)
654  )
655  ;
656  pips_assert("entity_kind is consistent",abstract_locations_p == ((entity_kind(al)&ABSTRACT_LOCATION)==ABSTRACT_LOCATION));
657 #endif
658  return (entity_kind(al) & ABSTRACT_LOCATION) ? true : false;
659 }
660 
661 ␌
662 /* returns the smallest abstract locations containing the location of
663  variable v.
664 
665  This does not work for formal parameters or, if it works, the
666  caller module is not known and the resulting abstract location is
667  very large. A large abstract location is returned.
668 
669  No idea to model return values... even though they are located in
670  the stack in real world.
671 
672  If v cannot be converted into an abstract location, either the
673  function aborts or an undefined entity is returned.
674 */
676 {
678 
680  al = v;
681  /* NULL is an abstract location */
682  else if(entity_null_locations_p(v))
683  al = v;
684  else if(entity_variable_p(v)
686  && !variable_return_p(v)) {
687  bool typed_p = !get_bool_property("ALIASING_ACROSS_TYPES");
688 
689  // Too simplistic
690  //al = FindOrCreateEntity(mn, ln);
691 
692  if(formal_parameter_p(v)) {
693  const char * ln = FORMAL_AREA_LOCAL_NAME;
695  storage s = entity_storage(v);
696  formal fs = storage_formal(s);
697  entity f = formal_function(fs);
698  if(typed_p) {
699  const char* fn = entity_local_name(f);
700  al = entity_all_module_xxx_locations_typed(fn, ln, uvt);
701  }
702  else
704  entity_kind(al)=ABSTRACT_LOCATION; // should it be a static/dynamic/stack/heap area too ? not according to static_area_p
705  }
706  else { // must be a standard variable, or a stub
707  storage s = entity_storage(v);
708  ram r = storage_ram(s);
709  entity f = ram_function(r);
710  entity a = ram_section(r);
711  //string mn = entity_local_name(f);
712  const char *ln = string_undefined;
714 
715  if(static_area_p(a))
717  else if(dynamic_area_p(a))
719  else if(stack_area_p(a))
721  else if(heap_area_p(a))
723  else if(formal_area_p(a))
725  else
726  pips_internal_error("Unexpected area\n");
727 
728  if(typed_p) {
729  const char* fn = entity_local_name(f);
730  al = entity_all_module_xxx_locations_typed(fn, ln, uvt);
731  }
732  else
734  entity_kind(al)=ABSTRACT_LOCATION; // should it be a static/dynamic/stack/heap area too ? not according to static_area_p
735  }
736  }
737  else
738  pips_internal_error("arg. not in definition domain");
739 
740  pips_assert("al is an abstract location entity",
742 
743  return al;
744 }
745 
746 ␌
747 /*returns the smallest abstract location set greater than or equalt to
748  al1 and al2.
749 
750  If al1 or al2 is nowhere, then return al2 or al1.
751 
752  If al1 and al2 are related to the same module, the module can be
753  preserved. Else the anywhere module must be used.
754 
755  If al1 and al2 are related to the same area, then the area is
756  preserved. Else, the *anywhere* area is used.
757 
758  FI: The type part of the abstract location lattice is not
759  implemented... Since the abstract locations are somewhere defined as
760  area, they cannot carry a type. Types are taken care of for heap
761  modelization but not more the abstract locations.
762 
763  FI: we are in trouble with the NULL pointer...
764 */
765 /* here al1 and al2 must be abstract locations */
767 {
769 
770  if (same_entity_p(al1, al2)) /* avoid costly string operations in trivial case */
771  e = al1;
772  else if(!get_bool_property("ALIASING_ACROSS_TYPES")) {
775  if(!type_equal_p(t1, t2))
777  }
778 
779  if(entity_undefined_p(e)) {
780  // FI: the string based tests are not reliable as there is no link
781  // between suffixes and types, even within one module
782  const char* ln1 = entity_local_name(al1);
783  const char* ln2 = entity_local_name(al2);
784  char* mn1 = strdup(entity_module_name(al1));
785  char* mn2 = strdup(entity_module_name(al2));
786  const char* ln;
787  const char* mn;
788  static int mc = 0; // Message count: to avoid multiple repetitions
789 
790  if(mc==0 && !get_bool_property("ALIASING_ACROSS_TYPES")) {
791  //pips_internal_error("Option not implemented yet.");
792  pips_user_warning("property \"ALIASING_ACROSS_TYPES\" is assumed true"
793  " for abstract locations.\n");
794  mc++;
795  }
796 
797  if(strcmp(ln1, ln2)==0)
798  ln = ln1;
799  else
800  ln = ANYWHERE_LOCATION;
801 
802  if(strcmp(mn1, mn2)==0)
803  mn = mn1;
804  else
805  mn = ANY_MODULE_NAME;
806  e = FindEntity(mn, ln);
807 
808  if(true || entity_undefined_p(e)) {
809  if(get_bool_property("ALIASING_ACROSS_TYPES")) {
811  }
812  else {
813  type t1 = entity_type(al1);
814  type t2 = entity_type(al2);
815  if(type_equal_p(t1, t2))
817  else
819  }
820  }
821 
822  free(mn1);free(mn2);
823  }
824  return e;
825 }
826 
827 /* Here, entity al1 and entity al2 can be program variables
828  */
830 {
832  //string ln1 = entity_local_name(al1);
833  //string ln2 = entity_local_name(al2);
834 
835  if(al1==al2) {
836  e = al1;
837  }
838  else {
839  bool al1_abstract_location_p = entity_abstract_location_p(al1);
840  bool al2_abstract_location_p = entity_abstract_location_p(al2);
841  if(al1_abstract_location_p )
842  if(al2_abstract_location_p ) {
843  /* Both al1 and al2 are abstract locations and they are
844  different */
845  e = abstract_locations_max(al1, al2);
846  }
847  else {
849  e = abstract_locations_max(al1, al);
850  }
851  else
852  if(al2_abstract_location_p) {
854  e = abstract_locations_max(al, al2);
855  }
856  else {
857  /* al1 and al2 are assumed to be variables */
858  storage s1 = entity_storage(al1);
859  storage s2 = entity_storage(al2);
860 
861  if(storage_ram_p(s1) && storage_ram_p(s2)) {
862  ram r1 = storage_ram(s1);
863  ram r2 = storage_ram(s2);
864  entity f1 = ram_function(r1);
865  entity f2 = ram_function(r2);
866  entity a1 = ram_section(r1);
867  entity a2 = ram_section(r2);
868  const char* mn ;
869  const char* ln ;
870 
871  if(f1==f2)
872  mn = entity_local_name(f1);
873  else
874  mn = ANY_MODULE_NAME;
875 
876  if(static_area_p(a1) && static_area_p(a2))
878  else if(dynamic_area_p(a1) && dynamic_area_p(a2))
880  else if(stack_area_p(a1) && stack_area_p(a2))
882  else if(heap_area_p(a1) && heap_area_p(a2))
884  else
885  ln = ANYWHERE_LOCATION;
886  e = FindEntity(mn, ln);
887  }
888  else
889  pips_internal_error("not implemented");
890  }
891  }
892  return e;
893 }
894 ␌
895 /* in case we need to evaluate sigma(al), i.e. the locations pointed
896  by al, return the top of the lattice. Of course, this function
897  should be avoided as much as possible. */
899 {
901  e = entity_all_locations();
902  return e;
903 }
904 ␌
905 /* For debugging the API */
907  {
909  /* top */
910  al = entity_all_locations();
911  fprintf(stderr, "top: %s is %s\n", entity_name(al),
913  "the set of all application locations" : "bug!!!");
914 
915  /* bottom */
917  fprintf(stderr, "bottom: %s is %s\n", entity_name(al),
919  "the bottom of the abstract location lattice" : "bug!!!");
920 
921  /* null pointer */
922  al = entity_null_locations();
923  fprintf(stderr, "null: %s is %s\n", entity_name(al),
925  "the null pointer" : "bug!!!");
926 
927  /* all locations for a given module */
929  fprintf(stderr, "all module locations: %s is %s\n", entity_name(al),
931  "the set of all locations of a module" : "bug!!!");
932 
933  /* all heap locations for a given module */
935  fprintf(stderr, "all module heap locations: %s is %s\n", entity_name(al),
937  "the set of all heap locations of a module" : "bug!!!");
938 
939  /* all stack locations for a given module */
941  fprintf(stderr, "all module stack locations: %s is %s\n", entity_name(al),
943  "the set of all stack locations of a module" : "bug!!!");
944 
945  /* all static locations for a given module */
947  fprintf(stderr, "all module static locations: %s is %s\n", entity_name(al),
949  "the set of all static locations of a module" : "bug!!!");
950 
951  /* all dynamic locations for a given module */
953  fprintf(stderr, "all module dynamic locations: %s is %s\n", entity_name(al),
955  "the set of all dynamic locations of a module" : "bug!!!");
956 
957 
958  /* all heap locations for an application */
960  fprintf(stderr, "all application heap locations: %s is %s\n", entity_name(al),
962  "the set of all heap locations of an application" : "bug!!!");
963 
964  /* all stack locations for an application */
966  fprintf(stderr, "all application stack locations: %s is %s\n", entity_name(al),
968  "the set of all stack locations of an application" : "bug!!!");
969 
970  /* all static locations for an application */
972  fprintf(stderr, "all application static locations: %s is %s\n", entity_name(al),
974  "the set of all static locations of an applciation" : "bug!!!");
975 
976  /* all dynamic locations for an application */
978  fprintf(stderr, "all module dynamic locations: %s is %s\n", entity_name(al),
980  "the set of all dynamic locations of an application" : "bug!!!");
981 
982  /* Should/could be extended to check the max computation... */
983  }
984 
985  /**
986  * @brief Do these two abstract locations MAY share some real memory
987  * locations ?
988  */
990  {
991  entity mal = abstract_locations_max(al1, al2); // maximal abstraction location
992  bool conflict_p = (mal==al1) || (mal==al2);
993 
994  return conflict_p;
995  }
996 
997  /**
998  * @brief Do these two abstract locations MUST share some real memory
999  * locations ? Never ! DO NOT USE THIS FUNCTION UNLESS...
1000  */
1002  entity al2 __attribute__ ((__unused__)))
1003  {
1004 
1005  /* The function is useful in functional drivers to avoid dealing
1006  with specific cases*/
1007 
1008  //pips_internal_error("abstract_locations_must_conflict_p is a non sense : "
1009  // "it's always false ! avoid use it.");
1010 
1011  return false;
1012  }
1013 ␌
1014 /* This function should be located somewhere in effect-util in or near
1015  abstract locations */
1017 {
1018  bool type_sensitive_p = !get_bool_property("ALIASING_ACROSS_TYPES");
1019  entity anywhere = type_sensitive_p?
1021  :
1023 
1024  reference r = make_reference(anywhere,NIL);
1025  return r;
1026 }
1027 
1029 {
1031  cell sc = make_cell_reference(r);
1032  return sc;
1033 }
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
Definition: 3dnow.h:3
cell make_cell_reference(reference _field_)
Definition: effects.c:293
functional make_functional(list a1, type a2)
Definition: ri.c:1109
value make_value_unknown(void)
Definition: ri.c:2847
type make_type_variable(variable _field_)
Definition: ri.c:2715
storage make_storage_rom(void)
Definition: ri.c:2285
value make_value_constant(constant _field_)
Definition: ri.c:2841
type copy_type(type p)
TYPE.
Definition: ri.c:2655
basic make_basic_overloaded(void)
Definition: ri.c:167
type make_type_functional(functional _field_)
Definition: ri.c:2718
type make_type_void(list _field_)
Definition: ri.c:2727
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
constant make_constant_int(intptr_t _field_)
Definition: ri.c:409
type make_type_area(area _field_)
Definition: ri.c:2712
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
area make_area(intptr_t a1, list a2)
Definition: ri.c:98
static int count
Definition: SDG.c:519
bool entity_all_module_static_locations_p(entity e)
test if an entity is the a static area
bool entity_all_xxx_locations_p(entity e, string xxx)
test if an entity is the set of all memory locations in the xxx area of any module.
bool entity_null_locations_p(entity e)
test if an entity is the NULL POINTER
entity entity_null_locations()
return TOP-LEVEL:NULL_POINTER The NULL pointer should be a global variable, unique for all modules FI...
void check_abstract_locations()
For debugging the API.
bool entity_abstract_location_p(entity al)
entity entity_all_module_dynamic_locations(entity m)
return m:*DYNAMIC**ANYWHERE
entity entity_typed_anywhere_locations(type t)
entity entity_all_module_xxx_locations_typed(const char *mn, const char *xxx, type t)
entity entity_all_module_heap_locations(entity m)
return m:*HEAP**ANYWHERE
entity abstract_locations_max(entity al1, entity al2)
eturns the smallest abstract location set greater than or equalt to al1 and al2.
entity entity_all_module_heap_locations_typed(entity m, type t)
bool abstract_locations_must_conflict_p(entity al1 __attribute__((__unused__)), entity al2 __attribute__((__unused__)))
Do these two abstract locations MUST share some real memory locations ? Never ! DO NOT USE THIS FUNCT...
entity variable_to_abstract_location(entity v)
returns the smallest abstract locations containing the location of variable v.
bool entity_all_dynamic_locations_p(entity e)
test if an entity is the set of all dynamic locations
bool stub_entity_of_module_p(entity s, entity m)
entity entity_all_module_locations(entity m)
return m:ANYWHERE Set of all memory locations related to one module.
entity entity_locations_dereference(entity al __attribute__((__unused__)))
in case we need to evaluate sigma(al), i.e.
bool entity_stub_sink_p(entity e)
test if an entity is a stub sink for a formal parameter e.g.
bool cell_typed_anywhere_locations_p(cell c)
test if a cell is the bottom of the lattice
entity entity_all_stack_locations()
return ANY_MODULE:STACK
bool entity_all_locations_p(entity e)
test if an entity is the top of the lattice
entity entity_all_module_static_locations(entity m)
return m:*DYNAMIC**ANYWHERE
bool entity_all_static_locations_p(entity e)
test if an entity is the set of all static locations
bool entity_typed_anywhere_locations_p(entity e)
Test if an entity is the bottom of the lattice.
entity entity_all_module_stack_locations(entity m)
return m:*STACK**ANYWHERE
reference make_anywhere_reference(type t)
This function should be located somewhere in effect-util in or near abstract locations.
bool reference_typed_anywhere_locations_p(reference r)
test if a reference is the bottom of the lattice
entity entity_locations_max(entity al1, entity al2)
Here, entity al1 and entity al2 can be program variables.
entity entity_anywhere_locations()
entity entity_all_dynamic_locations()
return ANY_MODULE:DYNAMIC
entity entity_all_module_xxx_locations(entity m, const char *xxx)
return m:xxx*ANYWHERE* Generic set of functions for all kinds of areas
bool entity_nowhere_locations_p(entity e)
test if an entity is the bottom of the lattice
entity entity_all_xxx_locations(string xxx)
return ANY_MODULE:xxx
bool entity_all_module_locations_p(entity e)
test if an entity is the set of locations defined in a module
entity entity_all_xxx_locations_typed(string xxx, type t)
FI->AM: the predicate entity_all_xxx_locations_typed_p() is missing...
bool entity_anywhere_locations_p(entity e)
test if an entity is the bottom of the lattice
entity entity_all_locations()
eturn ANY_MODULE:ANYWHERE (the top of the lattice)
bool entity_all_module_heap_locations_p(entity e)
test if an entity is the a heap area
entity entity_all_heap_locations()
return ANY_MODULE:HEAP
cell make_anywhere_cell(type t)
entity entity_all_heap_locations_typed(type t)
bool entity_all_module_dynamic_locations_p(entity e)
test if an entity is the a dynamic area
bool abstract_locations_may_conflict_p(entity al1, entity al2)
Do these two abstract locations MAY share some real memory locations ?
entity entity_nowhere_locations()
return ANY_MODULE:NOWHERE
bool entity_all_module_stack_locations_p(entity e)
test if an entity is the a stack area
bool entity_all_stack_locations_p(entity e)
test if an entity is the set of all stack locations
bool entity_all_module_xxx_locations_p(entity e, string xxx)
test if an entity is the set of all memory locations in the xxx area of a module.
bool entity_all_heap_locations_p(entity e)
test if an entity is the set of all heap locations
bool entity_typed_nowhere_locations_p(entity e)
test if an entity is the bottom of the lattice
entity entity_all_static_locations()
return ANY_MODULE:STATIC
entity entity_typed_nowhere_locations(type t)
entity generic_entity_typed_anywhere_locations(type t)
#define NULL_POINTER_NAME
#define NOWHERE_LOCATION
#define ANYWHERE_LOCATION
#define ANY_MODULE_NAME
reference cell_any_reference(cell)
API for reference.
Definition: effects.c:77
const char * local_name(const char *s)
Does not take care of block scopes and returns a pointer.
Definition: entity_names.c:221
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
void free(void *)
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 pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_user_warning
Definition: misc-local.h:146
#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 pips_internal_error
Definition: misc-local.h:149
#define FORMAL_AREA_LOCAL_NAME
Definition: naming-local.h:76
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
#define MODULE_SEP_CHAR
Definition: naming-local.h:28
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define STACK_AREA_LOCAL_NAME
Definition: naming-local.h:72
#define STATIC_AREA_LOCAL_NAME
Definition: naming-local.h:70
#define MODULE_SEP_STRING
Definition: naming-local.h:30
#define HEAP_AREA_LOCAL_NAME
Definition: naming-local.h:71
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define same_string_p(s1, s2)
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define string_undefined
Definition: newgen_types.h:40
#define true
Definition: newgen_types.h:81
char * string
STRING.
Definition: newgen_types.h:39
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
int f2(int off1, int off2, int w, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:1
void print_type(type)
For debugging.
Definition: type.c:111
#define make_entity(n, t, s, i)
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
@ ENTITY_STATIC_AREA
@ ABSTRACT_LOCATION
@ DEFAULT_ENTITY_KIND
@ ENTITY_DYNAMIC_AREA
@ ENTITY_STACK_AREA
@ ENTITY_HEAP_AREA
bool dynamic_area_p(entity aire)
Definition: area.c:68
bool stack_area_p(entity aire)
Definition: area.c:104
bool heap_area_p(entity aire)
Definition: area.c:86
bool formal_area_p(entity aire)
Definition: area.c:95
bool static_area_p(entity aire)
Definition: area.c:77
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
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
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 dummy_parameter_entity_p(entity p)
is p a dummy parameter?
Definition: entity.c:1941
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
void register_static_entity(entity *e)
add given entity to the set of entities that must reset upon workspace deletion practically,...
Definition: entity.c:156
entity CreateEntity(const char *package_name, const char *local_name)
BEGIN_EOLE.
Definition: entity.c:1572
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092
bool variable_return_p(entity)
True if a variable is the pseudo-variable used to store value returned by a function:
Definition: variable.c:1522
type type_to_pointer_type(type)
allocate a new type "pt" which includes directly "t".
Definition: type.c:5253
bool type_equal_p(type, type)
Definition: type.c:547
type entity_basic_concrete_type(entity)
retrieves or computes and then returns the basic concrete type of an entity
Definition: type.c:3677
bool formal_parameter_p(entity)
Definition: variable.c:1489
string type_to_string(const type)
type.c
Definition: type.c:51
#define type_functional_p(x)
Definition: ri.h:2950
#define reference_variable(x)
Definition: ri.h:2326
#define entity_storage(x)
Definition: ri.h:2794
#define storage_ram_p(x)
Definition: ri.h:2519
#define ram_section(x)
Definition: ri.h:2249
#define storage_formal(x)
Definition: ri.h:2524
#define type_undefined_p(x)
Definition: ri.h:2884
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_undefined
Definition: ri.h:2761
#define entity_name(x)
Definition: ri.h:2790
#define formal_function(x)
Definition: ri.h:1406
#define storage_ram(x)
Definition: ri.h:2521
#define type_undefined
Definition: ri.h:2883
#define ram_function(x)
Definition: ri.h:2247
#define entity_kind(x)
Definition: ri.h:2798
#define entity_type(x)
Definition: ri.h:2792
#define storage_undefined_p(x)
Definition: ri.h:2477
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define entity_initial(x)
Definition: ri.h:2796
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
s1
Definition: set.c:247
#define ifdebug(n)
Definition: sg.c:47