return ptr;
} /* find_base_adr */
-/**
- * Check if the address can be decomposed into base PLUS offset.
- */
-static int has_offset(ir_node *adr, int *offset) {
- if (is_SymConst(adr)) {
- *offset = 0;
- return 1;
- }
- if (is_Sel(adr)) {
- ir_entity *ent = get_Sel_entity(adr);
- ir_type *owner = get_entity_owner(ent);
-
- if (get_type_state(owner) != layout_fixed) {
- /* The layout is NOT fixed yet, symbolic evaluation needed */
- }
- }
- return 0;
-} /* has_offset */
-
-/**
- * Two address expressions have the same base address,
- * check if there offsets are different.
- *
- * @param adr1 The first address.
- * @param adr2 The second address.
- */
-static ir_alias_relation different_offsets(ir_node *adr1, ir_node *adr2) {
- int offset1, offset2;
- if (has_offset(adr1, &offset1) && has_offset(adr2, &offset2)) {
- /* */
- }
- return may_alias;
-} /* different_offsets */
-
/**
* Check if a given Const node is greater or equal a given size.
*
return check_const(r1, size);
}
if (is_Add(idx2)) {
- /* both are Adds, check if they are of x + c kind */
+ /* both are Adds, check if they are of x + a == x + b kind */
ir_node *l2 = get_Add_left(idx2);
ir_node *r2 = get_Add_right(idx2);
}
if (is_Sub(idx2)) {
- /* both are Subs, check if they are of x - c kind */
+ /* both are Subs, check if they are of x - a == x - b kind */
ir_node *l2 = get_Sub_left(idx2);
if (l1 == l2) {
if (tp1 == tp2)
check_arr = 1;
else if (get_type_state(tp1) == layout_fixed && get_type_state(tp2) == layout_fixed &&
- get_type_size_bytes(tp1) == get_type_size_bytes(tp2))
+ get_type_size_bits(tp1) == get_type_size_bits(tp2))
check_arr = 1;
}
if (check_arr) {
/* base2 address is a global var (R1 a) */
if (adr1 != base2)
return no_alias;
- else
- return different_offsets(adr1, adr2);
} else if (base2 == get_irg_frame(irg)) {
/* the second one is a local variable so they are always
different (R1 b) */
static int cmp_mem_disambig_entry(const void *elt, const void *key, size_t size) {
const mem_disambig_entry *p1 = elt;
const mem_disambig_entry *p2 = key;
+ (void) size;
return p1->adr1 == p2->adr1 && p1->adr2 == p2->adr2;
} /* cmp_mem_disambig_entry */
ir_address_taken_state state = get_entity_address_taken(ent);
if (state != ir_address_not_taken) {
- assert(ir_address_not_taken <= state && state <= ir_address_taken);
+ assert(ir_address_not_taken <= (int) state && state <= ir_address_taken);
ir_printf("%+F: %s\n", ent, get_address_taken_state_name(state));
}
}
if (irp->globals_adr_taken_state == ir_address_taken_not_computed)
analyse_irp_globals_address_taken();
} /* assure_irp_globals_address_taken_computed */
+
+
+DEBUG_ONLY(static firm_dbg_module_t *dbgcall = NULL;)
+
+/**
+ * Copy the calling conventions from the entities to the call type.
+ */
+static void update_calls(ir_node *call, void *env) {
+ (void) env;
+ if (is_Call(call)) {
+ ir_node *ptr = get_Call_ptr(call);
+
+ if (is_SymConst(ptr)) {
+ ir_entity *ent = get_SymConst_entity(ptr);
+ ir_type *mtp = get_entity_type(ent);
+ ir_type *ctp = get_Call_type(call);
+
+ if (mtp != ctp && get_method_additional_properties(mtp) & mtp_property_private) {
+ set_method_additional_property(ctp, mtp_property_private);
+ DB((dbgcall, LEVEL_1, "changed call to private method %+F\n", ent));
+ }
+ }
+ }
+}
+
+/* Mark all private methods, i.e. those of which all call sites are known. */
+void mark_private_methods(void) {
+ int i;
+ int changed = 0;
+
+ FIRM_DBG_REGISTER(dbgcall, "firm.opt.cc");
+
+ assure_irp_globals_address_taken_computed();
+
+ /* first step: change the calling conventions of the local non-escaped entities */
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ ir_graph *irg = get_irp_irg(i);
+ ir_entity *ent = get_irg_entity(irg);
+ ir_address_taken_state state = get_entity_address_taken(ent);
+
+ if (get_entity_visibility(ent) == visibility_local &&
+ state == ir_address_not_taken) {
+ ir_type *mtp = get_entity_type(ent);
+
+ set_method_additional_property(mtp, mtp_property_private);
+ changed = 1;
+ DB((dbgcall, LEVEL_1, "found private method %+F\n", ent));
+ }
+ }
+
+ if (changed)
+ all_irg_walk(NULL, update_calls, NULL);
+}