[llvm] [RISC-V] Fix crash with late stack realignment requirement (PR #83496)

Nemanja Ivanovic via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 29 16:45:20 PST 2024


================
@@ -1175,6 +1178,35 @@ static unsigned estimateFunctionSizeInBytes(const MachineFunction &MF,
   return FnSize;
 }
 
+Align RISCVFrameLowering::maxPossibleSpillAlign(
+    const MachineFunction &MF) const {
+  if (MaxSpillAlign.contains(&MF))
+    return MaxSpillAlign.at(&MF);
+
+  const MachineRegisterInfo &MRI = MF.getRegInfo();
+  const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
+  Align CurrMaxAlign = Align(1);
+  // The maximum spill alignment has not yet been computed. Compute it.
+  for (const MachineBasicBlock &MBB : MF) {
+    for (const MachineInstr &MI : MBB) {
+      for (const MachineOperand &MO : MI.operands()) {
+        if (!MO.isReg())
+          continue;
+        Register Reg = MO.getReg();
+        const TargetRegisterClass *RC;
+        if (Reg.isPhysical())
----------------
nemanjai wrote:

Decided to remove it after all. It fails on implicit defs that don't have a register class anyway.

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


More information about the llvm-commits mailing list