https://gcc.gnu.org/g:5159c19cb2a8375fe73e7ab90b118fa55a5e0bbd

commit 5159c19cb2a8375fe73e7ab90b118fa55a5e0bbd
Author: Jeff Law <j...@ventanamicro.com>
Date:   Sat May 17 09:37:01 2025 -0600

    [RISC-V] Fix ICE due to bogus use of gen_rtvec
    
    Found this while setting up the risc-v coordination branch off of gcc-15.  
Not
    sure why I didn't use rtvec_alloc directly here since we're going to 
initialize
    the whole vector ourselves.  Using gen_rtvec was just wrong as it's walking
    down a non-existent varargs list.  Under the "right" circumstances it can 
walk
    off a page and fault.
    
    This was seen with a test already in the testsuite (I forget which test), 
so no
    new regression test.
    
    Tested in my tester and verified the failure on the coordination branch is
    resolved a well.  Waiting on pre-commit CI to render a verdict.
    
    gcc/
            * config/riscv/riscv-vect-permconst.cc 
(vector_permconst:process_bb):
            Use rtvec_alloc, not gen_rtvec since we don't want/need to 
initialize
            the vector.
    
    (cherry picked from commit 7ed37d5ea48f6a51c81f73f35a64ca00c0325fd7)

Diff:
---
 gcc/config/riscv/riscv-vect-permconst.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/riscv/riscv-vect-permconst.cc 
b/gcc/config/riscv/riscv-vect-permconst.cc
index 8e13cf8d5587..087f26aea8ae 100644
--- a/gcc/config/riscv/riscv-vect-permconst.cc
+++ b/gcc/config/riscv/riscv-vect-permconst.cc
@@ -227,7 +227,7 @@ vector_permconst::process_bb (basic_block bb)
         normalize it to zero.
 
         XXX This violates structure sharing conventions.  */
-      rtvec_def *nvec = gen_rtvec (CONST_VECTOR_NUNITS (cvec).to_constant ());
+      rtvec_def *nvec = rtvec_alloc (CONST_VECTOR_NUNITS (cvec).to_constant 
());
 
       for (i = 0; i < CONST_VECTOR_NUNITS (cvec).to_constant (); i++)
        nvec->elem[i] = GEN_INT (INTVAL (CONST_VECTOR_ELT (cvec, i)) - bias);

Reply via email to