summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2016-01-28 03:59:09 +0000
committerDan Gohman <dan433584@gmail.com>2016-01-28 03:59:09 +0000
commitfbfe5ec4a4f64700ab545444811072249d91c763 (patch)
tree96a6473c6537f75fc2d50964e6eb1571ce184a63 /llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
parent343322bb93ce424a3f214de56e034144528037c9 (diff)
[WebAssembly] Don't stackify a register def past a get_local use in the same tree.
llvm-svn: 259013
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
index 3377ca0979d4..15da0d175f33 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
@@ -326,6 +326,17 @@ public:
const RangeTy &Range = Worklist.back();
return Range.begin() != Range.end() && Range.begin()->getParent() == Instr;
}
+
+ /// Test whether the given register is present on the stack, indicating an
+ /// operand in the tree that we haven't visited yet. Moving a definition of
+ /// Reg to a point in the tree after that would change its value.
+ bool IsOnStack(unsigned Reg) const {
+ for (const RangeTy &Range : Worklist)
+ for (const MachineOperand &MO : Range)
+ if (MO.isReg() && MO.getReg() == Reg)
+ return true;
+ return false;
+ }
};
/// State to keep track of whether commuting is in flight or whether it's been
@@ -467,7 +478,8 @@ bool WebAssemblyRegStackify::runOnMachineFunction(MachineFunction &MF) {
// supports intra-block moves) and it's MachineSink's job to catch all
// the sinking opportunities anyway.
bool SameBlock = Def->getParent() == &MBB;
- bool CanMove = SameBlock && IsSafeToMove(Def, Insert, AA, LIS, MRI);
+ bool CanMove = SameBlock && IsSafeToMove(Def, Insert, AA, LIS, MRI) &&
+ !TreeWalker.IsOnStack(Reg);
if (CanMove && MRI.hasOneUse(Reg)) {
Insert = MoveForSingleUse(Reg, Def, MBB, Insert, LIS, MFI);
} else if (Def->isAsCheapAsAMove() &&