diff options
author | Reid Kleckner <rnk@google.com> | 2017-11-08 21:31:14 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-11-08 21:31:14 +0000 |
commit | 7adb2fdbbadd0c588a2137c7362a9099574d79ae (patch) | |
tree | 51b8a7eec92f22bbf2869969130a0fce1886de6b /llvm/lib/Target/X86/X86FrameLowering.cpp | |
parent | a702fa17f31abd5efce302ef3d4cf2fbaf167368 (diff) | |
download | bcm5719-llvm-7adb2fdbbadd0c588a2137c7362a9099574d79ae.tar.gz bcm5719-llvm-7adb2fdbbadd0c588a2137c7362a9099574d79ae.zip |
Revert "Correct dwarf unwind information in function epilogue for X86"
This reverts r317579, originally committed as r317100.
There is a design issue with marking CFI instructions duplicatable. Not
all targets support the CFIInstrInserter pass, and targets like Darwin
can't cope with duplicated prologue setup CFI instructions. The compact
unwind info emission fails.
When the following code is compiled for arm64 on Mac at -O3, the CFI
instructions end up getting tail duplicated, which causes compact unwind
info emission to fail:
int a, c, d, e, f, g, h, i, j, k, l, m;
void n(int o, int *b) {
if (g)
f = 0;
for (; f < o; f++) {
m = a;
if (l > j * k > i)
j = i = k = d;
h = b[c] - e;
}
}
We get assembly that looks like this:
; BB#1: ; %if.then
Lloh3:
adrp x9, _f@GOTPAGE
Lloh4:
ldr x9, [x9, _f@GOTPAGEOFF]
mov w8, wzr
Lloh5:
str wzr, [x9]
stp x20, x19, [sp, #-16]! ; 8-byte Folded Spill
.cfi_def_cfa_offset 16
.cfi_offset w19, -8
.cfi_offset w20, -16
cmp w8, w0
b.lt LBB0_3
b LBB0_7
LBB0_2: ; %entry.if.end_crit_edge
Lloh6:
adrp x8, _f@GOTPAGE
Lloh7:
ldr x8, [x8, _f@GOTPAGEOFF]
Lloh8:
ldr w8, [x8]
stp x20, x19, [sp, #-16]! ; 8-byte Folded Spill
.cfi_def_cfa_offset 16
.cfi_offset w19, -8
.cfi_offset w20, -16
cmp w8, w0
b.ge LBB0_7
LBB0_3: ; %for.body.lr.ph
Note the multiple .cfi_def* directives. Compact unwind info emission
can't handle that.
llvm-svn: 317726
Diffstat (limited to 'llvm/lib/Target/X86/X86FrameLowering.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86FrameLowering.cpp | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp index 86e65b83ffa..c7af0ae43d2 100644 --- a/llvm/lib/Target/X86/X86FrameLowering.cpp +++ b/llvm/lib/Target/X86/X86FrameLowering.cpp @@ -1562,11 +1562,6 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF, bool HasFP = hasFP(MF); uint64_t NumBytes = 0; - bool NeedsDwarfCFI = - (!MF.getTarget().getTargetTriple().isOSDarwin() && - !MF.getTarget().getTargetTriple().isOSWindows()) && - (MF.getMMI().hasDebugInfo() || MF.getFunction()->needsUnwindTableEntry()); - if (IsFunclet) { assert(HasFP && "EH funclets without FP not yet implemented"); NumBytes = getWinEHFuncletFrameSize(MF); @@ -1589,13 +1584,6 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF, BuildMI(MBB, MBBI, DL, TII.get(Is64Bit ? X86::POP64r : X86::POP32r), MachineFramePtr) .setMIFlag(MachineInstr::FrameDestroy); - if (NeedsDwarfCFI) { - unsigned DwarfStackPtr = - TRI->getDwarfRegNum(Is64Bit ? X86::RSP : X86::ESP, true); - BuildCFI(MBB, MBBI, DL, MCCFIInstruction::createDefCfa( - nullptr, DwarfStackPtr, -SlotSize)); - --MBBI; - } } MachineBasicBlock::iterator FirstCSPop = MBBI; @@ -1659,11 +1647,6 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF, } else if (NumBytes) { // Adjust stack pointer back: ESP += numbytes. emitSPUpdate(MBB, MBBI, NumBytes, /*InEpilogue=*/true); - if (!hasFP(MF) && NeedsDwarfCFI) { - // Define the current CFA rule to use the provided offset. - BuildCFI(MBB, MBBI, DL, MCCFIInstruction::createDefCfaOffset( - nullptr, -CSSize - SlotSize)); - } --MBBI; } @@ -1676,23 +1659,6 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF, if (NeedsWin64CFI && MF.hasWinCFI()) BuildMI(MBB, MBBI, DL, TII.get(X86::SEH_Epilogue)); - if (!hasFP(MF) && NeedsDwarfCFI) { - MBBI = FirstCSPop; - int64_t Offset = -CSSize - SlotSize; - // Mark callee-saved pop instruction. - // Define the current CFA rule to use the provided offset. - while (MBBI != MBB.end()) { - MachineBasicBlock::iterator PI = MBBI; - unsigned Opc = PI->getOpcode(); - ++MBBI; - if (Opc == X86::POP32r || Opc == X86::POP64r) { - Offset += SlotSize; - BuildCFI(MBB, MBBI, DL, - MCCFIInstruction::createDefCfaOffset(nullptr, Offset)); - } - } - } - if (Terminator == MBB.end() || !isTailCallOpcode(Terminator->getOpcode())) { // Add the return addr area delta back since we are not tail calling. int Offset = -1 * X86FI->getTCReturnAddrDelta(); @@ -2874,15 +2840,6 @@ MachineBasicBlock::iterator X86FrameLowering::restoreWin32EHStackPointers( return MBBI; } -int X86FrameLowering::getInitialCFAOffset(const MachineFunction &MF) const { - return TRI->getSlotSize(); -} - -unsigned X86FrameLowering::getInitialCFARegister(const MachineFunction &MF) - const { - return TRI->getDwarfRegNum(StackPtr, true); -} - namespace { // Struct used by orderFrameObjects to help sort the stack objects. struct X86FrameSortingObject { |