diff options
author | Xu Zhang <simonzgx@gmail.com> | 2024-04-24 21:24:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 14:24:14 +0100 |
commit | f6d431f208c0fa48827eac40e7acf788346a9967 (patch) | |
tree | 1ef7233cbc4728923cd3cfafa05f8bbbdaee95f4 /llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | |
parent | 07e6c1609d0a57f7ddc0537b7794be2e0296658b (diff) | |
download | llvm-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/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp index ebacbc4..b9b2841 100644 --- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -339,7 +339,7 @@ bool TwoAddressInstructionPass::isPlainlyKilled(const MachineInstr *MI, }); } - return MI->killsRegister(Reg); + return MI->killsRegister(Reg, /*TRI=*/nullptr); } /// Test if the register used by the given operand is killed by the operand's @@ -1355,8 +1355,10 @@ tryInstructionTransform(MachineBasicBlock::iterator &mi, << "2addr: NEW INST: " << *NewMIs[1]); // Transform the instruction, now that it no longer has a load. - unsigned NewDstIdx = NewMIs[1]->findRegisterDefOperandIdx(regA); - unsigned NewSrcIdx = NewMIs[1]->findRegisterUseOperandIdx(regB); + unsigned NewDstIdx = + NewMIs[1]->findRegisterDefOperandIdx(regA, /*TRI=*/nullptr); + unsigned NewSrcIdx = + NewMIs[1]->findRegisterUseOperandIdx(regB, /*TRI=*/nullptr); MachineBasicBlock::iterator NewMI = NewMIs[1]; bool TransformResult = tryInstructionTransform(NewMI, mi, NewSrcIdx, NewDstIdx, Dist, true); @@ -1371,19 +1373,22 @@ tryInstructionTransform(MachineBasicBlock::iterator &mi, if (MO.isReg() && MO.getReg().isVirtual()) { if (MO.isUse()) { if (MO.isKill()) { - if (NewMIs[0]->killsRegister(MO.getReg())) + if (NewMIs[0]->killsRegister(MO.getReg(), /*TRI=*/nullptr)) LV->replaceKillInstruction(MO.getReg(), MI, *NewMIs[0]); else { - assert(NewMIs[1]->killsRegister(MO.getReg()) && + assert(NewMIs[1]->killsRegister(MO.getReg(), + /*TRI=*/nullptr) && "Kill missing after load unfold!"); LV->replaceKillInstruction(MO.getReg(), MI, *NewMIs[1]); } } } else if (LV->removeVirtualRegisterDead(MO.getReg(), MI)) { - if (NewMIs[1]->registerDefIsDead(MO.getReg())) + if (NewMIs[1]->registerDefIsDead(MO.getReg(), + /*TRI=*/nullptr)) LV->addVirtualRegisterDead(MO.getReg(), *NewMIs[1]); else { - assert(NewMIs[0]->registerDefIsDead(MO.getReg()) && + assert(NewMIs[0]->registerDefIsDead(MO.getReg(), + /*TRI=*/nullptr) && "Dead flag missing after load unfold!"); LV->addVirtualRegisterDead(MO.getReg(), *NewMIs[0]); } |