From: Tom de Vries Date: Mon, 3 Jul 2017 07:20:49 +0000 (+0000) Subject: Fix sigsegv in find_same_succ_bb X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0bbfd5540d15befe675f8bac6a5aa55df9064436;p=gcc.git Fix sigsegv in find_same_succ_bb 2017-07-03 Tom de Vries PR tree-optimization/81192 * tree-ssa-tail-merge.c (same_succ_flush_bb): Handle BB_SAME_SUCC (bb) == NULL. * gcc.dg/pr81192.c: New test. From-SVN: r249893 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 64793d9a95f..7284fef2806 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-07-03 Tom de Vries + + PR tree-optimization/81192 + * tree-ssa-tail-merge.c (same_succ_flush_bb): Handle + BB_SAME_SUCC (bb) == NULL. + 2017-07-02 Jan Hubicka * cfgrtl.c (rtl_verify_edges): Enable checking of profile_probability diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ac9c6a63d61..dda405aa9e7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-03 Tom de Vries + + PR tree-optimization/81192 + * gcc.dg/pr81192.c: New test. + 2017-07-02 Thomas Koenig * gfortran/eoshift_3.f90: New test. diff --git a/gcc/testsuite/gcc.dg/pr81192.c b/gcc/testsuite/gcc.dg/pr81192.c new file mode 100644 index 00000000000..57eb4781d4d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr81192.c @@ -0,0 +1,22 @@ +/* { dg-options "-Os -fdump-tree-pre-details" } */ + +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)) + ; +} + +/* { dg-final { scan-tree-dump-times "(?n)find_duplicates: duplicate of " 1 "pre" } } */ diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c index db836f7187f..e88072c1836 100644 --- a/gcc/tree-ssa-tail-merge.c +++ b/gcc/tree-ssa-tail-merge.c @@ -809,6 +809,9 @@ static void same_succ_flush_bb (basic_block bb) { same_succ *same = BB_SAME_SUCC (bb); + if (! same) + return; + BB_SAME_SUCC (bb) = NULL; if (bitmap_single_bit_set_p (same->bbs)) same_succ_htab->remove_elt_with_hash (same, same->hashval);