aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.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/WebAssembly/WebAssemblyRegStackify.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/WebAssembly/WebAssemblyRegStackify.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
index 3046f947..ef174e1 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
@@ -80,13 +80,13 @@ FunctionPass *llvm::createWebAssemblyRegStackify() {
// the expression stack.
static void imposeStackOrdering(MachineInstr *MI) {
// Write the opaque VALUE_STACK register.
- if (!MI->definesRegister(WebAssembly::VALUE_STACK))
+ if (!MI->definesRegister(WebAssembly::VALUE_STACK, /*TRI=*/nullptr))
MI->addOperand(MachineOperand::CreateReg(WebAssembly::VALUE_STACK,
/*isDef=*/true,
/*isImp=*/true));
// Also read the opaque VALUE_STACK register.
- if (!MI->readsRegister(WebAssembly::VALUE_STACK))
+ if (!MI->readsRegister(WebAssembly::VALUE_STACK, /*TRI=*/nullptr))
MI->addOperand(MachineOperand::CreateReg(WebAssembly::VALUE_STACK,
/*isDef=*/false,
/*isImp=*/true));
@@ -371,8 +371,8 @@ static bool isSafeToMove(const MachineOperand *Def, const MachineOperand *Use,
Register Reg = MO.getReg();
// If the register is dead here and at Insert, ignore it.
- if (MO.isDead() && Insert->definesRegister(Reg) &&
- !Insert->readsRegister(Reg))
+ if (MO.isDead() && Insert->definesRegister(Reg, /*TRI=*/nullptr) &&
+ !Insert->readsRegister(Reg, /*TRI=*/nullptr))
continue;
if (Reg.isPhysical()) {
@@ -864,7 +864,8 @@ bool WebAssemblyRegStackify::runOnMachineFunction(MachineFunction &MF) {
if (WebAssembly::isArgument(DefI->getOpcode()))
continue;
- MachineOperand *Def = DefI->findRegisterDefOperand(Reg);
+ MachineOperand *Def =
+ DefI->findRegisterDefOperand(Reg, /*TRI=*/nullptr);
assert(Def != nullptr);
// Decide which strategy to take. Prefer to move a single-use value