aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2015-11-20 02:33:24 +0000
committerDan Gohman <dan433584@gmail.com>2015-11-20 02:33:24 +0000
commit7bafa0eaef62731c2c1e011080fe9e3769272c38 (patch)
tree4798452e381e73f0332fd093bc05c82b5c2061eb /llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
parentb044af50f28209ff4eeed8fa4614e78969d8df74 (diff)
downloadllvm-7bafa0eaef62731c2c1e011080fe9e3769272c38.zip
llvm-7bafa0eaef62731c2c1e011080fe9e3769272c38.tar.gz
llvm-7bafa0eaef62731c2c1e011080fe9e3769272c38.tar.bz2
[WebAssembly] Add asserts that the expression stack is used in stack order.
llvm-svn: 253638
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
index b6f2037..5ba7c31 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
@@ -177,5 +177,28 @@ bool WebAssemblyRegStackify::runOnMachineFunction(MachineFunction &MF) {
MBB.addLiveIn(WebAssembly::EXPR_STACK);
}
+#ifndef NDEBUG
+ // Verify that pushes and pops are performed in FIFO order.
+ SmallVector<unsigned, 0> Stack;
+ for (MachineBasicBlock &MBB : MF) {
+ for (MachineInstr &MI : MBB) {
+ for (MachineOperand &MO : reverse(MI.explicit_operands())) {
+ if (!MO.isReg()) continue;
+ unsigned VReg = MO.getReg();
+
+ if (MFI.isVRegStackified(VReg)) {
+ if (MO.isDef())
+ Stack.push_back(VReg);
+ else
+ assert(Stack.pop_back_val() == VReg);
+ }
+ }
+ }
+ // TODO: Generalize this code to support keeping values on the stack across
+ // basic block boundaries.
+ assert(Stack.empty());
+ }
+#endif
+
return Changed;
}