PIPS
filter_proper_effects.c File Reference
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "misc.h"
#include "ri-util.h"
#include "effects-util.h"
#include "database.h"
#include "resources.h"
#include "pipsdbm.h"
#include "properties.h"
#include "effects-generic.h"
#include "effects-simple.h"
+ Include dependency graph for filter_proper_effects.c:

Go to the source code of this file.

Functions

static list get_variables_to_filter ()
 of entity More...
 
static bool there_is_a_conflict (entity var)
 
static void reference_rwt (reference r)
 it should be a check on call arguments, whether they are W + ref for user define functions, use summary effects for intrinsics? =, implied-do, read... More...
 
static void check_if_direct_reference (void *x)
 
static bool direct_written_reference (statement s, entity var)
 
static bool stmt_flt (statement s)
 
bool filter_proper_effects (const char *module_name)
 filter_proper_effects.c More...
 

Variables

static list variables_to_filter = NIL
 of entity More...
 
static bool direct_reference_found = false
 
static entity a_variable = NULL
 

Function Documentation

◆ check_if_direct_reference()

static void check_if_direct_reference ( void *  x)
static

Definition at line 126 of file filter_proper_effects.c.

127 {
129 }
static void reference_rwt(reference r)
it should be a check on call arguments, whether they are W + ref for user define functions,...
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
static char * x
Definition: split_file.c:159

References gen_recurse, gen_true(), reference_domain, reference_rwt(), and x.

Referenced by direct_written_reference().

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

◆ direct_written_reference()

static bool direct_written_reference ( statement  s,
entity  var 
)
static

should not happen on a statement with proper effects

Definition at line 131 of file filter_proper_effects.c.

132 {
134  direct_reference_found = false;
135  a_variable = var;
136 
137  switch (instruction_tag(i))
138  {
139  case is_instruction_call:
141  break;
142  case is_instruction_loop:
143  {
144  loop l = instruction_loop(i);
147  direct_reference_found = true;
148  break;
149  }
152  break;
153  case is_instruction_test:
155  break;
156  default:
157  /* should not happen on a statement with proper effects */
158  pips_internal_error("unexpected instruction tag...");
159  }
160 
161  a_variable = NULL;
162  return direct_reference_found;
163 }
static bool direct_reference_found
static void check_if_direct_reference(void *x)
static entity a_variable
bool entities_may_conflict_p(entity e1, entity e2)
Check if two entities may conflict.
Definition: conflicts.c:984
#define pips_internal_error
Definition: misc-local.h:149
#define instruction_loop(x)
Definition: ri.h:1520
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_condition(x)
Definition: ri.h:2833
#define instruction_whileloop(x)
Definition: ri.h:1523
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define instruction_test(x)
Definition: ri.h:1517
#define whileloop_condition(x)
Definition: ri.h:3160
#define loop_index(x)
Definition: ri.h:1640

References a_variable, check_if_direct_reference(), direct_reference_found, entities_may_conflict_p(), instruction_loop, instruction_tag, instruction_test, instruction_whileloop, is_instruction_call, is_instruction_loop, is_instruction_test, is_instruction_whileloop, loop_index, loop_range, pips_internal_error, statement_instruction, test_condition, and whileloop_condition.

Referenced by stmt_flt().

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

◆ filter_proper_effects()

bool filter_proper_effects ( const char *  module_name)

filter_proper_effects.c

gets what is needed from PIPS DBM

returns the result to the DBM...

Parameters
module_nameodule_name

Definition at line 201 of file filter_proper_effects.c.

202 {
203  debug_on("FILTER_PROPER_EFFECTS_DEBUG_LEVEL");
204  pips_debug(1, "considering module %s\n", module_name);
205 
206  /* gets what is needed from PIPS DBM
207  */
210  db_get_memory_resource(DBR_CODE, module_name, true));
212  db_get_memory_resource(DBR_PROPER_EFFECTS, module_name, true));
213 
215 
219 
222 
223  /* returns the result to the DBM... */
225  (DBR_FILTERED_PROPER_EFFECTS, module_name, NULL);
226 
230 
231  debug_off();
232  return true;
233 }
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
static list variables_to_filter
of entity
static list get_variables_to_filter()
of entity
static bool stmt_flt(statement s)
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
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
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
#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 pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
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
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_free_list(), gen_null(), gen_recurse, get_current_module_statement(), get_variables_to_filter(), local_name_to_top_level_entity(), module_name(), NIL, pips_debug, reset_current_module_entity(), reset_current_module_statement(), reset_proper_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_proper_rw_effects(), statement_domain, stmt_flt(), and variables_to_filter.

+ Here is the call graph for this function:

◆ get_variables_to_filter()

static list get_variables_to_filter ( )
static

of entity

Definition at line 46 of file filter_proper_effects.c.

