aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2016-05-05 20:41:15 +0000
committerDan Gohman <dan433584@gmail.com>2016-05-05 20:41:15 +0000
commit450a80754f41bdd934aa4c9ce65e5763d71e4e3b (patch)
tree6b64f71a1327049c40c71c426483d41e0e8bc051 /llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
parent338034759af76a5b80abeabd4fc8f32051cebcd4 (diff)
downloadllvm-450a80754f41bdd934aa4c9ce65e5763d71e4e3b.zip
llvm-450a80754f41bdd934aa4c9ce65e5763d71e4e3b.tar.gz
llvm-450a80754f41bdd934aa4c9ce65e5763d71e4e3b.tar.bz2
[WebAssembly] Don't emit epilogue code in the middle of stackified code.
llvm-svn: 268679
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
index 5499581..2e50c7e 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
@@ -72,6 +72,7 @@ bool WebAssemblyFrameLowering::needsSP(const MachineFunction &MF,
/// 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);
}
@@ -190,6 +191,13 @@ void WebAssemblyFrameLowering::emitEpilogue(MachineFunction &MF,
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