[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

Ana Pazos via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 3 21:01:36 PDT 2019


apazos added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:631
+      MachineBasicBlock::iterator NewMI =
+          BuildMI(MBB, MI, DL, TII.get(RISCV::PseudoCALL))
+              .add(MI->getOperand(0));
----------------
apazos wrote:
> Where are we making sure the PseudoCALL result in a0 is alive through the riscv_restore call?
I did not find any other target that transforms a tail call back into a regular call.

The issue with doing this is that we don't have info about the return value of the original call.

If anyone knows how to do it, please give me some pointers.

I tried to fix this problem by adding implicit operands to  the riscv_restore tail call that are all the possible return value registers:
BuildMI(MBB, MI, DL, TII.get(RISCV::PseudoTAIL))
.addExternalSymbol(RestoreLibCall, RISCVII::MO_CALL)
-.setMIFlag(MachineInstr::FrameDestroy);
+            .setMIFlag(MachineInstr::FrameDestroy)
+            .addReg(RISCV::X10, RegState::Implicit)
+            .addReg(RISCV::X11, RegState::Implicit)
+            .addReg(RISCV::F10_F, RegState::Implicit)
+            .addReg(RISCV::F11_F, RegState::Implicit)

With this change, some perennial tests now pass.

But there are still failures to be analyzed in SPEC.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62686/new/

https://reviews.llvm.org/D62686





More information about the cfe-commits mailing list