[llvm] [SPARC] Prevent RESTORE from sourcing from %o7 in call delay slots (PR #172593)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 14 09:08:50 PST 2026
================
@@ -442,6 +461,20 @@ static bool combineRestoreOR(MachineBasicBlock::iterator RestoreMI,
&& (!OrMI->getOperand(2).isImm() || OrMI->getOperand(2).getImm() != 0))
return false;
+ // Check whether it uses %o7 as its source and the corresponding branch
+ // instruction is a call.
+ MachineBasicBlock::iterator LastInst = MBB.getFirstTerminator();
+ bool IsCall = LastInst != MBB.end() && LastInst->isCall();
+
+ if (IsCall && OrMI->getOpcode() == SP::ORrr &&
+ (OrMI->getOperand(1).getReg() == SP::O7 ||
+ OrMI->getOperand(2).getReg() == SP::O7))
+ return false;
+
+ if (IsCall && OrMI->getOpcode() == SP::ORrr &&
+ OrMI->getOperand(1).getReg() == SP::O7)
+ return false;
----------------
koachan wrote:
Ah yeah, that should be ORri.
https://github.com/llvm/llvm-project/pull/172593
More information about the llvm-commits
mailing list