summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp11
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h3
-rw-r--r--llvm/lib/Target/X86/X86FrameLowering.cpp18
3 files changed, 15 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 9b2b3477be7..01d018fdde3 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1339,6 +1339,7 @@ void CodeViewDebug::beginFunctionImpl(const MachineFunction *MF) {
// instruction (AArch64), this will be zero.
CurFn->CSRSize = MFI.getCVBytesOfCalleeSavedRegisters();
CurFn->FrameSize = MFI.getStackSize();
+ CurFn->OffsetAdjustment = MFI.getOffsetAdjustment();
CurFn->HasStackRealignment = TRI->needsStackRealignment(*MF);
// For this function S_FRAMEPROC record, figure out which codeview register
@@ -2599,16 +2600,10 @@ void CodeViewDebug::emitLocalVariable(const FunctionInfo &FI,
// 32-bit x86 call sequences often use PUSH instructions, which disrupt
// ESP-relative offsets. Use the virtual frame pointer, VFRAME or $T0,
- // instead. In simple cases, $T0 will be the CFA.
+ // instead. In frames without stack realignment, $T0 will be the CFA.
if (RegisterId(Reg) == RegisterId::ESP) {
Reg = unsigned(RegisterId::VFRAME);
- Offset -= FI.FrameSize;
-
- // If the frame requires realignment, VFRAME will be ESP after it is
- // aligned. We have to remove the ESP adjustments made to push CSRs and
- // EBP. EBP is not included in CSRSize.
- if (FI.HasStackRealignment)
- Offset += FI.CSRSize + 4;
+ Offset += FI.OffsetAdjustment;
}
// If we can use the chosen frame pointer for the frame and this isn't a
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
index b6fbdc1373f..ef0f0c3635e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
@@ -153,6 +153,9 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase {
/// Number of bytes pushed to save CSRs.
unsigned CSRSize = 0;
+ /// Adjustment to apply on x86 when using the VFRAME frame pointer.
+ int OffsetAdjustment = 0;
+
/// Two-bit value indicating which register is the designated frame pointer
/// register for local variables. Included in S_FRAMEPROC.
codeview::EncodedFramePtrReg EncodedLocalFramePtrReg =
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp
index 1eb9fa0bc1e..67ec867b562 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -1103,15 +1103,6 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
if (TRI->needsStackRealignment(MF) && !IsWin64Prologue)
NumBytes = alignTo(NumBytes, MaxAlign);
- // Get the offset of the stack slot for the EBP register, which is
- // guaranteed to be the last slot by processFunctionBeforeFrameFinalized.
- // Update the frame offset adjustment.
- if (!IsFunclet)
- MFI.setOffsetAdjustment(-NumBytes);
- else
- assert(MFI.getOffsetAdjustment() == -(int)NumBytes &&
- "should calculate same local variable offset for funclets");
-
// Save EBP/RBP into the appropriate stack slot.
BuildMI(MBB, MBBI, DL, TII.get(Is64Bit ? X86::PUSH64r : X86::PUSH32r))
.addReg(MachineFramePtr, RegState::Kill)
@@ -1167,6 +1158,15 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
NumBytes = StackSize - X86FI->getCalleeSavedFrameSize();
}
+ // Update the offset adjustment, which is mainly used by codeview to translate
+ // from ESP to VFRAME relative local variable offsets.
+ if (!IsFunclet) {
+ if (HasFP && TRI->needsStackRealignment(MF))
+ MFI.setOffsetAdjustment(-NumBytes);
+ else
+ MFI.setOffsetAdjustment(-StackSize);
+ }
+
// For EH funclets, only allocate enough space for outgoing calls. Save the
// NumBytes value that we would've used for the parent frame.
unsigned ParentFrameNumBytes = NumBytes;
OpenPOWER on IntegriCloud