[clang] [llvm] [RISCV] Support frame pointers in SiFive CLIC preemptible handlers (PR #221318)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 19 03:29:37 PDT 2026


================
@@ -1456,15 +1433,12 @@ void RISCVFrameLowering::emitEpilogue(MachineFunction &MF,
   if (NeedsDwarfCFI && hasFP(MF))
     CFIBuilder.buildDefCFA(SPReg, RealStackSize);
 
-  // With a frame pointer, restore the SiFive CLIC CSRs through X5.
-  if (hasFP(MF))
-    emitSiFiveCLICPreemptibleRestores(MF, MBB, FirstScalarCSRRestoreInsn, DL);
-
   // Skip to after the restores of scalar callee-saved registers
   // FIXME: assumes exactly one instruction is used to restore each
   // callee-saved register.
   MBBI = std::next(FirstScalarCSRRestoreInsn,
-                   getUnmanagedCSI(MF, CSI, PreferAscendingLS).size());
+                   getScalarSpillCSI(MF, CSI, PreferAscendingLS).size());
+  emitSiFiveCLICPreemptibleRestores(MF, MBB, MBBI, DL);
   CFIBuilder.setInsertPoint(MBBI);
----------------
zeyi2 wrote:

Fixed, thanks!

https://github.com/llvm/llvm-project/pull/221318


More information about the cfe-commits mailing list