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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Kito Cheng <k...@gcc.gnu.org>:

https://gcc.gnu.org/g:327c7c38123eec6264324acd98b4386363d05cb4

commit r14-11567-g327c7c38123eec6264324acd98b4386363d05cb4
Author: æ¾æ²»é <zhijin.z...@spacemit.com>
Date:   Wed Aug 14 14:06:23 2024 +0800

    RISC-V: Fix factor in dwarf_poly_indeterminate_value [PR116305]

    This patch is to fix the bug (BugId:116305) introduced by the commit
    bd93ef for risc-v target.

    The commit bd93ef changes the chunk_num from 1 to TARGET_MIN_VLEN/128
    if TARGET_MIN_VLEN is larger than 128 in riscv_convert_vector_bits. So
    it changes the value of BYTES_PER_RISCV_VECTOR. For example, before
    merging the commit bd93ef and if TARGET_MIN_VLEN is 256, the value
    of BYTES_PER_RISCV_VECTOR should be [8, 8], but now [16, 16]. The value
    of riscv_bytes_per_vector_chunk and BYTES_PER_RISCV_VECTOR are no longer
    equal.

    Prologue will use BYTES_PER_RISCV_VECTOR.coeffs[1] to estimate the vlenb
    register value in riscv_legitimize_poly_move, and dwarf2cfi will also
    get the estimated vlenb register value in
riscv_dwarf_poly_indeterminate_value
    to calculate the number of times to multiply the vlenb register value.

    So need to change the factor from riscv_bytes_per_vector_chunk to
    BYTES_PER_RISCV_VECTOR, otherwise we will get the incorrect dwarf
    information. The incorrect example as follow:

    ```
    csrr    t0,vlenb
    slli    t1,t0,1
    sub     sp,sp,t1

    .cfi_escape 0xf,0xb,0x72,0,0x92,0xa2,0x38,0,0x34,0x1e,0x23,0x50,0x22
    ```

    The sequence '0x92,0xa2,0x38,0' means the vlenb register, '0x34' means
    the literal 4, '0x1e' means the multiply operation. But in fact, the
    vlenb register value just need to multiply the literal 2.

            PR target/116305

    gcc/ChangeLog:

            * config/riscv/riscv.cc (riscv_dwarf_poly_indeterminate_value):
Take
            BYTES_PER_RISCV_VECTOR for *factor instead of
riscv_bytes_per_vector_chunk.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/base/scalable_vector_cfi.c: New test.

    Signed-off-by: Zhijin Zeng <zhijin.z...@spacemit.com>

Reply via email to