aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
diff options
context:
space:
mode:
authorSamuel Parker <sam.parker@arm.com>2022-11-15 09:15:32 +0000
committerSamuel Parker <sam.parker@arm.com>2022-11-16 09:02:40 +0000
commitb303c0027ff7f3a9912d7690886b7b7b33ddb05f (patch)
treea7790412d2aa9a530ea4fc436c33cefd829ddb64 /llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
parentd128a03ff3b1d3e48fae41a10e790faf3a775d35 (diff)
downloadllvm-b303c0027ff7f3a9912d7690886b7b7b33ddb05f.zip
llvm-b303c0027ff7f3a9912d7690886b7b7b33ddb05f.tar.gz
llvm-b303c0027ff7f3a9912d7690886b7b7b33ddb05f.tar.bz2
[WebAssembly] multivalue stackify fix
Don't attempt to move a multivalue def past one of it's prior uses. Differential Revision: https://reviews.llvm.org/D137824
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
index f9ef45b..61cd0c2 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
+++ b/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;
+ }
}
}