From: Moritz Kroll Date: Mon, 3 Nov 2008 19:39:38 +0000 (+0000) Subject: Added new storage class for pointer constants X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=e3e0e94d6bcf4257ff00c8bc173d13fd279932b1;p=libfirm Added new storage class for pointer constants [r23420] --- diff --git a/include/libfirm/irmemory.h b/include/libfirm/irmemory.h index c99764a27..fbc22461c 100644 --- a/include/libfirm/irmemory.h +++ b/include/libfirm/irmemory.h @@ -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; diff --git a/ir/ana/irmemory.c b/ir/ana/irmemory.c index 850326627..2c2965997 100644 --- a/ir/ana/irmemory.c +++ b/ir/ana/irmemory.c @@ -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; } }