On Mon, 3 Jul 2017, Tom de Vries wrote: > [ was: Re: [PATCH, PR81192] Fix sigsegv in find_same_succ_bb ] > > On 07/03/2017 12:26 AM, Tom de Vries wrote: > > [ Trying again with before.svg instead of before.pdf ] > > > > 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.svg. > > > > 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. > > As pointed out in the PR, blocks 4 and 6 belong to different loops, and > shouldn't be merged. > > There is a test 'bb->loop_father->latch == bb' in find_same_succ_bb that is > supposed to keep the two blocks from merging, but the test is not working for > this example because the latch field is not defined (because the loop has in > fact two latches). > > This patch prevents blocks from different loops to be merged by testing for > bb->loop_father->num equivalence in tail-merge.
You can compare bb->loop_father directly. > It also removes the unreliable test for 'bb->loop_father->latch == bb' in > find_same_succ_bb. > > Bootstrapped and reg-tested on x86_64. > > OK for trunk and gcc-[567]-branch? Ok for trunk with the above change, as we do not have any wrong-code/ICE testcase that fails on branches I'd not backport this. Maybe to the GCC 7 branch but certainly not farther. Thanks, Richard. > Thanks, > - Tom > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)