diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-04-14 21:41:27 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-06-22 18:20:56 +0000 |
commit | bdd1243df58e60e85101c09001d9812a789b6bc4 (patch) | |
tree | a1ce621c7301dd47ba2ddc3b8eaa63b441389481 /contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp | |
parent | 781624ca2d054430052c828ba8d2c2eaf2d733e7 (diff) | |
parent | e3b557809604d036af6e00c60f012c2025b59a5e (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp b/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp index f9ef45bfb41c..4b24f7fdb118 100644 --- a/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp +++ b/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp @@ -336,12 +336,17 @@ static bool isSafeToMove(const MachineOperand *Def, const MachineOperand *Use, // instruction in which the current value is used, we cannot // stackify. Stackifying in this case would require that def moving below the // current def in the stack, which cannot be achieved, even with locals. + // Also ensure we don't sink the def past any other prior uses. for (const auto &SubsequentDef : drop_begin(DefI->defs())) { - for (const auto &PriorUse : UseI->uses()) { - if (&PriorUse == Use) - break; - if (PriorUse.isReg() && SubsequentDef.getReg() == PriorUse.getReg()) - return false; + auto I = std::next(MachineBasicBlock::const_iterator(DefI)); + auto E = std::next(MachineBasicBlock::const_iterator(UseI)); + for (; I != E; ++I) { + for (const auto &PriorUse : I->uses()) { + if (&PriorUse == Use) + break; + if (PriorUse.isReg() && SubsequentDef.getReg() == PriorUse.getReg()) + return false; + } } } @@ -370,7 +375,7 @@ static bool isSafeToMove(const MachineOperand *Def, const MachineOperand *Use, !Insert->readsRegister(Reg)) continue; - if (Register::isPhysicalRegister(Reg)) { + if (Reg.isPhysical()) { // Ignore ARGUMENTS; it's just used to keep the ARGUMENT_* instructions // from moving down, and we've already checked for that. if (Reg == WebAssembly::ARGUMENTS) @@ -466,8 +471,7 @@ static bool oneUseDominatesOtherUses(unsigned Reg, const MachineOperand &OneUse, if (!MO.isReg()) return false; Register DefReg = MO.getReg(); - if (!Register::isVirtualRegister(DefReg) || - !MFI.isVRegStackified(DefReg)) + if (!DefReg.isVirtual() || !MFI.isVRegStackified(DefReg)) return false; assert(MRI.hasOneNonDBGUse(DefReg)); const MachineOperand &NewUse = *MRI.use_nodbg_begin(DefReg); @@ -842,7 +846,7 @@ bool WebAssemblyRegStackify::runOnMachineFunction(MachineFunction &MF) { assert(Use.isUse() && "explicit_uses() should only iterate over uses"); assert(!Use.isImplicit() && "explicit_uses() should only iterate over explicit operands"); - if (Register::isPhysicalRegister(Reg)) + if (Reg.isPhysical()) continue; // Identify the definition for this register at this point. |