/// false, the stack red zone can be used and only a local SP is needed.
bool WebAssemblyFrameLowering::needsSPWriteback(
const MachineFunction &MF, const MachineFrameInfo &MFI) const {
+ assert(needsSP(MF, MFI));
return MFI.getStackSize() > RedZoneSize || MFI.hasCalls() ||
MF.getFunction()->hasFnAttribute(Attribute::NoRedZone);
}
if (InsertPt != MBB.end()) {
DL = InsertPt->getDebugLoc();
+
+ // If code has been stackified with the return, disconnect it so that we
+ // don't break the tree when we insert code just before the return.
+ if (InsertPt->isReturn() && InsertPt->getNumExplicitOperands() != 0) {
+ WebAssemblyFunctionInfo &MFI = *MF.getInfo<WebAssemblyFunctionInfo>();
+ MFI.unstackifyVReg(InsertPt->getOperand(0).getReg());
+ }
}
// Restore the stack pointer. If we had fixed-size locals, add the offset
}
}
// Allocate locals for used physical registers
- bool HasFP = MF.getSubtarget().getFrameLowering()->hasFP(MF);
+ bool HasFP =
+ MF.getSubtarget<WebAssemblySubtarget>().getFrameLowering()->hasFP(MF);
if (FrameInfo.getStackSize() > 0 || FrameInfo.adjustsStack() || HasFP) {
DEBUG(dbgs() << "PReg SP " << CurReg << "\n");
MFI.addPReg(WebAssembly::SP32, CurReg++);
unreachable
}
+; Don't stackify an expression that might use the stack into a return, since we
+; might insert a prologue before the return.
+
+; CHECK-LABEL: no_stackify_past_epilogue:
+; CHECK: return ${{[0-9]+}}{{$}}
+declare i32 @use_memory(i32*)
+define i32 @no_stackify_past_epilogue() {
+ %x = alloca i32
+ %call = call i32 @use_memory(i32* %x)
+ ret i32 %call
+}
+
!llvm.module.flags = !{!0}
!llvm.dbg.cu = !{!1}