25 #include "pips_config.h"
66 #include <sys/types.h>
72 #include "constants.h"
79 #include "resources.h"
82 #include "pips-libs.h"
87 #include "builder_map.h"
107 const char* rname,
const char* oname)
115 static bool warned_about_gmp_inconsistent_requirement =
false;
116 if (!warned_about_gmp_inconsistent_requirement &&
120 warned_about_gmp_inconsistent_requirement =
true;
150 unsigned int oe, se, me;
165 struct builder_map * pbm;
166 for (pbm = builder_maps; pbm->builder_name; pbm++)
168 return pbm->builder_func;
193 pips_debug(8,
"The up-to-date resource cache is reset\n");
201 pips_debug(8,
"The up-to-date resource cache is initialized to empty\n");
243 pips_debug(5,
"resource %s(%s) deleted from up_to_date make cache\n",
259 printf(
"Up-to-date resources/make cache inconsistent with "
260 "pipsdbm resources\n");
262 printf(
"Up-to-date resource: \"%s.%s\"\n", res_on, res_rn);
266 printf(
"No up-to-date resource is cached in make cache\n");
269 printf(
"The up-to-date resource make cache is currently undefined\n");
300 #define DECLARE_ERROR_HANDLER(name) extern void name(); name()
307 #ifdef HAVE_PIPS_effects_generic_LIBRARY
316 #ifdef HAVE_PIPS_transformer_LIBRARY
320 #ifdef HAVE_PIPS_semantics_LIBRARY
325 #undef DECLARE_ERROR_HANDLER
337 #define add_res(vrn, on) \
338 result = CONS(REAL_RESOURCE, \
339 make_real_resource(strdup(vrn), strdup(on)), result);
359 for (pvr = lvr; pvr !=
NIL; pvr =
CDR(pvr))
379 int number_of_main = 0;
403 if (!
rmake(DBR_CALLEES, oname)) {
406 "Some source code probably is missing!\n",
431 if (!
rmake(DBR_CALLERS, oname)) {
433 "Any missing source code?\n",
486 "Compilation units cannot be synthesized.\n",
580 static int number_of_applications_of_a_rule = 0;
581 static bool checkpoint_workspace_being_done =
false;
585 bool first_time =
true, success_p =
true,
595 number_of_applications_of_a_rule++;
597 if (!checkpoint_workspace_being_done &&
598 frequency>0 && number_of_applications_of_a_rule>=frequency)
606 checkpoint_workspace_being_done =
true;
608 checkpoint_workspace_being_done =
false;
609 number_of_applications_of_a_rule = 0;
618 bool is_required =
false;
635 first_time ==
true ? (first_time =
false,run) :
"",
636 is_required ==
true ?
"updating" :
"building",
648 if (print_memory_usage_p)
657 string time_with_io,io_time;
667 if (print_memory_usage_p) {
669 user_log(
"\t\t\t\t memory size %10.3f, increase %10.3f\n",
698 pips_debug(5,
"searching rule for resource %s\n", rname);
703 bool resource_required_p =
false;
717 resource_required_p =
true;
721 if (!resource_required_p)
784 pips_debug(2,
"apply %s on %s\n", pname, oname);
816 bool success_p =
true;
828 pips_debug(3,
"rule %s : selecting phase %s\n",
852 pips_debug(3,
"rule %s : applying %s to %s - recursive call\n",
873 bool success_p =
true;
884 bool success_p =
true;
893 static bool make(
const char* rname,
const char* oname)
895 bool success_p =
true;
897 debug(1,
"make",
"%s(%s) - requested\n", rname, oname);
906 success_p =
rmake(rname, oname);
913 rname, oname, success_p?
"":
"could not be ");
919 bool rmake(
const char* rname,
const char* oname)
922 char * res_id = NULL;
924 pips_debug(2,
"%s(%s) - requested\n", rname, oname);
932 pips_debug(5,
"resource %s(%s) found up_to_date, time stamp %d\n",
962 "Do not expect interesting results.\n");
981 "Resource %s(%s) becomes up-to-date after applying\n"
982 " pre-transformations and building required resources\n",
1006 pips_debug(5,
"resource %s(%s) added to up_to_date "
1007 "with time stamp %d\n",
1028 static bool apply(
const char* pname,
const char* oname)
1030 bool success_p =
true;
1032 pips_debug(1,
"%s.%s - requested\n", oname, pname);
1043 pips_debug(1,
"%s.%s - done\n", oname, pname);
1119 bool success_p =
true;
1129 pips_debug(3,
"rule %s : %s(%s) - recursive call\n",
1132 if (!
rmake(rrrn, rron)) {
1172 " and must be recomputed\n",
1174 if (!
rmake(rrrn, rron)) {
1181 if (!
rmake(rrrn, rron)) {
1203 " %d instead of %d...\n", nc, c);
1216 pips_debug(3,
"rule %s : %s(%s) - recursive call (retry)\n",
1219 if (!
rmake(rrrn, rron)) {
1243 " up-to-date after one recomputation.\n"
1244 "The rules involved and their pre- and "
1245 "post-actions must be checked",
1258 const char* rname,
const char* oname)
1260 list real_required_resources =
NIL;
1261 list real_modified_resources =
NIL;
1300 bool res_in_modified_list_p =
false;
1311 res_in_modified_list_p =
true;
1312 pips_debug(3,
"resource %s(%s) is in the rule_modified list",
1320 if (res_in_modified_list_p ==
false) {
1322 pips_debug(5,
"resource %s(%s) is not there "
1323 "and not in the rule_modified list", rrrn, rron);
1331 pips_debug(5,
"resource %s(%s) is not up to date", rrrn, rron);
1340 pips_debug(5,
"resource %s(%s) with time stamp %ld is newer "
1341 "than resource %s(%s) with time stamp %ld\n",
1342 rrrn, rron, respt, rname, oname, rest);
1359 list real_produced_resources =
1361 bool res_found_p =
false;
1363 pips_debug(5,
"resource %s(%s) added to up_to_date with time stamp %d\n",
1373 if (sres_id != res_id) {
1378 pips_debug(5,
"sibling resource %s(%s) added to up_to_date "
1379 "with time stamp %d\n",
1393 pips_debug(5,
"sibling resource %s(%s) added to up_to_date "
1394 "with time stamp %d\n",
1405 pips_assert(
"resource res is among the real resources produced by rule ru",
1451 user_log(
"Deletion of %s resources:\n", what);
1456 if (ndeleted>0)
user_log(
"%d destroyed.\n", ndeleted);
1457 else user_log(
"none destroyed.\n");
1484 pips_assert(
"make cache is consistent before deletion",
1500 pips_debug(8,
"Number of resources no longer considered up-to-date: %d\n",
1506 pips_assert(
"The number of resources removed from the cache is smaller "
1507 "than the number of resources removed from te database\n",
1509 pips_assert(
"make cache is consistent before deletion",
1538 FILE * tmp_file =
safe_fopen(main_name,
"r");
1579 pips_debug (5,
"resource %s.%s has been read: ok\n", rron, rrrn);
1583 user_log(
"resource %s.%s has not been read\n", rron, rrrn);
1601 pips_debug (5,
"resource %s.%s has been written: ok\n", rron, rrrn);
1605 user_log (
"resource %s.%s has not been written\n", rron, rrrn);
1650 user_log(
"\t\t\t\t memory size %10.3f, increase %10.3f\n",
1658 const char* module_n,
1659 const char* what_it_is,
1660 rule (*find_rule)(
const char*),
1661 bool (*doit)(
const char*,
const char*))
1685 "build %s %s for module %s.\n",
1686 what_it_is, name, module_n);
1692 user_log(
"Request: build %s %s for module %s.\n",
1693 what_it_is, name, module_n);
1698 success = doit(name, module_n);
1702 user_log(
"%s made for %s.\n", name, module_n);
1708 "build %s %s for module %s.\n",
1709 what_it_is, name, module_n);
1730 const char* phase_n,
1759 user_log(
"Request: capply %s for module [%s].\n", phase_n, module_list);
1764 user_log(
"capply %s made for [%s].\n", phase_n, module_list);
1769 "capply %s for module [%s].\n",
1770 phase_n, module_list);
1783 size_t len = strlen(propname) + strlen(
value) + 2;
1784 char*
line = calloc(len,
sizeof(
char));
1785 strcat(
line, propname);
int get_int_property(const string)
void user_log(const char *format,...)
void set_pips_current_computation(const char *rname, const char *oname)
message.c
void reset_pips_current_computation(void)
string db_resource_name(void *dbr)
To be used for debugging.
bool db_resource_is_required_p(const char *rname, const char *oname)
true if exists and in required state.
void db_print_all_required_resources(FILE *file)
void db_clean_all_required_resources(void)
list db_retrieve_resources(const char *rname)
Retrieve all the db resources of a given resource type, "rname".
int db_time_of_resource(const char *rname, const char *oname)
bool db_resource_p(const char *rname, const char *oname)
true if exists and in loaded or stored state.
void db_set_resource_as_required(const char *rname, const char *oname)
bool db_touch_resource(const char *rname, const char *oname)
touch logical time for resource[owner], possibly behind the back of pipsdbm.
int db_delete_obsolete_resources(bool(*keep_p)(const char *, const char *))
delete all obsolete resources before a close.
void db_delete_all_resources(void)
FC: I added this function to clean all resources, hence avoiding to save them.
int db_unput_resources(const char *rname)
Delete all the resources of a given type "rname".
string db_get_resource_id(const char *rname, const char *oname)
some way to identify a resource...
string db_resource_owner_name(void *dbr)
To be used for debugging.
bool active_phase_p(const char *phase)
const char * activate(const char *phase)
void save_active_phases(void)
activate.c
void retrieve_active_phases(void)
@ any_exception_error
catch all
void const char const char const int
linear_exception_t the_last_just_thrown_exception
void linear_reset_error_counters(void)
reset linear counters
void linear_get_error_counts(unsigned int *, unsigned int *, unsigned int *)
return various errors counts through unsigned int pointer overflow, simplex & misc (aka others) NULL ...
bool linear_require_gmp(void)
whether linear is asked to use gmp if possible (env variable)
unsigned int linear_error_count(void)
return number of linear errors may be used as a test after a reset to know whether new errors occured...
bool linear_with_gmp(void)
whether linear can use gmp (i.e.
void gen_array_full_free(gen_array_t a)
string string_array_join(gen_array_t array, string separator)
Join a string array with a string separator.
gen_array_t gen_array_from_list(list ls)
string compilation_unit_name
cproto-generated files
bool run_pipsmake_callback()
string compilation_unit_of_module(const char *)
The output is undefined if the module is referenced but not defined in the workspace,...
void error_reset_cumulated_rw_effects(void)
void proper_effects_error_handler(void)
void error_reset_invariant_rw_effects(void)
void error_reset_proper_rw_effects(void)
void error_reset_rw_effects(void)
bool compilation_unit_p(const char *module_name)
The names of PIPS entities carry information about their nature.
FILE * safe_fopen(const char *filename, const char *what)
bool file_exists_p(const char *name)
char * get_string_property(const char *)
int safe_fclose(FILE *stream, const char *filename)
char * safe_readline(FILE *file)
returns the allocated line read, whatever its length.
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
void gen_full_free_list(list l)
#define ENDP(l)
Test if a list is empty.
list gen_nreverse(list cp)
reverse a list in place
#define NIL
The empty list (nil in Lisp)
size_t gen_length(const list l)
void gen_free_string_list(list ls)
#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.
list gen_copy_string_list(list ls)
of string
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 rule_post_transformation(x)
#define REAL_RESOURCE(x)
REAL_RESOURCE.
#define virtual_resource_owner(x)
#define rule_pre_transformation(x)
#define real_resource_owner_name(x)
#define owner_callers_p(x)
#define rule_preserved(x)
#define virtual_resource_name(x)
#define makefile_active_phases(x)
@ is_owner_compilation_unit
#define real_resource_resource_name(x)
#define owner_callees_p(x)
#define VIRTUAL_RESOURCE(x)
VIRTUAL_RESOURCE.
#define owner_select_p(x)
#define makefile_rules(x)
void pips_malloc_debug()
include <sys/stdtypes.h>
#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
void set_debug_stack_pointer(const int i)
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
double get_process_gross_heap_size(void)
_int get_debug_stack_pointer(void)
The pair get_ and set_debug_stack_pointer() should never be used except to clean up the stack after a...
void reset_hooks_is_empty(void)
check that the stack was cleaned.
void reset_hooks_call(void)
this function is expected to be called when catching an exception.
#define GEN_ARRAY_FOREACH(type, s, array)
string concatenate(const char *,...)
Return the concatenation of the given strings.
#define same_string_p(s1, s2)
set set_del_element(set, const set, const void *)
#define SET_MAP(element, code, the_set)
#define SET_FOREACH(type_name, the_item, the_set)
enumerate set elements in their internal order.
set set_clear(set)
Assign the empty set to s s := {}.
bool set_belong_p(const set, const void *)
#define set_undefined_p(s)
set set_make(set_type)
Create an empty set of any type but hash_private.
set set_add_element(set, const set, const void *)
#define string_undefined_p(s)
void checkpoint_workspace(void)
checkpoint the current workspace, i.e.
#define db_unput_a_resource(r, o)
#define MAIN_FILE_NAMES
Name of the file containing the names of the main procedures.
void get_request_string_timers(string *global, string *phases, string *dbm)
compute times elapsed since init_request_log_timers(), i.e.
static set res_read
Sets of the readwrite resources by pipsdbm.
void init_request_timers()
Functions for timing one request.
static struct tms dbm_time
static struct tms request_time
Timing of one request.
void get_string_timers(string *with_io, string *io)
compute times elapsed since init_log_timers(), i.e.
void get_logged_resources(set *sr, set *sw)
Get the made sets.
void init_log_timers()
Functions for timing one phase.
bool interrupt_pipsmake_asap_p()
void init_resource_usage_check()
init variables
void dont_interrupt_pipsmake_asap()
static struct tms phase_time
Timing of one phase.
int db_inc_logical_time(void)
0 means not set...
string db_get_current_workspace_directory(void)
rule find_rule_by_phase(const char *)
this function returns the rule that defines builder pname
makefile parse_makefile(void)
static bool apply_a_rule(const char *oname, rule ru)
void delete_some_resources(void)
this is quite ugly, but I wanted to put the enumeration down to pipsdbm.
gen_array_t get_callers(string module)
Get all the callers of the specified module.
rule find_rule_by_resource(const char *rname)
This function returns the active rule to produce resource rname.
void add_resource_to_make_cache(void *res_id)
void reset_static_phase_variables()
Static variables used by phases must be reset on error although pipsmake does not know which ones are...
bool make_cache_p()
Can the make cache be used?
bool check_resource_up_to_date(const char *rname, const char *oname)
To be used in a rule.
static bool make_required(const char *, rule)
compute all real resources needed to apply a rule "ru" on an object related to owner "oname".
static bool check_physical_resource_up_to_date(const char *rname, const char *oname)
returns whether resource is up to date.
static bool apply_without_reseting_up_to_date_resources(const char *pname, const char *oname)
Apply do NOT activate the rule applied.
gen_array_t get_callees(string module)
Get all the callers of the specified module.
static void logs_on(void)
int delete_obsolete_resources(void)
bool make_cache_consistent_p()
Debug function: make sure that up-to-date resources do exist in the resource database.
void remove_resource_from_make_cache(void *res_id)
string get_first_main_module(void)
Should be able to handle Fortran applications, C applications and mixed Fortran/C applications.
static void logs_off(void)
static rule safe_find_rule_by_resource(const char *rname)
Always returns a defined rule.
void set_current_phase_context(const char *rname, const char *oname)
cproto-generated files
static bool safe_do_something(const char *name, const char *module_n, const char *what_it_is, rule(*find_rule)(const char *), bool(*doit)(const char *, const char *))
void print_make_cache()
Debug function, to be tested...
static bool concurrent_apply(const char *pname, gen_array_t modules)
void init_make_cache(void)
bool safe_make(const char *res_n, const char *module_n)
static builder_func_t get_builder(const char *name)
static bool make_pre_post_transformation(const char *oname, rule ru, list transformations)
compute all pre or post-transformations to apply a rule on an object or activate a phase if owner is ...
#define DECLARE_ERROR_HANDLER(name)
static bool make_pre_transformation(const char *, rule)
FI: guard added to simplify debugging and to call make_pre_post_transformation() only when it is usef...
void delete_named_resources(const char *rn)
Delete from up_to_date_resources make cache all the resources with a given resource name.
void reset_current_phase_context(void)
void reset_make_cache(void)
static list build_real_resources(const char *oname, list lvr)
Translate and expand a list of virtual resources into a potentially much longer list of real resource...
static bool make(const char *rname, const char *oname)
static set up_to_date_resources
FI: pipsmmake is very slow when interprocedural analyzes have been selected; some memoization has bee...
bool safe_concurrent_apply(const char *phase_n, gen_array_t modules)
void delete_all_resources(void)
static double initial_memory_size
bool make_cache_hit_p(void *rr_id)
void do_resource_usage_check(const char *oname, rule ru)
check the usage of resources
static void update_preserved_resources(const char *oname, rule ru)
void reinit_make_cache_if_necessary(void)
static bool apply(const char *pname, const char *oname)
#define add_res(vrn, on)
Apply an instantiated rule with a given ressource owner.
bool rmake(const char *rname, const char *oname)
recursive make resource.
static bool make_post_transformation(const char *, rule)
FI: guard added to simplify debugging and to call make_pre_post_transformation() only when it is usef...
bool safe_set_property(const char *propname, const char *value)
bool safe_apply(const char *phase_n, const char *module_n)
static void preserve_virtual_resource(const char *oname, virtual_resource vr)
touch the resource if it exits this is currently an experimental and partial implementation
static bool catch_user_error(builder_func_t builder, const char *rname, const char *oname)
call builder to build a resource for something.
static list called_modules
list of called subroutines or functions
void parse_properties_string(char *s, bool processing_p)
properties.c
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
bool entity_main_module_p(entity e)
void reset_std_static_entities()
void error_reset_current_module_statement(void)
To be called by an error management routine only.
void entity_basic_concrete_types_init(void)
void error_reset_current_module_entity(void)
To be called by an error management routine only.
void entity_basic_concrete_types_reset(void)
struct _newgen_struct_callees_ * callees
#define callees_callees(x)
static int line
FLEX_SCANNER.
void reset_total_precondition_map(void)
void reset_precondition_map(void)
void reset_transformer_map(void)
FI: I do not understand why the type is duplicated at the set level.
The structure used to build lists in NewGen.