https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112400
Bug ID: 112400 Summary: VAX: ICE in fixup_reorder_chain, at cfgrtl.cc:4025, whilst building gimple_match.cc Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: kalvisd at gmail dot com Target Milestone: --- Created attachment 56511 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56511&action=edit Reduced test case GCC was built as below, on amd64 targeting vax: $ /mnt/gcc/x86_64/bin/vax--netbsdelf-g++ -v Using built-in specs. COLLECT_GCC=/mnt/gcc/x86_64/bin/vax--netbsdelf-g++ COLLECT_LTO_WRAPPER=/mnt/gcc/x86_64/bin/../libexec/gcc/vax--netbsdelf/12.2.0/lto-wrapper Target: vax--netbsdelf Configured with: ../gcc-12.2.0/configure --prefix=/mnt/gcc/12/../x86_64 --target=vax--netbsdelf --enable-long-long --enable-threads --with-system-zlib --without-isl --enable-__cxa_atexit --enable-libstdcxx-time=rt --enable-libstdcxx-threads --with-diagnostics-color=auto-if-env --with-default-libstdcxx-abi=new --with-sysroot=/srv/nfs/netbsd-git/build/obj.vax/srv/nfs/netbsd-git/src/destdir.vax --disable-nls --disable-multilib --program-transform-name=''\''s,^,vax--netbsdelf-,'\''' --with-mpc=/mnt/gcc/12/../x86_64 --with-mpfr=/mnt/gcc/12/../x86_64 --with-gmp=/mnt/gcc/12/../x86_64 --with-isl=/mnt/gcc/12/../x86_64 --srcdir=/mnt/gcc/12/gcc-12.2.0-x86_64-vax--netbsdelf/../gcc-12.2.0 Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.2.0 (GCC) Output from GCC when it generated the ICE: /mnt/gcc/x86_64/bin/vax--netbsdelf-g++ -O2 -fpic -fPIC -o gimple-match.s -S gimple-match.i gimple-match.i: In function 'bool ah(x*, b*, a (*)(a), a, a*, k)': gimple-match.i:22:44: warning: no return statement in function returning non-void [-Wreturn-type] 22 | static bool ah(x *, b *, a(a), a, a *, k) {} | ^ gimple-match.i: In function 'bool ai(x*, a (*)(a))': gimple-match.i:92:1: warning: control reaches end of non-void function [-Wreturn-type] 92 | } | ^ during RTL pass: bbro gimple-match.i:92:1: internal compiler error: in fixup_reorder_chain, at cfgrtl.cc:4025 0x5bc784 fixup_reorder_chain /mnt/gcc/12/gcc-12.2.0-x86_64-vax--netbsdelf/../gcc-12.2.0/gcc/cfgrtl.cc:4025 0x5bc784 cfg_layout_finalize() /mnt/gcc/12/gcc-12.2.0-x86_64-vax--netbsdelf/../gcc-12.2.0/gcc/cfgrtl.cc:4538 0x1276008 execute /mnt/gcc/12/gcc-12.2.0-x86_64-vax--netbsdelf/../gcc-12.2.0/gcc/bb-reorder.cc:2663 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. make: *** [Makefile:47: gimple-match.s] Error 1 Compiler invoked using /mnt/gcc/x86_64/bin/vax--netbsdelf-g++ -O2 -fpic -fPIC -o gimple-match.s -S gimple-match.i The reduced input file is attached as gimple-match.i The root cause seems to be an incompletely removed computed jump instruction; the 'jump2' phase was able to remove the related table of jump offsets but not the jump itself, and this appears to be because onlyjump_p() did not recognise the computed jump instruction. The RTX for a computed jump instruction on VAX is something like this: (jump_insn 10499 6387 3048 558 (parallel [ (const_int 3 [0x3]) (set (pc) (plus:SI (sign_extend:SI (mem:HI (plus:SI (mult:SI (reg:SI 0 %r0 [1385]) (const_int 2 [0x2])) (pc)) [0 S2 A8])) (label_ref:SI 3048))) (clobber (reg:CC 16 %psl)) (use (label_ref:SI 3048)) ]) 573 {*casesi1} (expr_list:REG_DEAD (reg:SI 0 %r0 [1385]) (expr_list:REG_UNUSED (reg:CC 16 %psl) (nil))) -> 3048) onlyjump_p() will recognise jump instructions if and only if there is one set expression, zero or more use or clobber expressions, and no other expression types.