/** Returns the entity that contains the implementation of the inherited
* entity if available, else returns the entity passed. */
static ir_entity *get_inherited_methods_implementation(ir_entity *inh_meth) {
/** Returns the entity that contains the implementation of the inherited
* entity if available, else returns the entity passed. */
static ir_entity *get_inherited_methods_implementation(ir_entity *inh_meth) {
- assert(get_atomic_ent_value(inh_meth) && "constant entity without value");
- assert((get_irn_op(get_atomic_ent_value(inh_meth)) == op_SymConst) &&
- (get_SymConst_kind(get_atomic_ent_value(inh_meth)) == symconst_addr_ent) &&
+ ir_node *value = get_atomic_ent_value(inh_meth);
+ assert(value && "constant entity without value");
+ assert(is_SymConst_addr_ent(value) &&
- ir_entity *ent = get_SymConst_entity(get_atomic_ent_value(get_Sel_entity(node)));
- assert(get_entity_peculiarity(ent) != peculiarity_inherited);
-
- if (!eset_contains(entities, ent)) {
- /* Entity not yet handled. Find all (internal or external)
- * implemented methods that overwrites this entity.
- * This set is stored in the entity link. */
- set_entity_link(ent, get_impl_methods(ent));
- eset_insert(entities, ent);
- }
+ ir_entity *ent = get_SymConst_entity(get_atomic_ent_value(get_Sel_entity(node)));
+ assert(get_entity_peculiarity(ent) != peculiarity_inherited);
+
+ if (!eset_contains(entities, ent)) {
+ /* Entity not yet handled. Find all (internal or external)
+ * implemented methods that overwrites this entity.
+ * This set is stored in the entity link. */
+ set_entity_link(ent, get_impl_methods(ent));
+ eset_insert(entities, ent);
+ }
- /* -- As an add on we get an optimization that removes polymorphic calls.
- This optimization is more powerful than that in transform_node_Sel(). -- */
- arr = get_entity_link(ent);
- if (arr == NULL) {
- /*
- * The Sel node never returns a pointer to a usable method.
- * We could not call it, but it may be description:
- * We call a method in a dead part of the program.
- */
- assert(get_entity_peculiarity(ent) == peculiarity_description);
- }
- else if (get_opt_closed_world() && get_opt_dyn_meth_dispatch() &&
- (ARR_LEN(arr) == 1 && arr[0] != NULL)) {
- ir_node *new_node;
-
- /*
- * The Sel node returns only one possible method.
- * So we could replace the Sel node by a SymConst.
- * This method must exists.
- */
- set_irg_current_block(current_ir_graph, get_nodes_block(node));
- assert(get_entity_peculiarity(get_SymConst_entity(get_atomic_ent_value(arr[0]))) ==
- peculiarity_existent);
- new_node = copy_const_value(get_irn_dbg_info(node), get_atomic_ent_value(arr[0]));
- DBG_OPT_POLY(node, new_node);
- exchange(node, new_node);
- }
+ /* -- As an add on we get an optimization that removes polymorphic calls.
+ This optimization is more powerful than that in transform_node_Sel(). -- */
+ arr = get_entity_link(ent);
+ if (arr == NULL) {
+ /*
+ * The Sel node never returns a pointer to a usable method.
+ * We could not call it, but it may be description:
+ * We call a method in a dead part of the program.
+ */
+ assert(get_entity_peculiarity(ent) == peculiarity_description);
+ }
+ else if (get_opt_closed_world() && get_opt_dyn_meth_dispatch() &&
+ (ARR_LEN(arr) == 1 && arr[0] != NULL)) {
+ ir_node *new_node;
+
+ /*
+ * The Sel node returns only one possible method.
+ * So we could replace the Sel node by a SymConst.
+ * This method must exists.
+ */
+ set_irg_current_block(current_ir_graph, get_nodes_block(node));
+ assert(get_entity_peculiarity(get_SymConst_entity(get_atomic_ent_value(arr[0]))) ==
+ peculiarity_existent);
+ new_node = copy_const_value(get_irn_dbg_info(node), get_atomic_ent_value(arr[0]));
+ DBG_OPT_POLY(node, new_node);
+ exchange(node, new_node);
+ }
* op_Tuple oder ein Knoten, der in "free_ana_walker" behandelt
* wird. */
ir_node * pred = get_Proj_pred(node);
* op_Tuple oder ein Knoten, der in "free_ana_walker" behandelt
* wird. */
ir_node * pred = get_Proj_pred(node);
free_mark_proj(get_Tuple_pred(pred, get_Proj_proj(node)), n, set);
} else {
/* nothing: da in "free_ana_walker" behandelt. */
free_mark_proj(get_Tuple_pred(pred, get_Proj_proj(node)), n, set);
} else {
/* nothing: da in "free_ana_walker" behandelt. */
-static void add_method_address_intitialzer(ir_initializer_t *initializer,
- eset *set)
+/**
+ * Add all method addresses in global new style initializers to the set.
+ *
+ * @note
+ * We do NOT check the type here, just it it's an entity address.
+ * The reason for this is code like:
+ *
+ * void *p = function;
+ *
+ * which is sometimes used to anchor functions.
+ */
+static void add_method_address_inititializer(ir_initializer_t *initializer,
+ eset *set)
- switch(initializer->kind) {
- case IR_INITIALIZER_CONST: {
- ir_node *n = initializer->consti.value;
+ ir_node *n;
+ size_t i;
+
+ switch (initializer->kind) {
+ case IR_INITIALIZER_CONST:
+ n = initializer->consti.value;
n = get_compound_ent_value(ent, i);
/* let's check if it's the address of a function */
n = get_compound_ent_value(ent, i);
/* let's check if it's the address of a function */
- irg_walk_graph(irg, NULL, free_ana_walker, free_set);
+ irg_walk_graph(irg, firm_clear_link, free_ana_walker, free_set);
+ ir_free_resources(irg, IR_RESOURCE_IRN_LINK);