[llvm] [llvm] Support multiple save/restore points in mir (PR #119357)

Elizaveta Noskova via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 17 06:42:27 PDT 2025


================
@@ -922,11 +966,10 @@ void RISCVFrameLowering::emitPrologue(MachineFunction &MF,
   // to the stack, not before.
   // FIXME: assumes exactly one instruction is used to save each callee-saved
   // register.
-  std::advance(MBBI, getUnmanagedCSI(MF, CSI).size());
-
-  // Iterate over list of callee-saved registers and emit .cfi_offset
-  // directives.
-  emitCFIForCSI<CFISaveRegisterEmitter>(MBB, MBBI, getUnmanagedCSI(MF, CSI));
+  int Distance = getUnmanagedCSI(MF, CSI).size();
+  if (!RVFI->isPushable(MF) && !RVFI->useSaveRestoreLibCalls(MF))
----------------
enoskova-sc wrote:

This piece of code originally aimed to skip stores of CSRs and right after these stores  emit one CFI instruction for one store.
As in this patch I moved CFI instruction emission to the `spillCalleeSavedRegisters` (because spills can appear not only in Prolog) here we need to remove CFI emission and skip 2*(num of CSRs): 1 for spill + 1 for CFI.

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


More information about the llvm-commits mailing list