Commit 9022c59e authored by Matthias Braun's avatar Matthias Braun
Browse files

fix some bugs that prevented repeated calling of ir_init and ir_finish

[r27628]
parent 36a16c27
......@@ -126,8 +126,14 @@ void be_init_copystat(void)
BE_REGISTER_MODULE_DESTRUCTOR(be_quit_copystat);
void be_quit_copystat(void)
{
ir_nodeset_del(all_phi_nodes);
ir_nodeset_del(all_copy_nodes);
if (all_phi_nodes != NULL) {
ir_nodeset_del(all_phi_nodes);
all_phi_nodes = NULL;
}
if (all_copy_nodes != NULL) {
ir_nodeset_del(all_copy_nodes);
all_copy_nodes = NULL;
}
}
/**
......
......@@ -127,9 +127,9 @@ void ir_init(const firm_parameter_t *param)
later. */
init_irprog_2();
/* Initialize the type module and construct some idents needed. */
firm_init_type();
ir_init_type();
/* initialize the entity module */
firm_init_entity();
ir_init_entity();
/* class cast optimization */
firm_init_class_casts_opt();
/* memory disambiguation */
......@@ -166,6 +166,9 @@ void ir_finish(void)
free_ir_prog();
ir_finish_entity();
ir_finish_type();
finish_tarval();
finish_mode();
finish_tpop();
......
......@@ -239,7 +239,7 @@ ir_entity *copy_entity_name(ir_entity *old, ident *new_name)
void free_entity(ir_entity *ent)
{
if (! is_Array_type(ent->owner))
if (ent->owner != NULL && !is_Array_type(ent->owner))
remove_compound_member(ent->owner, ent);
assert(ent && ent->kind == k_entity);
......@@ -996,21 +996,23 @@ int entity_has_definition(const ir_entity *entity)
|| entity_has_compound_ent_values(entity);
}
void firm_init_entity(void)
void ir_init_entity(void)
{
symconst_symbol sym;
assert(firm_unknown_type && "Call init_type() before firm_init_entity()!");
assert(!unknown_entity && "Call firm_init_entity() only once!");
unknown_entity = new_d_entity(NULL, new_id_from_str(UNKNOWN_ENTITY_NAME),
firm_unknown_type, NULL);
set_entity_visibility(unknown_entity, ir_visibility_external);
set_entity_ld_ident(unknown_entity, get_entity_ident(unknown_entity));
}
current_ir_graph = get_const_code_irg();
sym.entity_p = unknown_entity;
void ir_finish_entity(void)
{
if (unknown_entity != NULL) {
free_entity(unknown_entity);
unknown_entity = NULL;
}
}
ir_allocation get_entity_allocation(const ir_entity *entity)
......
......@@ -172,7 +172,9 @@ struct ir_entity {
};
/** Initialize the entity module. */
void firm_init_entity(void);
void ir_init_entity(void);
/** Cleanup entity module */
void ir_finish_entity(void);
/* ----------------------- inline functions ------------------------ */
static inline int _is_entity(const void *thing)
......
......@@ -85,7 +85,7 @@ ir_type *get_unknown_type(void)
static ident *value_params_suffix = NULL;
static ident *value_ress_suffix = NULL;
void firm_init_type(void)
void ir_init_type(void)
{
value_params_suffix = new_id_from_str(VALUE_PARAMS_SUFFIX);
value_ress_suffix = new_id_from_str(VALUE_RESS_SUFFIX);
......@@ -106,6 +106,24 @@ void firm_init_type(void)
remove_irp_type(firm_unknown_type);
}
void ir_finish_type(void)
{
if (firm_none_type != NULL) {
free_type(firm_none_type);
firm_none_type = NULL;
}
if (firm_code_type != NULL) {
free_type(firm_code_type);
firm_code_type = NULL;
}
if (firm_unknown_type != NULL) {
free_type(firm_unknown_type);
firm_unknown_type = NULL;
}
value_params_suffix = NULL;
value_ress_suffix = NULL;
}
/** the global type visited flag */
ir_visited_t firm_type_visited;
......
......@@ -286,10 +286,11 @@ int get_class_dfn(const ir_type *clss);
void add_compound_member(ir_type *compound, ir_entity *entity);
void remove_compound_member(ir_type *compound, ir_entity *entity);
/**
* Initialize the type module.
*/
void firm_init_type(void);
/** Initialize the type module. */
void ir_init_type(void);
/** free internal datastructures of type module */
void ir_finish_type(void);
/** Clone an existing method type.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment