[RFC] [alias, middle-end] Alias and data dependency export

Andrey Belevantsev abel@ispras.ru
Tue Jun 30 15:34:00 GMT 2009


Hello,

Richard Guenther wrote:
> On Wed, 3 Jun 2009, Andrey Belevantsev wrote:
> 
>> Richard Guenther wrote:
>>> I think we should instead benchmark getting rid of TMR_ORIGINAL
>>> completely.  We should be able to initialize mem_attrs from the
>>> other fields of the TMR.  But that can be done as a followup if
>>> the special casing is not too ugly for now (was there supposed to
>>> be a patch attached?).
>> The special casing is in the lines of
>>
>> *************** ptr_deref_may_alias_decl_p (tree ptr, tr
>> *** 175,189 ****
>>         || TREE_CODE (ptr) == INTEGER_CST)
>>       return true;
>>
>> !   gcc_assert (TREE_CODE (ptr) == SSA_NAME
>> ! 	      && (TREE_CODE (decl) == VAR_DECL
>> ! 		  || TREE_CODE (decl) == PARM_DECL
>> ! 		  || TREE_CODE (decl) == RESULT_DECL));
>>
>>     /* Non-aliased variables can not be pointed to.  */
>>     if (!may_be_aliased (decl))
>>       return false;
>>
>>     /* If we do not have useful points-to information for this pointer
>>        we cannot disambiguate anything else.  */
>>     pi = SSA_NAME_PTR_INFO (ptr);
>> --- 175,194 ----
>>         || TREE_CODE (ptr) == INTEGER_CST)
>>       return true;
>>
>> !   gcc_assert (TREE_CODE (decl) == VAR_DECL
>> !               || TREE_CODE (decl) == PARM_DECL
>> !               || TREE_CODE (decl) == RESULT_DECL);
>>
>>     /* Non-aliased variables can not be pointed to.  */
>>     if (!may_be_aliased (decl))
>>       return false;
>>
>> +   if (TREE_CODE (ptr) != SSA_NAME)
>> +     {
>> +       gcc_assert (current_ir_type () != IR_GIMPLE);
>> +       return true;
>> +     }
>> +
>>     /* If we do not have useful points-to information for this pointer
>>        we cannot disambiguate anything else.  */
>>     pi = SSA_NAME_PTR_INFO (ptr);
>>
>> and similarly for ptr_derefs_may_alias_p.
> 
> This could be avoided by not generating MEM_ORIG_EXPR from TMR_ORIGINAL
> at all if they have INDIRECT_REF_P as base (with the same effect, aliasing
> everything).
I have added this hunk in the patch, but it may not be needed as I now 
filter trees before feeding them to the oracle anyways.  The current 
patch doesn't change the oracle at all, which is what you probably wanted ;)

>> The current patch I have is attached.  This is the cut-down version without
>> ddg export (I have just edited the diff though to ease review, so the full
>> compilable patch with ddg export is also attached for reference).
As described above, again I have attached two patches: full patch with 
ddg-export and hand-edited diff with removed ddg-export.

>>
>> The partitioning is handled there as the last thing in partiotion_stack_vars,
>> see update_alias_info_with_stack_vars.  The bases are rewritten during expand,
>> seems like the problems I had were because of wrong ordering of the call to my
>> code.  Other stuff you mentioned is fixed as well.
This still applies.

>>
>> Some unsolved problems that may be done as a followup:
>>
>> 1.  The patch of not adding stack vars for SSA_NAMEs breaks a stack protector
>> test, ssp-2.c.  What happens that in the following function:
This is solved after discussion of the above patch on gcc-patches@ -- as 
this change breaks stack protector, is it not desirable, so I don't have 
to change anything in the alias-export patch, as SSA_NAMEs are filtered 
there already.

