Improved implementation:
[libfirm] / ir / ana / irmemory.c
index 1585930..7f46e83 100644 (file)
@@ -335,12 +335,12 @@ static ir_alias_relation different_types(ir_node *adr1, ir_node *adr2)
 {
        ir_entity *ent1 = NULL, *ent2 = NULL;
 
-       if (is_SymConst(adr1) && get_SymConst_kind(adr1) == symconst_addr_ent)
+       if (is_SymConst_addr_ent(adr1))
                ent1 = get_SymConst_entity(adr1);
        else if (is_Sel(adr1))
                ent1 = get_Sel_entity(adr1);
 
-       if (is_SymConst(adr2) && get_SymConst_kind(adr2) == symconst_addr_ent)
+       if (is_SymConst_addr_ent(adr2))
                ent2 = get_SymConst_entity(adr2);
        else if (is_Sel(adr2))
                ent2 = get_Sel_entity(adr2);
@@ -468,9 +468,11 @@ static int is_arg_Proj(ir_node *node) {
 
 /**
  * Returns true if an address represents a global variable.
+ *
+ * @param irn  the node representing the address
  */
 static INLINE int is_global_var(ir_node *irn) {
-       return is_SymConst(irn) && get_SymConst_kind(irn) == symconst_addr_ent;
+       return is_SymConst_addr_ent(irn);
 }  /* is_global_var */
 
 /**
@@ -967,7 +969,7 @@ static void check_initializer(ir_entity *ent) {
        if (is_atomic_entity(ent)) {
                /* let's check if it's an address */
                n = get_atomic_ent_value(ent);
-               if (is_SymConst(n) && get_SymConst_kind(n) == symconst_addr_ent) {
+               if (is_SymConst_addr_ent(n)) {
                        ir_entity *ent = get_SymConst_entity(n);
                        set_entity_address_taken(ent, ir_address_taken);
                }
@@ -976,7 +978,7 @@ static void check_initializer(ir_entity *ent) {
                        n = get_compound_ent_value(ent, i);
 
                        /* let's check if it's an address */
-                       if (is_SymConst(n) && get_SymConst_kind(n) == symconst_addr_ent) {
+                       if (is_SymConst_addr_ent(n)) {
                                ir_entity *ent = get_SymConst_entity(n);
                                set_entity_address_taken(ent, ir_address_taken);
                        }
@@ -1024,7 +1026,7 @@ static void check_global_address(ir_node *irn, void *env) {
        ir_entity *ent;
        ir_address_taken_state state;
 
-       if (is_SymConst(irn) && get_SymConst_kind(irn) == symconst_addr_ent) {
+       if (is_SymConst_addr_ent(irn)) {
                /* A global. */
                ent = get_SymConst_entity(irn);
        } else if (is_Sel(irn) && get_Sel_ptr(irn) == tls) {
@@ -1115,6 +1117,7 @@ static ir_type *clone_type_and_cache(ir_type *tp) {
 
        res = clone_type_method(tp, prefix);
        pmap_insert(mtp_map, tp, res);
+       DB((dbgcall, LEVEL_2, "cloned type %+F into %+F\n", tp, res));
 
        return res;
 }  /* clone_type_and_cache */
@@ -1129,14 +1132,15 @@ static void update_calls_to_private(ir_node *call, void *env) {
 
                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 ((get_method_additional_properties(ctp) & mtp_property_private) == 0) {
-                               ctp = clone_type_and_cache(ctp);
-                               set_method_additional_property(ctp, mtp_property_private);
-                               set_Call_type(call, ctp);
-                               DB((dbgcall, LEVEL_1, "changed call to private method %+F\n", ent));
+                       if (get_entity_additional_properties(ent) & mtp_property_private) {
+                               if ((get_method_additional_properties(ctp) & mtp_property_private) == 0) {
+                                       ctp = clone_type_and_cache(ctp);
+                                       set_method_additional_property(ctp, mtp_property_private);
+                                       set_Call_type(call, ctp);
+                                       DB((dbgcall, LEVEL_1, "changed call to private method %+F\n", ent));
+                               }
                        }
                }
        }
@@ -1164,6 +1168,7 @@ void mark_private_methods(void) {
                        ir_type *mtp = get_entity_type(ent);
 
                        set_entity_additional_property(ent, mtp_property_private);
+                       DB((dbgcall, LEVEL_1, "found private method %+F\n", ent));
                        if ((get_method_additional_properties(mtp) & mtp_property_private) == 0) {
                                /* need a new type */
                                mtp = clone_type_and_cache(mtp);
@@ -1171,7 +1176,6 @@ void mark_private_methods(void) {
                                set_method_additional_property(mtp, mtp_property_private);
                                changed = 1;
                        }
-                       DB((dbgcall, LEVEL_1, "found private method %+F\n", ent));
                }
        }