This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFA][PATCH][PR middle-end/61118] Improve tree CFG accuracy for setjmp/longjmp
- From: Jeff Law <law at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 2 Mar 2018 16:17:28 -0700
- Subject: Re: [RFA][PATCH][PR middle-end/61118] Improve tree CFG accuracy for setjmp/longjmp
- Authentication-results: sourceware.org; auth=none
- References: <93b4b8a7-c6fe-65c0-0609-62ebee669967@redhat.com> <CAFiYyc3ptsvAfoXUzA==_dTp5UB6pQzHOia9MBEYVJNi-HD5CA@mail.gmail.com> <4bf9a4f9-2125-dc31-5c61-b4a29315eda6@redhat.com> <20180302230704.GK5867@tucnak>
On 03/02/2018 04:07 PM, Jakub Jelinek wrote:
> On Fri, Mar 02, 2018 at 03:18:05PM -0700, Jeff Law wrote:
>> On 02/28/2018 03:43 AM, Richard Biener wrote:
>> [ More snipping ]
>>
>>>
>>>> It's actually pretty easy to fix the CFG. We just need to recognize
>>>> that a "returns twice" function returns not to the call, but to the
>>>> point immediately after the call. So if we have a call to a returns
>>>> twice function that ends a block with a single successor, when we wire
>>>> up the abnormal dispatcher, we target the single successor rather than
>>>> the block containing the returns-twice call.
>>>
>>> Hmm, I think you need to check whether the successor has a single
>>> predecessor, not whether we have a single successor (we always have
>>> that unless setjmp also throws). If you fix that you keep the CFG
>>> "incorrect" if there are multiple predecessors so I think in addition
>>> to properly creating the edges you have to work on the BB building
>>> part to ensure that there's a single-predecessor block after
>>> returns-twice function calls. Note that currently we force returns-twice
>>> to be the first (and only) stmt of a block -- your fix would relax this,
>>> returns-twice no longer needs to start a new BB.
>> So I found the code which makes the setjmp start a new block. But I
>> haven't found the code which makes setjmp end a block. I'm going to
>> have to throw things into the debugger to find the latter.
>>
>>
>> We ought to remove the code that makes the setjmp start a new block.
>> That's just unnecessary. setjmp certainly needs to end the block though.
>
> At least in gimple, having setjmp start the block is intentional;
> we have abnormal edges from all the (possible) spots which might have
> longjmp to abnormal dispatcher artificial bb and from that block abnormal
> edges to all the sigjmp starts, which is how we emulate the fact that
> longjmp might return in a setjmp location. Edges are created by
> handle_abnormal_edges.
But the longjmp should not return to the setjmp call, it should return
to the point immediately after the setjmp call. That's the core of the
issue with 61118.
jeff