This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR81192] Fix sigsegv in find_same_succ_bb
- From: Richard Biener <rguenther at suse dot de>
- To: Tom de Vries <Tom_deVries at mentor dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 3 Jul 2017 08:59:18 +0200 (CEST)
- Subject: Re: [PATCH, PR81192] Fix sigsegv in find_same_succ_bb
- Authentication-results: sourceware.org; auth=none
- References: <2777d355-a59c-a87b-bb64-86cd40eab077@mentor.com>
On Sun, 2 Jul 2017, Tom de Vries wrote:
> Hi,
>
> consider this test-case:
> ...
> unsigned a;
> int b, c;
>
> static int
> fn1 (int p1, int p2)
> {
> return p1 > 2147483647 - p2 ? p1 : p1 + p2;
> }
>
> void
> fn2 (void)
> {
> int j;
> a = 30;
> for (; a;)
> for (; c; b = fn1 (j, 1))
> ;
> }
> ...
>
> When compiling the test-case with -Os, just before tail-merge it looks as in
> before.pdf.
>
> During tail-merge, it runs into a sigsegv.
>
> What happens is the following:
> - tail-merge decides to merge blocks 4 and 6, and removes block 6.
> - bb8, a predecessor of block 6, is marked as member of
> deleted_bb_preds.
> - during update_worklist, same_succ_flush_bb is called for bb8
> - same_succ_flush_bb runs into a sigsegv because
> BB_SAME_SUCC (bb8) == NULL
> - the reason that BB_SAME_SUCC (bb8) == NULL, is because it hit the
> bb->loop_father->latch == bb clause in find_same_succ_bb at the start
> of the tail-merge pass.
>
> This patch fixes the sigsegv by doing an early-out in same_succ_flush_bb if
> BB_SAME_SUCC () == NULL.
>
> Bootstrapped and reg-tested on x86_64.
>
> OK for trunk and gcc-[567]-branch?
Ok for trunk and branches. Mind the gcc-6 branch is frozen right now.
Thanks,
Richard.
> Thanks,
> - Tom
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)