Duplicate constraints in ipa-pta

Tom de Vries Tom_deVries@mentor.com
Wed Oct 28 15:15:00 GMT 2015


On 28/10/15 12:10, Richard Biener wrote:
> On Wed, 28 Oct 2015, Tom de Vries wrote:
>
>> Richard,
>>
>> when compiling this testcase:
>> ...
>> static int __attribute__((noinline, noclone))
>> foo (int *a, int *b)
>> {
>>    *b = 1;
>>    *a = 2;
>>    return *b;
>> }
>>
>> int __attribute__((noinline, noclone))
>> bar (int *a, int *b)
>> {
>>    return foo (a, b);
>> }
>> ...
>>
>> with -O2 -fipa-pta we find in the pta dumpfile:
>> ...
>> Generating constraints for bar (bar)
>>
>> bar.arg0 = &NONLOCAL
>> bar.arg1 = &NONLOCAL
>> bar.arg1 = &NONLOCAL
>> ...
>>
>> The reason for the duplicate last two constraints is that with fipa-pta, in
>> create_function_info_for we link the function arguments in a next chain.
>>
>> And in intra_create_variable_infos there are two iteration mechanism used:
>> - the loop over the function arguments
>> - the loop over the vi_next (p) for each function argument p
>>
>> So when processing argument a, we generate constraints for both a and it's
>> next b.
>> And when processing argument b, we generate constraints for b again.
>>
>> Is this a known issue? Should we fix this?
>
> Didn't see that yet.  Yes, we should fix it.
>
> Index: gcc/tree-ssa-structalias.c
> ===================================================================
> --- gcc/tree-ssa-structalias.c  (revision 229481)
> +++ gcc/tree-ssa-structalias.c  (working copy)
> @@ -5913,6 +6009,8 @@ intra_create_variable_infos (struct func
>                  make_constraint_from_global_restrict (p, "PARM_RESTRICT");
>                else if (p->may_have_pointers)
>                  make_constraint_from (p, nonlocal_id);
> +             if (p->is_full_var)
> +               break;
>              }
>          }
>       }
>
> does for me.  Pre-approved if it passes testing.

Tested and committed. Posting with ChangeLog entry.

Thanks,
- Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Generate-constraints-only-once-in-intra_create_varia.patch
Type: text/x-patch
Size: 740 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20151028/4ab7c6a0/attachment.bin>


More information about the Gcc mailing list