From 681a5632e0afaa24cc2a3d50a30be08d27dbfd35 Mon Sep 17 00:00:00 2001 From: Ju-Zhe Zhong Date: Sat, 24 Dec 2022 11:08:00 +0800 Subject: [PATCH] RISC-V: Fix ICE of visiting non-existing block in CFG. This patch is to fix issue of visiting non-existing block of CFG. Since blocks index of CFG in GCC are not always contiguous, we will potentially visit a gap block which is no existing in the current CFG. This patch can avoid visiting non existing block in CFG. I noticed such issue in my internal regression of current testsuite when I change the X86 server machine. This patch fix it: 17:27:15 job(build_and_test_rv32): Increased FAIL List: 17:27:15 job(build_and_test_rv32): FAIL: gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-46.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (internal compiler error: Segmentation fault) gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (pass_vsetvl::compute_global_backward_infos): Change to visit CFG. (pass_vsetvl::prune_expressions): Ditto. --- gcc/config/riscv/riscv-vsetvl.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index a55b5a1..0d66765 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -1962,12 +1962,10 @@ pass_vsetvl::compute_global_backward_infos (void) if (dump_file) { fprintf (dump_file, "\n\nDirty blocks list: "); - for (size_t i = 0; i < m_vector_manager->vector_block_infos.length (); - i++) - { - if (m_vector_manager->vector_block_infos[i].reaching_out.dirty_p ()) - fprintf (dump_file, "%ld ", i); - } + for (const bb_info *bb : crtl->ssa->bbs ()) + if (m_vector_manager->vector_block_infos[bb->index ()] + .reaching_out.dirty_p ()) + fprintf (dump_file, "%d ", bb->index ()); fprintf (dump_file, "\n\n"); } } @@ -1976,15 +1974,16 @@ pass_vsetvl::compute_global_backward_infos (void) void pass_vsetvl::prune_expressions (void) { - for (size_t i = 0; i < m_vector_manager->vector_block_infos.length (); i++) + for (const bb_info *bb : crtl->ssa->bbs ()) { - if (m_vector_manager->vector_block_infos[i].local_dem.valid_or_dirty_p ()) + if (m_vector_manager->vector_block_infos[bb->index ()] + .local_dem.valid_or_dirty_p ()) m_vector_manager->create_expr ( - m_vector_manager->vector_block_infos[i].local_dem); - if (m_vector_manager->vector_block_infos[i] + m_vector_manager->vector_block_infos[bb->index ()].local_dem); + if (m_vector_manager->vector_block_infos[bb->index ()] .reaching_out.valid_or_dirty_p ()) m_vector_manager->create_expr ( - m_vector_manager->vector_block_infos[i].reaching_out); + m_vector_manager->vector_block_infos[bb->index ()].reaching_out); } if (dump_file) -- 2.7.4