Bug 54385 - [4.8 regression] ICE in pre_and_rev_post_order_compute, at cfganal.c:873
Summary: [4.8 regression] ICE in pre_and_rev_post_order_compute, at cfganal.c:873
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Steven Bosscher
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: build, ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2012-08-27 16:53 UTC by Andreas Schwab
Modified: 2012-11-09 12:33 UTC (History)
2 users (show)

See Also:
Host:
Target: m68k-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-08-27 00:00:00


Attachments
Reduced from libjava/java/lang/natClassLoader.cc (363 bytes, text/plain)
2012-08-27 16:53 UTC, Andreas Schwab
Details
Try to delete unreachable blocks if any edges were removed (1.31 KB, patch)
2012-08-27 17:54 UTC, Steven Bosscher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2012-08-27 16:53:05 UTC
Created attachment 28089 [details]
Reduced from libjava/java/lang/natClassLoader.cc

$ gcc/xgcc -B gcc/ -O2 -fnon-call-exceptions natClassLoader.ii -S
natClassLoader.ii: In function ‘void _Jv_PushClass(jclass)’:
natClassLoader.ii:51:1: internal compiler error: in pre_and_rev_post_order_compute, at cfganal.c:873

Started with r190602.
Comment 1 Steven Bosscher 2012-08-27 17:18:27 UTC
Starting program: /home/stevenb/devel/build-debug/gcc/cc1plus -quiet PR54385.cc -O2 -fnon-call-exceptions

Breakpoint 1, fancy_abort (file=0x1147c0a0 "../../trunk/gcc/cfganal.c", line=873, function=0x1147c1c0 "pre_and_rev_post_order_compute")
    at ../../trunk/gcc/diagnostic.c:1011
1011      internal_error ("in %s, at %s:%d", function, trim_filename (file), line);
(gdb) up
#1  0x00000000105d7d4c in pre_and_rev_post_order_compute (pre_order=0x0, rev_post_order=0x116d5580, include_entry_exit=false) at ../../trunk/gcc/cfganal.c:873
873         gcc_assert (pre_order_num == n_basic_blocks - NUM_FIXED_BLOCKS);
(gdb) p brief_dump_cfg(stderr,-1)
;; basic block 2, loop depth 0, count 0, freq 10000, maybe hot
;;  prev block 0, next block 3, flags: (REACHABLE, RTL, MODIFIED)
;;  pred:       ENTRY [100.0%]  (FALLTHRU)
;;  succ:       3 [100.0%]  (FALLTHRU)
;; basic block 3, loop depth 0, count 0, freq 10000, maybe hot
;;  prev block 2, next block 4, flags: (REACHABLE, RTL, MODIFIED)
;;  pred:       2 [100.0%]  (FALLTHRU)
;;  succ:       EXIT [100.0%]  (ABNORMAL,SIBCALL)
;; basic block 4, loop depth 0, count 0, freq 0
;;  prev block 3, next block 1, flags: (REACHABLE, RTL, MODIFIED)
;;  pred:      
;;  succ:      
$5 = void
(gdb) p current_pass->name
$6 = 0x114a27d8 "postreload"

So there's an unreachable block and it confuses pre_and_rev_post_order_compute. Someone has removed a critical edge between the ICE point and the start of postreload. This is the CFG on entry to rest_of_handle_postreload:

;; basic block 2, loop depth 0, count 0, freq 10000, maybe hot
;;  prev block 0, next block 3, flags: (REACHABLE, RTL, MODIFIED)
;;  pred:       ENTRY [100.0%]  (FALLTHRU)
;;  succ:       4 (ABNORMAL,EH)
;;              3 [100.0%]  (FALLTHRU)
;; basic block 3, loop depth 0, count 0, freq 10000, maybe hot
;;  prev block 2, next block 4, flags: (REACHABLE, RTL, MODIFIED)
;;  pred:       2 [100.0%]  (FALLTHRU)
;;  succ:       EXIT [100.0%]  (ABNORMAL,SIBCALL)
;; basic block 4, loop depth 0, count 0, freq 0
;;  prev block 3, next block 1, flags: (REACHABLE, RTL, MODIFIED)
;;  pred:       2 (ABNORMAL,EH)
;;  succ:  

The edge disappears in reload_cse_regs_1, which is not CFG aware (like most of postreload, it seems).

This is a pre-existing problem that happens to be exposed by my patch.
Comment 2 Steven Bosscher 2012-08-27 17:54:51 UTC
Created attachment 28090 [details]
Try to delete unreachable blocks if any edges were removed
Comment 3 Mikael Pettersson 2012-10-26 10:15:26 UTC
I just hit this ICE trying to built trunk @ r192837 as a cross to m68k-linux with java enabled.  Steven's patch fixed the ICE.

(The java build also needed my proposed PR49847 patch.)
Comment 4 Steven Bosscher 2012-11-09 12:31:40 UTC
Author: steven
Date: Fri Nov  9 12:31:32 2012
New Revision: 193359

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193359
Log:
	PR middle-end/54385
	* postreload.c (reload_cse_simplify): Return a bool indicating
	whether the CFG was changed.
	(reload_cse_regs_1): Traverse the CFG instead of the insns chain.
	Cleanup the CFG if edges may have been removed.
	(reload_cse_regs): Update.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/postreload.c
Comment 5 Steven Bosscher 2012-11-09 12:33:08 UTC
.