]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[RISC-V] Fix ICE due to bogus use of gen_rtvec
authorJeff Law <jlaw@ventanamicro.com>
Sat, 17 May 2025 15:37:01 +0000 (09:37 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Sat, 17 May 2025 15:37:01 +0000 (09:37 -0600)
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.

gcc/config/riscv/riscv-vect-permconst.cc

index 8e13cf8d558722dc0f9f757d9273081c572e1b64..087f26aea8aec7d2c1a258665bd3a86243105925 100644 (file)
@@ -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);