[WebAssembly] Add asserts that the expression stack is used in stack order.
llvm-svn: 253638
This commit is contained in:
parent
b044af50f2
commit
7bafa0eaef
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user