aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
diff options
context:
space:
mode:
authorXu Zhang <simonzgx@gmail.com>2024-04-24 21:24:14 +0800
committerGitHub <noreply@github.com>2024-04-24 14:24:14 +0100
commitf6d431f208c0fa48827eac40e7acf788346a9967 (patch)
tree1ef7233cbc4728923cd3cfafa05f8bbbdaee95f4 /llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
parent07e6c1609d0a57f7ddc0537b7794be2e0296658b (diff)
downloadllvm-f6d431f208c0fa48827eac40e7acf788346a9967.zip
llvm-f6d431f208c0fa48827eac40e7acf788346a9967.tar.gz
llvm-f6d431f208c0fa48827eac40e7acf788346a9967.tar.bz2
[CodeGen] Make the parameter TRI required in some functions. (#85968)
Fixes #82659 There are some functions, such as `findRegisterDefOperandIdx` and `findRegisterDefOperand`, that have too many default parameters. As a result, we have encountered some issues due to the lack of TRI parameters, as shown in issue #82411. Following @RKSimon 's suggestion, this patch refactors 9 functions, including `{reads, kills, defines, modifies}Register`, `registerDefIsDead`, and `findRegister{UseOperandIdx, UseOperand, DefOperandIdx, DefOperand}`, adjusting the order of the TRI parameter and making it required. In addition, all the places that call these functions have also been updated correctly to ensure no additional impact. After this, the caller of these functions should explicitly know whether to pass the `TargetRegisterInfo` or just a `nullptr`.
Diffstat (limited to 'llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp')
-rw-r--r--llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
index 4693407..4a5b672 100644
--- a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
@@ -495,7 +495,7 @@ void ARMLoadStoreOpt::UpdateBaseRegUses(MachineBasicBlock &MBB,
bool InsertSub = false;
unsigned Opc = MBBI->getOpcode();
- if (MBBI->readsRegister(Base)) {
+ if (MBBI->readsRegister(Base, /*TRI=*/nullptr)) {
int Offset;
bool IsLoad =
Opc == ARM::tLDRi || Opc == ARM::tLDRHi || Opc == ARM::tLDRBi;
@@ -560,7 +560,8 @@ void ARMLoadStoreOpt::UpdateBaseRegUses(MachineBasicBlock &MBB,
return;
}
- if (MBBI->killsRegister(Base) || MBBI->definesRegister(Base))
+ if (MBBI->killsRegister(Base, /*TRI=*/nullptr) ||
+ MBBI->definesRegister(Base, /*TRI=*/nullptr))
// Register got killed. Stop updating.
return;
}
@@ -888,7 +889,7 @@ MachineInstr *ARMLoadStoreOpt::MergeOpsUpdate(const MergeCandidate &Cand) {
if (is_contained(ImpDefs, DefReg))
continue;
// We can ignore cases where the super-reg is read and written.
- if (MI->readsRegister(DefReg))
+ if (MI->readsRegister(DefReg, /*TRI=*/nullptr))
continue;
ImpDefs.push_back(DefReg);
}
@@ -903,7 +904,7 @@ MachineInstr *ARMLoadStoreOpt::MergeOpsUpdate(const MergeCandidate &Cand) {
MachineBasicBlock &MBB = *LatestMI->getParent();
unsigned Offset = getMemoryOpOffset(*First);
Register Base = getLoadStoreBaseOp(*First).getReg();
- bool BaseKill = LatestMI->killsRegister(Base);
+ bool BaseKill = LatestMI->killsRegister(Base, /*TRI=*/nullptr);
Register PredReg;
ARMCC::CondCodes Pred = getInstrPredicate(*First, PredReg);
DebugLoc DL = First->getDebugLoc();
@@ -2076,7 +2077,8 @@ bool ARMLoadStoreOpt::CombineMovBx(MachineBasicBlock &MBB) {
MachineBasicBlock::iterator Prev = MBBI;
--Prev;
- if (Prev->getOpcode() != ARM::tMOVr || !Prev->definesRegister(ARM::LR))
+ if (Prev->getOpcode() != ARM::tMOVr ||
+ !Prev->definesRegister(ARM::LR, /*TRI=*/nullptr))
return false;
for (auto Use : Prev->uses())
@@ -3176,7 +3178,7 @@ bool ARMPreAllocLoadStoreOpt::DistributeIncrements(Register Base) {
if (PrePostInc || BaseAccess->getParent() != Increment->getParent())
return false;
Register PredReg;
- if (Increment->definesRegister(ARM::CPSR) ||
+ if (Increment->definesRegister(ARM::CPSR, /*TRI=*/nullptr) ||
getInstrPredicate(*Increment, PredReg) != ARMCC::AL)
return false;