Message ID | 20240516182413.14997-2-palmer@rivosinc.com |
---|---|
State | New |
Headers | show |
Series | [gcc-13] Fix RISC-V missing stack tie | expand |
On 5/16/24 12:24 PM, Palmer Dabbelt wrote: > > gcc/ > * config/riscv/riscv.cc (riscv_expand_prologue): Add missing stack > tie for scalable and final stack adjustment if needed. > > Co-authored-by: Raphael Zinsly <rzinsly@ventanamicro.com> > > (cherry picked from commit c65046ff2ef0a9a46e59bc0b3369b2d226f6a239) > --- > I've only build tested this one, but it's tripping up some of the Fedora > folks here https://bugzilla.redhat.com/show_bug.cgi?id=2242327 so I > figured it's worth backporting. Yes, that's the the original report from Florian that led Raphael and I to dive in. Definitely worth backporting. jeff
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index cefd3b7b2b2..4501bf78c1e 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -5393,7 +5393,15 @@ riscv_expand_prologue (void) /* Second step for constant frame. */ HOST_WIDE_INT constant_frame = size.to_constant (); if (constant_frame == 0) - return; + { + /* We must have allocated stack space for the scalable frame. + Emit a stack tie if we have a frame pointer so that the + allocation is ordered WRT fp setup and subsequent writes + into the frame. */ + if (frame_pointer_needed) + riscv_emit_stack_tie (); + return; + } if (SMALL_OPERAND (-constant_frame)) { @@ -5413,6 +5421,13 @@ riscv_expand_prologue (void) insn = gen_rtx_SET (stack_pointer_rtx, insn); riscv_set_frame_expr (insn); } + + /* We must have allocated the remainder of the stack frame. + Emit a stack tie if we have a frame pointer so that the + allocation is ordered WRT fp setup and subsequent writes + into the frame. */ + if (frame_pointer_needed) + riscv_emit_stack_tie (); } }