25 #include "pips_config.h"
50 #include "constants.h"
56 #include "resources.h"
111 while (!
ENDP(l_callers))
116 l_callers =
CDR(l_callers);
223 for(
list citer=callers, siter=callers_statement;
245 text (*module_to_text)(
const string))
272 text (*module_to_text)(
const string))
274 string dir, local,
full;
362 return current_callees;
385 string source_module = (
string) v1;
399 else if(
ENDP(destinations)) {
400 hash_put(position, v1, (
void *) cmp);
410 cmp = p+1>cmp? p+1 : cmp;
413 hash_put(position, v1, (
void *) cmp);
419 pips_debug(1,
"Iteration %td completed with %td vertices processed\n"
420 "(total number of vertices processed: %td)\n",
442 " probably because of a recursive call cycle.\n", n);
465 int n_new_modules = 0;
475 pips_assert(
"The workspace contains at least one module", nmodules>0);
479 for(i=0; i<nmodules; i++) {
497 for(i=0; i<nmodules; i++) {
517 pips_user_warning(
"no source file for module %s, let's try so synthesize code\n",
523 if(
rmake(DBR_CALLEES, module_called)) {
534 hash_put(module_callers, (
void *) module_called, (
void *) c);
537 hash_put(module_callees, (
void *) module_called, (
void *) c);
538 rmake(DBR_CALLERS, module_called);
564 pips_debug(1,
"Compute heights from callee arcs");
566 pips_debug(1,
"Compute depths from caller arcs");
572 pips_debug(7,
"adding %p as %s for module %s\n",
614 pips_assert(
"The number of modules is unchanged", i==nmodules+n_new_modules);
callees make_callees(list a)
bool db_touch_resource(const char *rname, const char *oname)
touch logical time for resource[owner], possibly behind the back of pipsdbm.
static entity current_caller
static const char * caller_name
size_t gen_array_nitems(const gen_array_t a)
void gen_array_full_free(gen_array_t a)
void * gen_array_item(const gen_array_t a, size_t i)
list callers_to_call_sites(list callers_statement, entity called_module)
given a list callers_statement of module statements returns a list of calls to module called_module
bool callgraph(const string name)
callgraph computes the caller list of each module, using the callees list of them.
static void callgraph_module_name(entity module, FILE *fp, text(*module_to_text)(const string))
void sort_parameters(entity module, gen_cmp_func_t cmp)
change the parameter order for function module using comparison function cmp both compilation unit an...
static bool declaration_statement_add_call_to_callees(const statement s, callees *current_callees)
Add calls hidden in variable declarations to the current callees list.
static void gather_call_sites_in_block(statement s, gather_call_sites_t *p)
list callers_to_statements(list callers)
given a list callers of module name calling module called module return a list of their body
list entity_to_callees(entity mod)
static void transitive_positions(set vertices, hash_table arcs, hash_table position)
Global computation of CALLERS, HEIGHT and DEPTH.
static void add_call_to_callees(const call c, callees *current_callees)
Add a call to a function to a callees list.
static void gather_call_sites(call c, gather_call_sites_t *p)
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
list string_to_callees(const string module_name)
callgraph.c
bool module_to_callgraph(entity module, text(*module_to_text)(const string))
bool module_is_called_by_main_program_p(entity mod)
void print_callees(callees)
print.c
struct _newgen_struct_statement_ * statement
string compilation_unit_of_module(const char *)
The output is undefined if the module is referenced but not defined in the workspace,...
bool static_module_name_p(const char *name)
Check if the given name is a static module name.
const char * local_name(const char *s)
Does not take care of block scopes and returns a pointer.
const char * module_name(const char *s)
Return the module part of an entity name.
FILE * safe_fopen(const char *filename, const char *what)
int safe_fclose(FILE *stream, const char *filename)
void safe_append(FILE *out, char *file, int margin, bool but_comments)
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
const char * get_current_module_name(void)
Get the name of the current module.
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
#define ENDP(l)
Test if a list is empty.
list gen_nreverse(list cp)
reverse a list in place
#define POP(l)
Modify a list pointer to point on the next element of the list.
#define NIL
The empty list (nil in Lisp)
size_t gen_length(const list l)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
#define CAR(pcons)
Get the value of the first element of a list.
void gen_free_list(list l)
free the spine of the list
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
#define CDR(pcons)
Get the list less its first element.
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
#define list_undefined
Undefined list definition :-)
void gen_sort_list(list l, gen_cmp_func_t compare)
Sorts a list of gen_chunks in place, to avoid allocations...
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
gen_array_t db_get_module_list(void)
Get an array of all the modules (functions, procedures and compilation units) of a workspace.
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
hash_table hash_table_make(hash_key_type key_type, size_t size)
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
string db_build_file_resource_name(const char *rname, const char *oname, const char *suffix)
returns an allocated file name for a file resource.
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
string concatenate(const char *,...)
Return the concatenation of the given strings.
#define HASH_MAP(k, v, code, ht)
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
#define same_string_p(s1, s2)
#define SET_FOREACH(type_name, the_item, the_set)
enumerate set elements in their internal order.
bool set_belong_p(const set, const void *)
set set_make(set_type)
Create an empty set of any type but hash_private.
set set_add_element(set, const set, const void *)
int(* gen_cmp_func_t)(const void *, const void *)
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
string db_get_current_workspace_directory(void)
void set_current_phase_context(const char *rname, const char *oname)
cproto-generated files
void reset_current_phase_context(void)
bool rmake(const char *rname, const char *oname)
recursive make resource.
static list called_modules
list of called subroutines or functions
#define module_functional_parameters(func)
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...
bool same_entity_p(entity e1, entity e2)
predicates on entities
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
bool entity_main_module_p(entity e)
const char * module_local_name(entity e)
Returns the module local user name.
const char * module_resource_name(entity e)
Returns a pointer towards the resource name.
list module_formal_parameters(entity func)
list module_formal_parameters(entity func) input : an entity representing a function.
#define type_functional_p(x)
struct _newgen_struct_callees_ * callees
#define callees_undefined
#define callees_callees(x)
#define value_unknown_p(x)
#define entity_storage(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define call_domain
newgen_callees_domain_defined
#define storage_formal(x)
#define EXPRESSION(x)
EXPRESSION.
#define entity_undefined_p(x)
#define PARAMETER(x)
PARAMETER.
#define statement_declarations(x)
#define call_arguments(x)
#define value_expression_p(x)
#define type_variable_p(x)
#define STATEMENT(x)
STATEMENT.
#define entity_initial(x)
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
FI: I do not understand why the type is duplicated at the set level.
The structure used to build lists in NewGen.
#define MERGE_TEXTS(r, t)
void print_text(FILE *fd, text t)
static int depth
la sequence de nids