https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118540

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pan Li <pa...@gcc.gnu.org>:

https://gcc.gnu.org/g:17b95cfc310c0b3ef191cd47ceb3b4ee1205e8bf

commit r15-7600-g17b95cfc310c0b3ef191cd47ceb3b4ee1205e8bf
Author: Pan Li <pan2...@intel.com>
Date:   Sat Feb 15 14:33:35 2025 +0800

    RISC-V: Fix ICE for target attributes has different xlen size

    This patch would like to avoid the ICE when the target attribute
    specific the xlen different to the cmd.  Aka compile with rv64gc
    but target attribute with rv32gcv_zbb.  For example as blow:

       1   â long foo (long a, long b)
       2   â __attribute__((target("arch=rv32gcv_zbb")));
       3   â
       4   â long foo (long a, long b)
       5   â {
       6   â   return a + (b * 2);
       7   â }

    when compile with rv64gc -O3, it will have ICE similar as below

    during RTL pass: fwprop1
    test.c: In function âfooâ:
    test.c:10:1: internal compiler error: in add_use, at
    rtl-ssa/accesses.cc:1234
       10 | }
          | ^
    0x44d6b9d internal_error(char const*, ...)
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/diagnostic-global-context.cc:517
    0x44a26a6 fancy_abort(char const*, int, char const*)
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/diagnostic.cc:1722
    0x408fac9 rtl_ssa::function_info::add_use(rtl_ssa::use_info*)
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/rtl-ssa/accesses.cc:1234
    0x40a5eea
    rtl_ssa::function_info::create_reg_use(rtl_ssa::function_info::build_info&,
    rtl_ssa::insn_info*, rtl_ssa::resource_info)
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/rtl-ssa/insns.cc:496
    0x4456738
   
rtl_ssa::function_info::add_artificial_accesses(rtl_ssa::function_info::build_info&,
    df_ref_flags)
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/rtl-ssa/blocks.cc:900
    0x4457297
    rtl_ssa::function_info::start_block(rtl_ssa::function_info::build_info&,
    rtl_ssa::bb_info*)
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/rtl-ssa/blocks.cc:1082
    0x4453627
    rtl_ssa::function_info::bb_walker::before_dom_children(basic_block_def*)
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/rtl-ssa/blocks.cc:118
    0x3e9f3fb dom_walker::walk(basic_block_def*)
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/domwalk.cc:311
    0x445806f rtl_ssa::function_info::process_all_blocks()
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/rtl-ssa/blocks.cc:1298
    0x40a22d3 rtl_ssa::function_info::function_info(function*)
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/rtl-ssa/functions.cc:51
    0x3ec3f80 fwprop_init
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/fwprop.cc:893
    0x3ec420d fwprop
           
/home/pli/gcc/111/riscv-gnu-toolchain/gcc/__RISC-V_BUILD__/../gcc/fwprop.cc:963
    0x3ec43ad execute

    Consider stage 4, we just report error for the above scenario when
    detect the cmd xlen is different to the target attribute during the
    target hook TARGET_OPTION_VALID_ATTRIBUTE_P implementation.

            PR target/118540

    gcc/ChangeLog:

            * config/riscv/riscv-target-attr.cc
(riscv_target_attr_parser::parse_arch):
            Report error when cmd xlen is different with target attribute.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/base/pr118540-1.c: New test.
            * gcc.target/riscv/rvv/base/pr118540-2.c: New test.

    Signed-off-by: Pan Li <pan2...@intel.com>

Reply via email to