[x86] Teach the shrink-wrapping hooks to do the proper thing with Win64.
[oota-llvm.git] / lib / Target / X86 / X86FrameLowering.cpp
index 7b7f0daf12b3ae2b55e572d7f7eab0aae6e38f76..ee866fa45c33443d312c5d72c783ced9436f35b0 100644 (file)
@@ -2184,6 +2184,14 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
 bool X86FrameLowering::canUseAsEpilogue(const MachineBasicBlock &MBB) const {
   assert(MBB.getParent() && "Block is not attached to a function!");
 
+  // Win64 has strict requirements in terms of epilogue and we are
+  // not taking a chance at messing with them.
+  // I.e., unless this block is already an exit block, we can't use
+  // it as an epilogue.
+  if (MBB.getParent()->getSubtarget<X86Subtarget>().isTargetWin64() &&
+      !MBB.succ_empty() && !MBB.isReturnBlock())
+    return false;
+
   if (canUseLEAForSPInEpilogue(*MBB.getParent()))
     return true;