PIPS
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "effects.h"
#include "text.h"
#include "text-util.h"
#include "constants.h"
#include "ri-util.h"
#include "workspace-util.h"
#include "misc.h"
#include "database.h"
#include "pipsdbm.h"
#include "resources.h"
#include "phases.h"
#include "pipsmake.h"
#include "callgraph.h"
Go to the source code of this file.
Data Structures | |
struct | gather_call_sites_t |
Functions | |
list | string_to_callees (const string module_name) |
callgraph.c More... | |
list | entity_to_callees (entity mod) |
bool | module_is_called_by_main_program_p (entity mod) |
static void | gather_call_sites (call c, gather_call_sites_t *p) |
static void | gather_call_sites_in_block (statement s, gather_call_sites_t *p) |
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 More... | |
list | callers_to_statements (list callers) |
given a list callers of module name calling module called module return a list of their body More... | |
void | sort_parameters (entity module, gen_cmp_func_t cmp) |
change the parameter order for function module using comparison function cmp both compilation unit and callers are touched SG: it may be put in ri-util, but this would create a dependency from callgraph ... More... | |
static void | callgraph_module_name (entity module, FILE *fp, text(*module_to_text)(const string)) |
bool | module_to_callgraph (entity module, text(*module_to_text)(const string)) |
static void | add_call_to_callees (const call c, callees *current_callees) |
Add a call to a function to a callees list. More... | |
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. More... | |
callees | compute_callees (const statement stat) |
Recompute the callees of a module statement. More... | |
static void | transitive_positions (set vertices, hash_table arcs, hash_table position) |
Global computation of CALLERS, HEIGHT and DEPTH. More... | |
bool | callgraph (const string name) |
callgraph computes the caller list of each module, using the callees list of them. More... | |
Add a call to a function to a callees list.
Definition at line 300 of file callgraph.c.
References call_function, callees_callees, CONS, entity_initial, entity_local_name(), entity_storage, entity_type, entity_undefined_p, FOREACH, pips_assert, pips_debug, same_string_p, storage_rom_p, strdup(), STRING, type_functional_p, value_code_p, and value_unknown_p.
Referenced by compute_callees(), and declaration_statement_add_call_to_callees().
given a list callers_statement
of module statements returns a list of calls to module called_module
callers_statement | allers_statement |
called_module | alled_module |
Definition at line 149 of file callgraph.c.
References call_domain, FOREACH, gather_call_sites(), gather_call_sites_in_block(), gen_context_multi_recurse(), gen_true2(), NIL, gather_call_sites_t::sites, STATEMENT, and statement_domain.
Referenced by do_linearize_array_manage_callers(), normalize_microcode(), and sort_parameters().
given a list callers
of module name calling module called
module return a list of their body
callers | allers |
Definition at line 163 of file callgraph.c.
References caller_name, CONS, db_get_memory_resource(), FOREACH, gen_nreverse(), NIL, STATEMENT, and STRING.
Referenced by delay_communications_interprocedurally(), do_linearize_array_manage_callers(), normalize_microcode(), and sort_parameters().
callgraph computes the caller list of each module, using the callees list of them.
As a side effect, it also computes their heights and depths in the call graph and detects recursive call cycles.
callgraph is not able to generate missing source code.
Note: although callgraph is directly and internally used by pipsmake which needs to know about the callers of a module to chain its rules, it might be better to store it in a future (new) callgraph library (FI)
Argument "name" is not used. It is instantiated as a specific module by make() but this routine process the whole program.
Number of modules called whose source code is missing but synthesized by PIPS
Should we deal with strings or with entities?
Define the module_set and initialize the module callers, except for modules whose source code is missing.
Compute iteratively the callers from the callees. Synthesize missing codes if necessary and if the corresponding property is set.
The number of iterations depends on the order of the modules in the hash-tables.
Simple but inefficient implementation for Cathar-2
Should not be an error as PIPS can synthesize missing code and does it elsewhere...
set_pips_current_computation(DBR_CALLEES, module_called);
push_pips_current_computation(DBR_CALLEES, module_called);
It has no callees to exploit anyway; it does not matter that it is not looped over by the main loop. module_callers is going to be updated and will be used to store the results.
You cannot call pips_user_error() again, as it has just been called by rmake via apply_a_rule()
pop_pips_current_computation(DBR_CALLEES, module_called);
reset_pips_current_computation();
Since Fabien is not available to help with pipsdbm... Let's move on with Cathare-2!
name | ame |
Definition at line 460 of file callgraph.c.
References asprintf, called_modules, callees_callees, callees_undefined, CAR, CONS, db_get_memory_resource(), db_get_module_list(), DB_PUT_MEMORY_RESOURCE, depth, ENDP, fprintf(), gen_array_full_free(), gen_array_item(), gen_array_nitems(), gen_nconc(), hash_get(), HASH_MAP, hash_put(), hash_string, hash_table_free(), hash_table_make(), HASH_UNDEFINED_VALUE, ifdebug, list_undefined, make_callees(), module_name(), NIL, pips_assert, pips_debug, pips_user_warning, POP, print_callees(), reset_current_phase_context(), rmake(), set_add_element(), set_belong_p(), set_current_phase_context(), set_free(), set_make(), set_string, strdup(), STRING, and transitive_positions().
|
static |
Definition at line 242 of file callgraph.c.
References CALLGRAPH_INDENT, concatenate(), db_get_current_workspace_directory(), db_get_memory_resource(), ENTITY, entity_to_callees(), f(), FOREACH, fprintf(), free(), full, make_text(), MERGE_TEXTS, module, module_name(), module_resource_name(), NIL, print_text(), safe_append(), and strdup().
Referenced by module_to_callgraph().
Recompute the callees of a module statement.
stat | is the module statement |
stat | tat |
Definition at line 355 of file callgraph.c.
References add_call_to_callees(), call_domain, declaration_statement_add_call_to_callees(), gen_context_multi_recurse(), gen_null(), gen_true2(), make_callees(), NIL, and statement_domain.
Referenced by delay_communications(), delay_communications_interprocedurally(), delay_load_communications(), delay_store_communications(), do_isolate_statement_preconditions_satisified_p(), do_kernelize(), do_unfolding(), expression_substitution(), freia_compiler(), fsm_generation(), fsm_merge_states(), fsm_split_state(), full_fsm_generation(), full_spaghettify(), generate_starpu_pragma(), gpu_ify(), gpu_memory(), if_conversion(), inline_calls(), isolate_statement(), kernel_load_store_engine(), kernelize(), old__gpu_ify(), outline(), outliner_independent_recursively(), phrase_comEngine_distributor(), phrase_distributor(), phrase_distributor_control_code(), phrase_distributor_init(), pragma_outliner(), prepend_call(), process_reduced_loops(), redundant_load_store_elimination(), rename_operator(), safescale_distributor(), safescale_distributor_init(), scalopify(), scalopragma(), sesamify(), simd_remove_reductions(), simdizer(), spaghettify(), taskify(), and wrap_kernel_argument().
|
static |
Add calls hidden in variable declarations to the current callees list.
Definition at line 324 of file callgraph.c.
References add_call_to_callees(), call_domain, declaration_statement_p(), ENTITY, entity_initial, entity_type, FOREACH, gen_context_recurse, gen_true2(), statement_declarations, type_variable_p, and value_expression_p.
Referenced by compute_callees().
mod | od |
Definition at line 89 of file callgraph.c.
References CONS, ENTITY, entity_name, FOREACH, module_name(), module_name_to_entity(), NIL, STRING, and string_to_callees().
Referenced by callgraph_module_name().
|
static |
Definition at line 128 of file callgraph.c.
References CALL, call_function, CONS, gather_call_sites_t::m, same_entity_p(), and gather_call_sites_t::sites.
Referenced by callers_to_call_sites(), and gather_call_sites_in_block().
|
static |
Definition at line 134 of file callgraph.c.
References call_domain, declaration_statement_p(), ENTITY, entity_initial, FOREACH, gather_call_sites(), gen_context_recurse, gen_true2(), and statement_declarations.
Referenced by callers_to_call_sites().
mod | od |
Definition at line 103 of file callgraph.c.
References callees_callees, caller_name, CAR, CDR, current_caller, db_get_memory_resource(), ENDP, entity_main_module_p(), module_local_name(), module_name_to_entity(), and STRING.
Referenced by alias_propagation(), and alias_propagation_callers().
module | odule |
Definition at line 270 of file callgraph.c.
References callgraph_module_name(), concatenate(), db_build_file_resource_name(), db_get_current_workspace_directory(), DB_PUT_FILE_RESOURCE, free(), full, module, module_resource_name(), safe_fclose(), safe_fopen(), and strdup().
Referenced by print_decorated_call_graph().
void sort_parameters | ( | entity | module, |
gen_cmp_func_t | cmp | ||
) |
change the parameter order for function module
using comparison function cmp
both compilation unit and callers are touched SG: it may be put in ri-util, but this would create a dependency from callgraph ...
retrieve the formal parameters
order them
update offset
update parameter list
change call sites
for each call site , reorder arguments according to table reordering
tell dbm of the update
yes! some people use free in pips !
module | odule |
cmp | mp |
Definition at line 180 of file callgraph.c.
References CALL, call_arguments, callees_callees, callers_to_call_sites(), callers_to_statements(), CAR, compilation_unit_of_module(), CONS, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, db_touch_resource(), ENDP, ENTITY, entity_storage, EXPRESSION, f(), FOREACH, formal_offset, gen_free_list(), gen_length(), gen_nreverse(), gen_nth(), gen_sort_list(), get_current_module_name(), intptr_t, module, module_formal_parameters(), module_functional_parameters, NIL, offset, PARAMETER, POP, STATEMENT, storage_formal, and STRING.
Referenced by normalize_microcode_parameter_orders().
CALLGRAPH_INCLUDED.
Entry point:
Pierre Berthomier, May 1990 Lei Zhou, January 1991 Guillaume Oget, June 1995 To have asprintf(): DB_PUT_FILE_RESOURCE is defined there get all the callees of the module module_name,return the no-empty list of string. if the module has callee(s),the first element of the return list is the mudule's last callee.
module_name | odule_name |
Definition at line 69 of file callgraph.c.
References BLOCKDATA_PREFIX, callees_callees, callees_undefined, COMMON_PREFIX, db_get_memory_resource(), local_name(), MAIN_PREFIX, module_name(), and static_module_name_p().
Referenced by entity_to_callees().
|
static |
Global computation of CALLERS, HEIGHT and DEPTH.
Number of modules processed at the previous iteration
current module position
gdb does not access v1
already processed
do not know when to perform a put or an update...
Check that all vertices are associated to a position... which only is true if no recursive cycle exists.
Definition at line 370 of file callgraph.c.
References callees_callees, ENDP, FOREACH, hash_get(), hash_put(), HASH_UNDEFINED_VALUE, ifdebug, list_undefined, pips_assert, pips_debug, pips_internal_error, pips_user_warning, SET_FOREACH, and STRING.
Referenced by callgraph().