https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80747
Bug ID: 80747 Summary: gcc.dg/tree-ssa/tailrecursion-4.c fails with ICE when compiled with options "-fprofile-use -freorder-blocks-and-partition" Product: gcc Version: 6.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: zwzhangwen.zhang at huawei dot com Target Milestone: --- Created attachment 41355 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41355&action=edit my patch for fix this ICE. When I test bb-reorder pass with deja testcase, this ICE has been found. Compile line is as follow: ./install/bin/mips-sde-elf-gcc -fprofile-use -freorder-blocks-and-partition -O1 -foptimize-sibling-calls -S tailrecursion-4.c The ICE information is: tailrecursion-4.c: In function 't': tailrecursion-4.c:16:1: internal compiler error: in df_compact_blocks, at df-core.c:1743 } ^ 0x859fce df_compact_blocks() /home/wangtao/SDK_CPU_HCC_TEST/hi1822/SDK_CPU_HCC/build/script/1822/hi1822_build_dir/src/gcc-6.3.0/gcc/df-core.c:1743 0x11f3abe compact_blocks() /home/wangtao/SDK_CPU_HCC_TEST/hi1822/SDK_CPU_HCC/build/script/1822/hi1822_build_dir/src/gcc-6.3.0/gcc/cfg.c:159 0x813fea relink_block_chain(bool) /home/wangtao/SDK_CPU_HCC_TEST/hi1822/SDK_CPU_HCC/build/script/1822/hi1822_build_dir/src/gcc-6.3.0/gcc/cfgrtl.c:3654 0x11e85c9 reorder_basic_blocks /home/wangtao/SDK_CPU_HCC_TEST/hi1822/SDK_CPU_HCC/build/script/1822/hi1822_build_dir/src/gcc-6.3.0/gcc/bb-reorder.c:2501 0x11e862c execute /home/wangtao/SDK_CPU_HCC_TEST/hi1822/SDK_CPU_HCC/build/script/1822/hi1822_build_dir/src/gcc-6.3.0/gcc/bb-reorder.c:2591 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. I debug it, and find that there is a bug when reorder bb according to cold/hot partition in function reorder_basic_blocks_simple. In find_rarely_executed_basic_blocks_and_crossing_edges will not set partition for the first bb(cfun->cfg->x_entry_block_ptr), but reorderring bb in reorder_basic_blocks_simple may be according to the partition of the first bb. Therefore, after reorderring, some bbs have been lost, which triggered ICE. According to the above, I set a default partition for reorderring bb when partition is neither hot nor cold, which as the attachment shows. Please check my solution and give some suggestion. Thanks a lot.