> 
>> 2. MEM_EXPR/MEM_ORIG_EXPR problem.  As we determined that the former is used
>> for debugging, it seems that both should stay, but the usage of MEM_EXPR
>> should be audited, and its application for debugging and for aliasing should
>> be separated: debugging-related code goes to MEM_EXPR/MEM_OFFSET, while
>> aliasing-related stuff (including nonoverlapping_memrefs_p, which probably can
>> be simplified given the tree oracle) goes to MEM_ORIG_EXPR.  Then we can
>> rename the fields to whatever we want to reflect this.
This remains to be done (we have kind of agreed that it is possible to 
do this as a followup).

The patch still bootstraps and regtests on x86-64 including ada, I see 
builtin-math-6.c failed in comparison with latest test results, but this 
doesn't look like it's related (I will recheck of course).

Also, I will be traveling until next Monday with no email access.

Andrey

2009-06-30  Andrey Belevantsev  <abel@ispras.ru>
         Dmitry Melnik  <dm@ispras.ru>
         Alexander Monakov  <amonakov@ispras.ru>
         Dmitry Zhurikhin  <zhur@ispras.ru>

     * Makefile.in (OBJS-common): Add alias-export.o.
     (tree-ssa.o): Depend on alias-export.h.
     (tree-ssa-alias.o): Likewise.
     (emit-rtl.o): Likewise.
     (alias.o): Likewise.
     (final.o): Likewise.
     * alias-export.c: New file.
     * alias-export.h: New file.
     * rtl.h (struct mem_attrs): New field orig_expr.
     (MEM_ORIG_EXPR): New access macro.
     * tree-ssa-uncprop.c (pass_uncprop): Set TODO_rebuild_alias.
     * tree-ssa.c (delete_tree_ssa): Remove the FIXME loop.
     * tree-ssa-alias.c: (ptr_deref_may_alias_decl_p): Adjust assert to 
include RTL case.
     (ptr_derefs_may_alias_p): Adjust assert to include RTL case.
     * cfgexpand.c: Include alias-export.h.
     (union_stack_vars): Promote TREE_ADDRESSABLE to the merged partition
     representative.
     (update_alias_info_with_stack_vars): New.
     (partition_stack_vars): Call it.
     (gimple_expand_cfg): Also set MEM_ORIG_EXPR to NULL.
     * expr.c (expand_expr_real_1): When expanding TARGET_MEM_REF,
     set MEM_ORIG_EXPR to its TMR_ORIGINAL.
     * function.c (assign_parms_unsplit_complex): Also set MEM_ORIG_EXPR
     for parm.
     * emit-rtl.c: Include alias-export.h.
     (mem_attrs_htab_hash, get_mem_attrs, set_mem_attrs_from_reg,
     set_mem_alias_set, set_mem_align, set_mem_expr, set_mem_offset,
     set_mem_size, change_address, offset_address,
     widen_memory_access, get_spill_slot_decl,
     set_mem_attrs_for_spill): Account for MEM_ORIG_EXPR.
     (set_mem_orig_expr): New.
     (set_mem_attributes_minus_bitpos): Record MEM_ORIG_EXPR.
     (adjust_address_1): When we make a wider address, nullify 
MEM_ORIG_EXPR.
     * emit-rtl.h (set_mem_orig_expr): Export.
     * final.c: Include alias-export.h.
     (rest_of_clean_state): Free exported information.  Call 
delete_tree_ssa from here.
     * alias.c: Include alias-export.h.
     (query_alias_export_info): New.
     (true_dependence): Use query_alias_export_info.
     (canon_true_dependence, write_dependence_p): Likewise.
     * dbgcnt.def (alias_export): New counter.
     * builtins.c (get_memory_rtx): Also set MEM_ORIG_EXPR to NULL.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: current-ae-noddg.diff
Type: text/x-patch
Size: 52084 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090630/56c0adb8/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: current-ae.diff
Type: text/x-patch
Size: 70038 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090630/56c0adb8/attachment-0001.bin>


More information about the Gcc-patches mailing list