[llvm] r253638 - [WebAssembly] Add asserts that the expression stack is used in stack order.
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 19 18:33:24 PST 2015
Author: djg
Date: Thu Nov 19 20:33:24 2015
New Revision: 253638
URL: http://llvm.org/viewvc/llvm-project?rev=253638&view=rev
Log:
[WebAssembly] Add asserts that the expression stack is used in stack order.
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp?rev=253638&r1=253637&r2=253638&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp Thu Nov 19 20:33:24 2015
@@ -177,5 +177,28 @@ bool WebAssemblyRegStackify::runOnMachin
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;
}
More information about the llvm-commits
mailing list