47 {
48  string names = strdup(get_string_property("EFFECTS_FILTER_ON_VARIABLE"));
49  list le = NIL;
50  entity var;
51  string saved = names, s;
52 
53  pips_assert("property EFFECTS_FILTER_ON_VARIABLE is defined",
54  !same_string_p(names, ""));
55 
56  for (s=names; *s; s++)
57  {
58  var = NULL;
59  if (*s==',')
60  {
61  *s = '\0';
62  var = gen_find_tabulated(names, entity_domain);
63 
64  if (!var || entity_undefined_p(var))
65  {
66  pips_user_warning("reference variable '%s' not found\n", names);
67  }
68  else
69  {
70  le = CONS(ENTITY, var, le);
71  }
72  *s = ',';
73  names = s+1;
74  }
75  }
76 
77  var = gen_find_tabulated(names, entity_domain);
78 
79  if (!var || entity_undefined_p(var))
80  {
81  pips_user_warning("reference variable '%s' not found\n", names);
82  }
83  else
84  {
85  le = CONS(ENTITY, var, le);
86  }
87 
88  free(saved), saved = NULL;
89 
90  return le;
91 }
char * get_string_property(const char *)
void free(void *)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define pips_user_warning
Definition: misc-local.h:146
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define same_string_p(s1, s2)
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
char * strdup()
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, ENTITY, entity_domain, entity_undefined_p, free(), gen_find_tabulated(), get_string_property(), NIL, pips_assert, pips_user_warning, same_string_p, and strdup().

Referenced by filter_proper_effects().

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

◆ reference_rwt()

static void reference_rwt ( reference  r)
static

it should be a check on call arguments, whether they are W + ref for user define functions, use summary effects for intrinsics? =, implied-do, read...

Definition at line 117 of file filter_proper_effects.c.

118 {
120  {
121  direct_reference_found = true;
122  gen_recurse_stop(NULL);
123  }
124 }
void gen_recurse_stop(void *obj)
Tells the recursion not to go in this object.
Definition: genClib.c:3251
#define reference_variable(x)
Definition: ri.h:2326

References a_variable, direct_reference_found, entities_may_conflict_p(), gen_recurse_stop(), and reference_variable.

Referenced by check_if_direct_reference().

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

◆ stmt_flt()

static bool stmt_flt ( statement  s)
static

of effect

Definition at line 167 of file filter_proper_effects.c.

168 {
169  list /* of effect */ lpe = load_proper_rw_effects_list(s);
170  MAP(EFFECT, e,
171  {
172  entity var = effect_variable(e);
173  if (effect_write_p(e) && there_is_a_conflict(var))
174  {
175  if (direct_written_reference(s, var))
176  {
177  int order = statement_ordering(s);
178  int on; int os;
179  if (order!=STATEMENT_ORDERING_UNDEFINED)
180  {
181  on = ORDERING_NUMBER(order);
182  os = ORDERING_STATEMENT(order);
183  }
184  else
185  {
186  on = -1;
187  os = -1;
188  }
189 
190  user_log("## %s o=(%d,%d)/n=%d\n",
191  entity_name(var), on, os, statement_number(s));
192  }
193  }
194  },
195  lpe);
196  return true;
197 }
void user_log(const char *format,...)
Definition: message.c:234
list load_proper_rw_effects_list(statement)
#define effect_write_p(eff)
#define effect_variable(e)
For COMPATIBILITY purpose only - DO NOT USE anymore.
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
static bool there_is_a_conflict(entity var)
static bool direct_written_reference(statement s, entity var)
#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 STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
Definition: newgen-local.h:35
#define ORDERING_NUMBER(o)
#define ORDERING_STATEMENT(o)
#define statement_ordering(x)
Definition: ri.h:2454
#define entity_name(x)
Definition: ri.h:2790
#define statement_number(x)
Definition: ri.h:2452

References direct_written_reference(), EFFECT, effect_variable, effect_write_p, entity_name, load_proper_rw_effects_list(), MAP, ORDERING_NUMBER, ORDERING_STATEMENT, statement_number, statement_ordering, STATEMENT_ORDERING_UNDEFINED, there_is_a_conflict(), and user_log().

Referenced by filter_proper_effects().

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

◆ there_is_a_conflict()

static bool there_is_a_conflict ( entity  var)
static

Definition at line 97 of file filter_proper_effects.c.

98 {
99  MAP(ENTITY, v,
100  {
101  if (entities_may_conflict_p(var, v))
102  return true;
103  },
105  return false;
106 }

References entities_may_conflict_p(), ENTITY, MAP, and variables_to_filter.

Referenced by stmt_flt().

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

Variable Documentation

◆ a_variable

◆ direct_reference_found

bool direct_reference_found = false
static

Definition at line 110 of file filter_proper_effects.c.

Referenced by direct_written_reference(), and reference_rwt().

◆ variables_to_filter

list variables_to_filter = NIL
static

of entity

Definition at line 95 of file filter_proper_effects.c.

Referenced by filter_proper_effects(), and there_is_a_conflict().