[PATCH] X86: Emit an ABI compliant prologue and epilogue for Win64

Reid Kleckner rnk at google.com
Mon Feb 9 15:47:28 PST 2015


All my comments are comment related. :) Let me patch this and test it.


================
Comment at: lib/Target/X86/X86FrameLowering.cpp:894
@@ -869,1 +893,3 @@
 
+  // SP will be the base register for restoring XMMs
+  if (NeedsWinEH && NumBytes)
----------------
This comment is not associated with the relevant code anymore. I'd kill it.

================
Comment at: lib/Target/X86/X86FrameLowering.cpp:937
@@ -933,1 +936,3 @@
 
+  // Realign stack after we pushed callee-saved registers (so that we'll be
+  // able to calculate their offsets from the frame pointer).
----------------
s/pushed/spilled/, since we don't push XMM regs.

================
Comment at: lib/Target/X86/X86FrameLowering.cpp:1212
@@ -1197,2 +1211,3 @@
   const MachineFrameInfo *MFI = MF.getFrameInfo();
   int Offset = MFI->getObjectOffset(FI) - getOffsetOfLocalArea();
+  const X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
----------------
We need to describe what Offset is, since it took so much research to find. My attempt:
Offset will hold the offset from the stack pointer at function entry to the object. We need to factor in additional offsets applied during the prologue to the frame, base, and stack pointer depending on which is used.

================
Comment at: lib/Target/X86/X86FrameLowering.cpp:1242
@@ +1241,3 @@
+    unsigned SEHFrameOffset = calculateSetFPREG(NumBytes);
+    FPDelta = (int64_t)SEHStackAllocAmt - SEHFrameOffset;
+  }
----------------
My attempt at describing this variable:
FPDelta is the offset from the "traditional" FP location of the old base pointer followed by return address and the location required by the restricted Win64 prologue. Add FPDelta to all offsets below that go through the frame pointer.

http://reviews.llvm.org/D7520

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list