[X86] Always generate precise CFA adjustments.
This removes the code path that generate "synchronous" (only correct at call site) CFA.
We will probably want to re-introduce it once we are capable of emitting different
.eh_frame and .debug_frame sections.
Differential Revision: http://reviews.llvm.org/D14948
llvm-svn: 254874
diff --git a/llvm/lib/Target/X86/X86CallFrameOptimization.cpp b/llvm/lib/Target/X86/X86CallFrameOptimization.cpp
index 23990b0..fc6ee17 100644
--- a/llvm/lib/Target/X86/X86CallFrameOptimization.cpp
+++ b/llvm/lib/Target/X86/X86CallFrameOptimization.cpp
@@ -500,7 +500,8 @@
// For debugging, when using SP-based CFA, we need to adjust the CFA
// offset after each push.
- if (!TFL->hasFP(MF) && MF.getMMI().usePreciseUnwindInfo())
+ // TODO: This is needed only if we require precise CFA.
+ if (!TFL->hasFP(MF))
TFL->BuildCFI(MBB, std::next(Push), DL,
MCCFIInstruction::createAdjustCfaOffset(nullptr, 4));
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp
index 682f75c..2e7ed58 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -2524,10 +2524,10 @@
// (Pushes of argument for frame setup, callee pops for frame destroy)
Amount -= InternalAmt;
- // If this is a callee-pop calling convention, and we're emitting precise
- // SP-based CFI, emit a CFA adjust for the amount the callee popped.
- if (isDestroy && InternalAmt && DwarfCFI && !hasFP(MF) &&
- MMI.usePreciseUnwindInfo())
+ // TODO: This is needed only if we require precise CFA.
+ // If this is a callee-pop calling convention, emit a CFA adjust for
+ // the amount the callee popped.
+ if (isDestroy && InternalAmt && DwarfCFI && !hasFP(MF))
BuildCFI(MBB, I, DL,
MCCFIInstruction::createAdjustCfaOffset(nullptr, -InternalAmt));
@@ -2548,11 +2548,14 @@
// offset to be correct at each call site, while for debugging we want
// it to be more precise.
int CFAOffset = Amount;
- if (!MMI.usePreciseUnwindInfo())
- CFAOffset += InternalAmt;
- CFAOffset = isDestroy ? -CFAOffset : CFAOffset;
- BuildCFI(MBB, I, DL,
- MCCFIInstruction::createAdjustCfaOffset(nullptr, CFAOffset));
+ // TODO: When not using precise CFA, we also need to adjust for the
+ // InternalAmt here.
+
+ if (CFAOffset) {
+ CFAOffset = isDestroy ? -CFAOffset : CFAOffset;
+ BuildCFI(MBB, I, DL,
+ MCCFIInstruction::createAdjustCfaOffset(nullptr, CFAOffset));
+ }
}
return;
diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp
index 8878c9f..af38680 100644
--- a/llvm/lib/Target/X86/X86MCInstLower.cpp
+++ b/llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1143,8 +1143,10 @@
const X86FrameLowering* FrameLowering =
MF->getSubtarget<X86Subtarget>().getFrameLowering();
bool hasFP = FrameLowering->hasFP(*MF);
-
- bool NeedsDwarfCFI = MMI->usePreciseUnwindInfo();
+
+ // TODO: This is needed only if we require precise CFA.
+ bool NeedsDwarfCFI =
+ (MMI->hasDebugInfo() || MF->getFunction()->needsUnwindTableEntry());
int stackGrowth = -RI->getSlotSize();
if (NeedsDwarfCFI && !hasFP) {