[llvm] d2c8aa0 - [AArch64] Pass Reg instead of MI to tryToFindRenameRegister (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 1 06:02:11 PST 2022
Author: Florian Hahn
Date: 2022-03-01T14:02:02Z
New Revision: d2c8aa0bf49f0af005392a05ca90389b6b8cd26a
URL: https://github.com/llvm/llvm-project/commit/d2c8aa0bf49f0af005392a05ca90389b6b8cd26a
DIFF: https://github.com/llvm/llvm-project/commit/d2c8aa0bf49f0af005392a05ca90389b6b8cd26a.diff
LOG: [AArch64] Pass Reg instead of MI to tryToFindRenameRegister (NFC).
FirstMI is only used to get the load/store operand and the machine
function. Pass the MF and register explicitly, so the helper can be used
to find rename registers for other instructions in the future.
Added:
Modified:
llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
index 7bcc11406c5b6..ccc6eff319e08 100644
--- a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
@@ -1468,18 +1468,19 @@ canRenameUpToDef(MachineInstr &FirstMI, LiveRegUnits &UsedInBetween,
return true;
}
-// Check if we can find a physical register for renaming. This register must:
-// * not be defined up to FirstMI (checking DefinedInBB)
-// * not used between the MI and the defining instruction of the register to
-// rename (checked using UsedInBetween).
+// Check if we can find a physical register for renaming \p Reg. This register
+// must:
+// * not be defined already in \p DefinedInBB; DefinedInBB must contain all
+// defined registers up to the point where the renamed register will be used,
+// * not used in \p UsedInBetween; UsedInBetween must contain all accessed
+// registers in the range the rename register will be used,
// * is available in all used register classes (checked using RequiredClasses).
static Optional<MCPhysReg> tryToFindRegisterToRename(
- MachineInstr &FirstMI, LiveRegUnits &DefinedInBB,
+ const MachineFunction &MF, Register Reg, LiveRegUnits &DefinedInBB,
LiveRegUnits &UsedInBetween,
SmallPtrSetImpl<const TargetRegisterClass *> &RequiredClasses,
const TargetRegisterInfo *TRI) {
- auto &MF = *FirstMI.getParent()->getParent();
- MachineRegisterInfo &RegInfo = MF.getRegInfo();
+ const MachineRegisterInfo &RegInfo = MF.getRegInfo();
// Checks if any sub- or super-register of PR is callee saved.
auto AnySubOrSuperRegCalleePreserved = [&MF, TRI](MCPhysReg PR) {
@@ -1500,7 +1501,7 @@ static Optional<MCPhysReg> tryToFindRegisterToRename(
});
};
- auto *RegClass = TRI->getMinimalPhysRegClass(getLdStRegOp(FirstMI).getReg());
+ auto *RegClass = TRI->getMinimalPhysRegClass(Reg);
for (const MCPhysReg &PR : *RegClass) {
if (DefinedInBB.available(PR) && UsedInBetween.available(PR) &&
!RegInfo.isReserved(PR) && !AnySubOrSuperRegCalleePreserved(PR) &&
@@ -1723,7 +1724,8 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I,
if (*MaybeCanRename) {
Optional<MCPhysReg> MaybeRenameReg = tryToFindRegisterToRename(
- FirstMI, DefinedInBB, UsedInBetween, RequiredClasses, TRI);
+ *FirstMI.getParent()->getParent(), Reg, DefinedInBB,
+ UsedInBetween, RequiredClasses, TRI);
if (MaybeRenameReg) {
Flags.setRenameReg(*MaybeRenameReg);
Flags.setMergeForward(true);
More information about the llvm-commits
mailing list