Bug 80823 - [8 Regression] ICE: verify_flow_info failed
Summary: [8 Regression] ICE: verify_flow_info failed
Status: CLOSED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 8.0
: P1 normal
Target Milestone: 8.0
Assignee: Peter Bergner
URL: https://gcc.gnu.org/ml/gcc-patches/20...
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-19 05:15 UTC by Markus Trippelsdorf
Modified: 2017-05-24 12:14 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-05-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2017-05-19 05:15:01 UTC
trippels@gcc2-power8 linux % cat book3s_pr_papr.i
int a, c;
int b[1];
int fn1() {
  switch (a)
  case 0:
  case 2:
    return 1;
  return 0;
}
void fn2() {
  int i;
  for (;; ++i) {
    c = b[i];
    int d = !fn1();
    if (d)
      __asm__("");
  }
}

trippels@gcc2-power8 linux % gcc -c -O3 book3s_pr_papr.i
book3s_pr_papr.i: In function ‘fn2’:
book3s_pr_papr.i:10:6: error: missing edge 2->4
 void fn2() {
      ^~~
book3s_pr_papr.i:10:6: internal compiler error: verify_flow_info failed
0x10359553 verify_flow_info()
        ../../gcc/gcc/cfghooks.c:260
0x1094081b checking_verify_flow_info
        ../../gcc/gcc/cfghooks.h:198
0x1094081b cleanup_tree_cfg_noloop
        ../../gcc/gcc/tree-cfgcleanup.c:837
0x1094081b cleanup_tree_cfg()
        ../../gcc/gcc/tree-cfgcleanup.c:883
0x107bbfc7 execute_function_todo
        ../../gcc/gcc/passes.c:1922
0x107bcd53 do_per_function
        ../../gcc/gcc/passes.c:1653
0x107bcfd3 execute_todo
        ../../gcc/gcc/passes.c:2023
Comment 1 Markus Trippelsdorf 2017-05-19 05:25:13 UTC
Started with r248155.
Comment 2 Peter Bergner 2017-05-19 12:25:10 UTC
Sigh, mine.
Comment 3 Peter Bergner 2017-05-23 16:29:37 UTC
Testing a patch.
Comment 4 Peter Bergner 2017-05-23 16:44:19 UTC
Stupid thinko on my part.  An extra increment is causing us to skip some of the case labels in the switch statement, which only causes an ICE/problem if the skipped case happens to point to the same unreachable block as an earlier case label.  In that case, the earlier case has already removed the unreachable block, but skipped case label still points to it, leading to the verify_flow ICE.
I'm testing the following:

Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 248375)
+++ gcc/tree-cfg.c	(working copy)
@@ -1726,7 +1726,6 @@ group_case_labels_stmt (gswitch *stmt)
 	    remove_edge_and_dominated_blocks (base_edge);
 	  gimple_switch_set_label (stmt, base_index, NULL_TREE);
 	  new_size--;
-	  i++;
 	}
     }
Comment 5 Peter Bergner 2017-05-24 12:11:26 UTC
Author: bergner
Date: Wed May 24 12:10:54 2017
New Revision: 248408

URL: https://gcc.gnu.org/viewcvs?rev=248408&root=gcc&view=rev
Log:
gcc/
	PR middle-end/80823
	* tree-cfg.c (group_case_labels_stmt): Delete increment of "i";

gcc/testsuite/
	PR middle-end/80823
	* gcc.dg/pr80823.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr80823.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-cfg.c
Comment 6 Peter Bergner 2017-05-24 12:14:39 UTC
Fixed in revision r248408.
Comment 7 Peter Bergner 2017-05-24 12:14:57 UTC
Closing as fixed.