Added new storage class for pointer constants
authorMoritz Kroll <Moritz.Kroll@gmx.de>
Mon, 3 Nov 2008 19:39:38 +0000 (19:39 +0000)
committerMoritz Kroll <Moritz.Kroll@gmx.de>
Mon, 3 Nov 2008 19:39:38 +0000 (19:39 +0000)
[r23420]

include/libfirm/irmemory.h
ir/ana/irmemory.c

index c99764a..fbc2246 100644 (file)
@@ -64,6 +64,7 @@ typedef enum {
        ir_sc_argument          = 0x3,  /**< an method argument */
        ir_sc_tls               = 0x4,  /**< an address of a thread local storage variable */
        ir_sc_malloced          = 0x5,  /**< an allocated heap address */
+       ir_sc_globaladdr        = 0x6,  /**< a constant address of something, said to be alias free */
 
        ir_sc_modifier_nottaken = 0x80  /**< if set, the address of the variable was not taken */
 } ir_storage_class_class_t;
index 8503266..2c29659 100644 (file)
@@ -438,6 +438,8 @@ ir_storage_class_class_t classify_pointer(ir_graph *irg, ir_node *irn, ir_entity
                        res |= ir_sc_modifier_nottaken;
        } else if (is_Proj(irn) && is_malloc_Result(irn)) {
                return ir_sc_malloced;
+       } else if (is_Const(irn)) {
+               return ir_sc_globaladdr;
        }
 
        return res;
@@ -603,6 +605,16 @@ static ir_alias_relation _get_alias_relation(
 
                        /* for some reason CSE didn't happen yet for the 2 SymConsts... */
                        return ir_may_alias;
+               } else if (class1 == ir_sc_globaladdr) {
+                       tarval *tv  = get_Const_tarval(base1);
+                       offset1    += get_tarval_long(tv);
+                       tv          = get_Const_tarval(base2);
+                       offset2    += get_tarval_long(tv);
+
+                       if ((unsigned long)labs(offset2 - offset1) >= mode_size)
+                               return ir_no_alias;
+                       else
+                               return ir_sure_alias;
                }
        }