- if (class1 == STORAGE_CLASS_GLOBALVAR) {
- ir_entity *entity1 = get_SymConst_entity(base1);
- ir_entity *entity2 = get_SymConst_entity(base2);
- if (entity1 != entity2)
- return no_alias;
-
- /* for some reason CSE didn't happen yet for the 2 SymConsts... */
- return may_alias;
+ if (class1 == ir_sc_pointer || class2 == ir_sc_pointer) {
+ /* swap pointer class to class1 */
+ if (class2 == ir_sc_pointer) {
+ ir_storage_class_class_t temp = mod1;
+ mod1 = mod2;
+ mod2 = temp;
+ class1 = get_base_sc(mod1);
+ class2 = get_base_sc(mod2);
+ }
+ /* a pointer and an object whose address was never taken */
+ if (mod2 & ir_sc_modifier_nottaken) {
+ return ir_no_alias;
+ }
+ if (mod1 & ir_sc_modifier_argument) {
+ if ( (options & aa_opt_no_alias_args)
+ && (mod2 & ir_sc_modifier_argument))
+ return ir_no_alias;
+ if ( (options & aa_opt_no_alias_args_global)
+ && (class2 == ir_sc_globalvar
+ || class2 == ir_sc_tls
+ || class2 == ir_sc_globaladdr))
+ return ir_no_alias;
+ }
+ } else if (class1 != class2) {
+ /* two objects from different memory spaces */
+ return ir_no_alias;
+ } else {
+ /* both classes are equal */
+ if (class1 == ir_sc_globalvar) {
+ ir_entity *entity1 = get_SymConst_entity(base1);
+ ir_entity *entity2 = get_SymConst_entity(base2);
+ if (entity1 != entity2)
+ return ir_no_alias;
+
+ /* for some reason CSE didn't happen yet for the 2 SymConsts... */
+ return ir_may_alias;
+ } else if (class1 == ir_sc_globaladdr) {
+ ir_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;
+ }