Commit 4d3e8960 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

tr: Ensure that all entities have an owner.

parent 7a13c436
......@@ -2840,7 +2840,6 @@ static ir_node *gen_Switch(ir_node *node)
const ir_switch_table *table = get_Switch_table(node);
unsigned n_outs = get_Switch_n_outs(node);
ir_node *new_node;
ir_entity *entity;
assert(get_mode_size_bits(sel_mode) <= 32);
assert(!mode_is_float(sel_mode));
......@@ -2848,7 +2847,8 @@ static ir_node *gen_Switch(ir_node *node)
if (get_mode_size_bits(sel_mode) < 32)
new_sel = transform_upconv(sel, node);
entity = new_entity(NULL, id_unique("TBL%u"), get_unknown_type());
ir_type *const utype = get_unknown_type();
ir_entity *const entity = new_entity(utype, id_unique("TBL%u"), utype);
set_entity_visibility(entity, ir_visibility_private);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT);
......
......@@ -1101,7 +1101,6 @@ static ir_node *gen_Switch(ir_node *node)
ir_node *new_selector = be_transform_node(selector);
const ir_switch_table *table = get_Switch_table(node);
unsigned n_outs = get_Switch_n_outs(node);
ir_entity *entity;
ir_node *table_address;
ir_node *idx;
ir_node *load;
......@@ -1112,7 +1111,8 @@ static ir_node *gen_Switch(ir_node *node)
/* switch with smaller mode not implemented yet */
assert(get_mode_size_bits(get_irn_mode(selector)) == 32);
entity = new_entity(NULL, id_unique("TBL%u"), get_unknown_type());
ir_type *const utype = get_unknown_type();
ir_entity *const entity = new_entity(utype, id_unique("TBL%u"), utype);
set_entity_visibility(entity, ir_visibility_private);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT);
......
......@@ -77,13 +77,7 @@ static void show_entity_failure(const ir_node *node)
if (ent) {
ir_type *ent_type = get_entity_owner(ent);
if (ent_type) {
ir_fprintf(stderr, "\nFIRM: irn_verify_irg() %+F::%s failed\n",
ent_type, get_entity_name(ent));
} else {
fprintf(stderr, "\nFIRM: irn_verify_irg() <NULL>::%s failed\n", get_entity_name(ent));
}
ir_fprintf(stderr, "\nFIRM: irn_verify_irg() %+F::%s failed\n", ent_type, get_entity_name(ent));
} else {
fprintf(stderr, "\nFIRM: irn_verify_irg() <IRG %p> failed\n", (void *)irg);
}
......
......@@ -58,6 +58,8 @@ ir_entity *get_unknown_entity(void)
static ir_entity *intern_new_entity(ir_type *owner, ir_entity_kind kind,
ident *name, ir_type *type, dbg_info *dbgi)
{
assert(owner);
ir_entity *res = XMALLOCZ(ir_entity);
res->kind = k_entity;
......@@ -82,7 +84,7 @@ static ir_entity *intern_new_entity(ir_type *owner, ir_entity_kind kind,
#endif
/* Remember entity in its owner. */
if (owner != NULL)
if (is_compound_type(owner))
add_compound_member(owner, res);
res->visit = 0;
......@@ -108,8 +110,7 @@ ir_entity *new_d_entity(ir_type *owner, ident *name, ir_type *type,
res->attr.mtd_attr.param_access = NULL;
res->attr.mtd_attr.param_weight = NULL;
res->attr.mtd_attr.irg = NULL;
} else if (owner != NULL
&& (is_compound_type(owner) && !(owner->flags & tf_segment))) {
} else if (is_compound_type(owner) && !(owner->flags & tf_segment)) {
res = intern_new_entity(owner, IR_ENTITY_COMPOUND_MEMBER, name, type, db);
} else {
res = intern_new_entity(owner, IR_ENTITY_NORMAL, name, type, db);
......@@ -256,7 +257,7 @@ ir_entity *copy_entity_name(ir_entity *old, ident *new_name)
void free_entity(ir_entity *ent)
{
if (ent->owner != NULL && !is_Array_type(ent->owner))
if (is_compound_type(ent->owner))
remove_compound_member(ent->owner, ent);
assert(ent && ent->kind == k_entity);
......@@ -1024,9 +1025,9 @@ int entity_has_definition(const ir_entity *entity)
void ir_init_entity(ir_prog *irp)
{
ident *id = new_id_from_str(UNKNOWN_ENTITY_NAME);
irp->unknown_entity = intern_new_entity(NULL, IR_ENTITY_UNKNOWN, id,
irp->unknown_type, NULL);
ident *const id = new_id_from_str(UNKNOWN_ENTITY_NAME);
ir_type *const utype = get_unknown_type();
irp->unknown_entity = intern_new_entity(utype, IR_ENTITY_UNKNOWN, id, utype, NULL);
set_entity_visibility(irp->unknown_entity, ir_visibility_external);
set_entity_ld_ident(irp->unknown_entity, id);
hook_new_entity(irp->unknown_entity);
......
......@@ -1449,10 +1449,9 @@ ir_type *new_d_type_array(size_t n_dimensions, ir_type *element_type,
res->attr.aa.order[i] = i;
}
ident *const id = new_id_from_chars("elem_ent", 8);
res->attr.aa.element_type = element_type;
res->attr.aa.element_ent
= new_entity(NULL, new_id_from_chars("elem_ent", 8), element_type);
res->attr.aa.element_ent->owner = res;
res->attr.aa.element_ent = new_entity(res, id, element_type);
hook_new_type(res);
return res;
......
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