[llvm] a291601 - [Lanai] Use backwards scavenging in frame index elimination
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Thu May 18 02:05:49 PDT 2023
Author: Jay Foad
Date: 2023-05-18T09:58:45+01:00
New Revision: a2916016d825d4ad2011a70ca93e08a215bcdcfc
URL: https://github.com/llvm/llvm-project/commit/a2916016d825d4ad2011a70ca93e08a215bcdcfc
DIFF: https://github.com/llvm/llvm-project/commit/a2916016d825d4ad2011a70ca93e08a215bcdcfc.diff
LOG: [Lanai] Use backwards scavenging in frame index elimination
This is preferred because it does not rely on accurate kill flags.
Differential Revision: https://reviews.llvm.org/D150600
Added:
Modified:
llvm/lib/Target/Lanai/LanaiRegisterInfo.cpp
llvm/lib/Target/Lanai/LanaiRegisterInfo.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/Lanai/LanaiRegisterInfo.cpp b/llvm/lib/Target/Lanai/LanaiRegisterInfo.cpp
index 5450bdb30764..3a271cb95c07 100644
--- a/llvm/lib/Target/Lanai/LanaiRegisterInfo.cpp
+++ b/llvm/lib/Target/Lanai/LanaiRegisterInfo.cpp
@@ -167,7 +167,7 @@ bool LanaiRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
assert(RS && "Register scavenging must be on");
Register Reg = RS->FindUnusedReg(&Lanai::GPRRegClass);
if (!Reg)
- Reg = RS->scavengeRegister(&Lanai::GPRRegClass, II, SPAdj);
+ Reg = RS->scavengeRegisterBackwards(Lanai::GPRRegClass, II, false, SPAdj);
assert(Reg && "Register scavenger failed");
bool HasNegOffset = false;
@@ -235,10 +235,11 @@ bool LanaiRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
.addReg(FrameReg)
.addImm(-Offset);
MI.eraseFromParent();
- } else {
- MI.getOperand(FIOperandNum).ChangeToRegister(FrameReg, /*isDef=*/false);
- MI.getOperand(FIOperandNum + 1).ChangeToImmediate(Offset);
+ return true;
}
+
+ MI.getOperand(FIOperandNum).ChangeToRegister(FrameReg, /*isDef=*/false);
+ MI.getOperand(FIOperandNum + 1).ChangeToImmediate(Offset);
return false;
}
diff --git a/llvm/lib/Target/Lanai/LanaiRegisterInfo.h b/llvm/lib/Target/Lanai/LanaiRegisterInfo.h
index 5168dddd9301..89d9eba7f891 100644
--- a/llvm/lib/Target/Lanai/LanaiRegisterInfo.h
+++ b/llvm/lib/Target/Lanai/LanaiRegisterInfo.h
@@ -34,6 +34,8 @@ struct LanaiRegisterInfo : public LanaiGenRegisterInfo {
bool requiresRegisterScavenging(const MachineFunction &MF) const override;
+ bool supportsBackwardScavenger() const override { return true; }
+
bool eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj,
unsigned FIOperandNum,
RegScavenger *RS = nullptr) const override;
More information about the llvm-commits
mailing list