-static type *get_dynamic_type(ir_node *ptr) {
- ptr = skip_Cast(skip_Proj(ptr));
- if (get_irn_op(ptr) == op_Alloc)
- return get_Alloc_type(ptr);
- return firm_unknown_type;
+static ir_type *get_dynamic_type(ir_node *ptr) {
+ ir_type *tp;
+
+ /* skip Cast and Confirm nodes */
+ for (;;) {
+ ir_opcode code = get_irn_opcode(ptr);
+
+ switch (code) {
+ case iro_Cast:
+ ptr = get_Cast_op(ptr);
+ continue;
+ case iro_Confirm:
+ ptr = get_Confirm_value(ptr);
+ continue;
+ default:
+ ;
+ }
+ break;
+ }
+ tp = (*firm_get_Alloc)(ptr);
+ return tp ? tp : firm_unknown_type;
+}
+
+/**
+ * Check, if an entity is final, i.e. is not anymore overridden.
+ */
+static int is_final_ent(ir_entity *ent) {
+ if (is_entity_final(ent)) {
+ /* not possible to override this entity. */
+ return 1;
+ }
+ if (get_opt_closed_world() && get_entity_n_overwrittenby(ent) == 0) {
+ /* we have a closed world, so simply check how often it was
+ overridden. */
+ return 1;
+ }
+ return 0;