summaryrefslogtreecommitdiff
path: root/lib/Target/X86/X86FrameLowering.cpp
diff options
context:
space:
mode:
authorNico Rieck <nico.rieck@gmail.com>2013-07-08 11:20:11 +0000
committerNico Rieck <nico.rieck@gmail.com>2013-07-08 11:20:11 +0000
commit4010110ccf21be0517034b6ccf9493628afaad77 (patch)
treebbdd2808b85b35c53dd4f6aede1f7bedae5d2c6a /lib/Target/X86/X86FrameLowering.cpp
parent63e7778b53a1c8c190d5c67a9e8871c2acb00b26 (diff)
Reuse %rax after calling __chkstk on win64
Reapply this as I reverted the wrong commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86FrameLowering.cpp')
-rw-r--r--lib/Target/X86/X86FrameLowering.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Target/X86/X86FrameLowering.cpp b/lib/Target/X86/X86FrameLowering.cpp
index 9d66bfd88a8..5db431b60a4 100644
--- a/lib/Target/X86/X86FrameLowering.cpp
+++ b/lib/Target/X86/X86FrameLowering.cpp
@@ -914,11 +914,14 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
.addReg(X86::EFLAGS, RegState::Define | RegState::Implicit)
.setMIFlag(MachineInstr::FrameSetup);
- // MSVC x64's __chkstk needs to adjust %rsp.
- // FIXME: %rax preserves the offset and should be available.
- if (isSPUpdateNeeded)
- emitSPUpdate(MBB, MBBI, StackPtr, -(int64_t)NumBytes, Is64Bit, IsLP64,
- UseLEA, TII, *RegInfo);
+ // MSVC x64's __chkstk does not adjust %rsp itself.
+ // It also does not clobber %rax so we can reuse it when adjusting %rsp.
+ if (isSPUpdateNeeded) {
+ BuildMI(MBB, MBBI, DL, TII.get(X86::SUB64rr), StackPtr)
+ .addReg(StackPtr)
+ .addReg(X86::RAX)
+ .setMIFlag(MachineInstr::FrameSetup);
+ }
if (isEAXAlive) {
// Restore EAX