[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] [PATCH v2] RISC-V: Fix type of CFA during stack probe [PR122114]

Jeff Law law@gcc.gnu.org
Fri Jan 30 07:05:39 GMT 2026


https://gcc.gnu.org/g:104fdc68c493b211e27e54b78f97855c58d98b9d

commit 104fdc68c493b211e27e54b78f97855c58d98b9d
Author: Raphael Moreira Zinsly <rzinsly@ventanamicro.com>
Date:   Sat Oct 4 08:36:48 2025 -0600

    [PATCH v2] RISC-V: Fix type of CFA during stack probe [PR122114]
    
    Changes since v1:
            - Limit test to rv64.
    
    -->8--
    
    frame.total_size may not be a constant, this patch changes the type of
    the stored cfa offset to avoid errors trying to convert the frame size.
    
            PR target/122114
    gcc/ChangeLog:
            * config/riscv/riscv.cc
            (riscv_allocate_and_probe_stack_space): Change initial_cfa_offset
            type.
    
    gcc/testsuite/ChangeLog:
            * gcc.target/riscv/pr122114.c: New test.
    
    (cherry picked from commit ab429ea91d50e5ddb8eb5bc2098c6a476860a01b)

Diff:
---
 gcc/config/riscv/riscv.cc                 |  3 +--
 gcc/testsuite/gcc.target/riscv/pr122114.c | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 8e6b09f07121..950c5f02613f 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -9039,8 +9039,7 @@ riscv_allocate_and_probe_stack_space (rtx temp1, HOST_WIDE_INT size)
 	 from the top of the frame, as it might be lowered before.
 	 To consider the correct SP addresses for the CFA notes, it is needed
 	 to correct them with the initial offset value.  */
-      HOST_WIDE_INT initial_cfa_offset
-	= cfun->machine->frame.total_size.to_constant () - size;
+      poly_int64 initial_cfa_offset = cfun->machine->frame.total_size - size;
 
       if (!frame_pointer_needed)
 	{
diff --git a/gcc/testsuite/gcc.target/riscv/pr122114.c b/gcc/testsuite/gcc.target/riscv/pr122114.c
new file mode 100644
index 000000000000..ccb2ec912a74
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr122114.c
@@ -0,0 +1,22 @@
+/* { dg-do compile { target { rv64 } } } */
+/* { dg-options "-O2 -fstack-clash-protection -march=rv64gcv_zvl256b -mabi=lp64d" } */
+
+int pk_gen_i, pk_gen_j;
+long pk_gen_buf[4];
+long pk_gen_t;
+
+void vec_mul(long *, long *, long *);
+void uint64_is_zero_declassify(long);
+
+void pk_gen() {
+  long consts[128][13], prod[128][13];
+
+  vec_mul(prod[pk_gen_j], prod[pk_gen_j], consts[pk_gen_j]);
+
+  for (; pk_gen_i;) {
+    for (; pk_gen_j; pk_gen_j++)
+      pk_gen_t |= pk_gen_buf[pk_gen_j];
+
+    uint64_is_zero_declassify(pk_gen_t);
+  }
+}


More information about the Gcc-cvs mailing list