This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR71104 - call gimplification


On Wed, May 18, 2016 at 7:43 PM, Jeff Law <law@redhat.com> wrote:
> On 05/17/2016 06:28 AM, Richard Biener wrote:
>>
>>
>> The following patch addresses PR71104 which shows verify-SSA ICEs
>> after gimplify-into-SSA.  The issue is that for returns-twice calls
>> we gimplify register uses in the LHS before the actual call which leads to
>>
>>   p.0_1 = p;
>>   _2 = vfork ();
>>   *p.0_1 = _2;
>>
>> when gimplifying *p = vfork ().  That of course does not work -
>> fortunately the C standard allows to evaluate operands in the LHS
>> in unspecified order of the RHS.  That also makes this order aligned
>> with that scary C++ proposal of defined evaluation order.  It also
>> improves code-generation, avoiding spilling of the pointer load
>> around the call.
>>
>> Exchanging the gimplify calls doesn't fix the issue fully as for
>> aggregate returns we don't gimplify the call result into a
>> temporary.  So we need to make sure to not emit an SSA when
>> gimplifying the LHS of a returns-twice call (this path only applies
>> to non-register returns).
>>
>> A bootstrap with just the gimplification order exchange is building
>> target libs right now, I'll re-bootstrap and test the whole thing
>> again if that succeeds.
>>
>> Is this ok?  I think it makes sense code-generation-wise.  Code
>> changes from GCC 6
>>
>> bar:
>> .LFB0:
>>         .cfi_startproc
>>         subq    $24, %rsp
>>         .cfi_def_cfa_offset 32
>>         call    foo
>>         movq    p(%rip), %rax
>>         movq    %rax, 8(%rsp)
>>         call    vfork
>>         movq    8(%rsp), %rdx
>>         movl    %eax, (%rdx)
>>         addq    $24, %rsp
>>         .cfi_def_cfa_offset 8
>>         ret
>>
>> to
>>
>> bar:
>> .LFB0:
>>         .cfi_startproc
>>         subq    $8, %rsp
>>         .cfi_def_cfa_offset 16
>>         call    foo
>>         call    vfork
>>         movq    p(%rip), %rdx
>>         movl    %eax, (%rdx)
>>         addq    $8, %rsp
>>         .cfi_def_cfa_offset 8
>>         ret
>>
>> Thanks,
>> Richard.
>>
>> 2016-05-17  Richard Biener  <rguenther@suse.de>
>>
>>         PR middle-end/71104
>>         * gimplify.c (gimplify_modify_expr): Gimplify the RHS before
>>         gimplifying the LHS.  Make sure to gimplify a returning twice
>>         call LHS without using SSA names.
>>
>>         * gcc.dg/pr71104-1.c: New testcase.
>>         * gcc.dg/pr71104-2.c: Likewise.
>
> LGTM.

Now after Jason applied a better solution for gimplifying the RHS
before the LHS I have
applied the following after bootstrap / regtest on x86_64-unknown-linux-gnu.

Richard.

> jeff
>

Attachment: fix-pr71104
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]