From 77e5edafafd54b6a68f56e2fb8be67a4dd68ec0c Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 20 Jul 2017 11:27:31 +0000 Subject: [PATCH] re PR middle-end/81030 (ICE on valid code at -O1 (only) on x86_64-linux-gnu: verify_flow_info failed) PR middle-end/81030 * cfgbuild.c (find_many_sub_basic_blocks): Update REG_BR_PROB note when gimple level profile disagrees with what RTL expander did. * gcc.dg/pr81030.c: New test. From-SVN: r250383 --- gcc/ChangeLog | 7 +++++++ gcc/cfgbuild.c | 14 +++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr81030.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr81030.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5bea9dd1e3e..b6282b09997 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-07-18 Jan Hubicka + Tom de Vries + + PR middle-end/81030 + * cfgbuild.c (find_many_sub_basic_blocks): Update REG_BR_PROB note + when gimple level profile disagrees with what RTL expander did. + 2017-07-20 Richard Biener PR tree-optimization/61171 diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c index 16b07073b91..2fe74c40851 100644 --- a/gcc/cfgbuild.c +++ b/gcc/cfgbuild.c @@ -673,10 +673,18 @@ find_many_sub_basic_blocks (sbitmap blocks) && profile_status_for_fn (cfun) != PROFILE_READ)) bb->count = profile_count::uninitialized (); } - else - /* If nothing changed, there is no need to create new BBs. */ - if (EDGE_COUNT (bb->succs) == n_succs[bb->index]) + /* If nothing changed, there is no need to create new BBs. */ + else if (EDGE_COUNT (bb->succs) == n_succs[bb->index]) + { + /* In rare occassions RTL expansion might have mistakely assigned + a probabilities different from what is in CFG. This happens + when we try to split branch to two but optimize out the + second branch during the way. See PR81030. */ + if (JUMP_P (BB_END (bb)) && any_condjump_p (BB_END (bb)) + && EDGE_COUNT (bb->succs) >= 2) + update_br_prob_note (bb); continue; + } compute_outgoing_frequencies (bb); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8ff6c4f200c..8b840a2a01f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-17 Tom de Vries + + PR middle-end/81030 + * gcc.dg/pr81030.c: New test. + 2017-07-20 Richard Biener PR tree-optimization/61171 diff --git a/gcc/testsuite/gcc.dg/pr81030.c b/gcc/testsuite/gcc.dg/pr81030.c new file mode 100644 index 00000000000..23da6e528ac --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr81030.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +void __assert_fail (const char *, const char *, unsigned int, const char *); + +int a, b, c, d, e, f, h; +unsigned char g; + +int main () +{ + int i, *j = &b; + if (a) + { + if (h) + { + int **k = &j; + d = 0; + *k = &e; + } + else + for (b = 0; b > -28; b = g) + ; + c || !j ? : __assert_fail ("c || !j", "small.c", 20, "main"); + if (f) + for (i = 0; i < 1; i++) + ; + } + return 0; +} -- 2.30.2