[llvm] [RISCV] Remove CalleeSavedInfo for Zcmp/save-restore-libcalls registers (PR #79535)

Yeting Kuo via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 28 22:08:52 PST 2024


================
@@ -1252,6 +1252,30 @@ void RISCVFrameLowering::processFunctionBeforeFrameFinalized(
   RVFI->setCalleeSavedStackSize(Size);
 }
 
+void RISCVFrameLowering::processFunctionBeforeFrameIndicesReplaced(
+    MachineFunction &MF, RegScavenger *RS) const {
+  // Remove CalleeSavedInfo for registers saved by Zcmp or save/restore
+  // libcalls.
+  MachineFrameInfo &MFI = MF.getFrameInfo();
+  const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
+  const auto *RVFI = MF.getInfo<RISCVMachineFunctionInfo>();
+  if (!RVFI->isPushable(MF) && !RVFI->useSaveRestoreLibCalls(MF))
+    return;
+  const std::vector<CalleeSavedInfo> &CSIs = MFI.getCalleeSavedInfo();
+  std::vector<CalleeSavedInfo> NewCSIs;
+  for (const auto &CSI : CSIs) {
+    // Skip CSRs that have fake a frame index.
+    [[maybe_unused]] int ReservedFI = 0;
----------------
yetingk wrote:

I don't think you need `[[maybe_unused]]` here.

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


More information about the llvm-commits mailing list