[clang] [llvm] [RISCV] Add partial support for -fzero-call-used-regs (PR #194883)

Sam Elliott via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 16:12:17 PDT 2026


================
@@ -3936,6 +3936,23 @@ MachineBasicBlock::iterator RISCVInstrInfo::insertOutlinedCall(
   return It;
 }
 
+void RISCVInstrInfo::buildClearRegister(Register Reg, MachineBasicBlock &MBB,
+                                        MachineBasicBlock::iterator Iter,
+                                        DebugLoc &DL,
+                                        bool AllowSideEffects) const {
+
+  const MachineFunction &MF = *MBB.getParent();
+  const RISCVSubtarget &STI = MF.getSubtarget<RISCVSubtarget>();
+  const RISCVRegisterInfo &TRI = *STI.getRegisterInfo();
+
+  if (TRI.isGeneralPurposeRegister(MF, Reg)) {
+    BuildMI(MBB, Iter, DL, get(RISCV::PseudoClearGPR), Reg);
+  } else {
+    llvm::report_fatal_error(
----------------
lenary wrote:

```suggestion
    llvm::reportFatalInternalError(
```

(report_fatal_error is deprecated)

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


More information about the cfe-commits mailing list